FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour User defined Windows captions
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
User defined Windows captions
Posted: Tue May 07, 2019 06:53 AM
Time to have the WinRT look on our captions

captions.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"

#define CLR_MSPURPLE RGB( 128, 57, 123 )
#define CLR_MSRED    RGB( 232, 17,  35 )

function Main()

   local oWnd, oBtnClose

   DEFINE WINDOW oWnd STYLE WS_POPUP COLOR CLR_BLACK, CLR_MSPURPLE

   oWnd:SetSize( 500, 300 )

   @ 1, oWnd:nWidth - 46 BTNBMP oBtnClose BITMAP "../bitmaps/16x16/closew.bmp" ;
      FLAT NOBORDER NOROUND ACTION oWnd:End() SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   oBtnClose:bMMoved = { || oBtnClose:SetColor( CLR_BLACK, If( oBtnClose:lMOver, CLR_MSRED, oWnd:nClrPane ) ) }

   ACTIVATE WINDOW oWnd CENTER

return nil


regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: User defined Windows captions
Posted: Tue May 07, 2019 07:39 AM
Max and Close buttons

captions.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"

#define CLR_MSPURPLE RGB( 128,  57, 123 )
#define CLR_MSRED    RGB( 232,  17,  35 )
#define CLR_MSGRAY   RGB( 229, 229, 229 )

function Main()

   local oWnd, oBtnClose, oBtnMax

   DEFINE WINDOW oWnd STYLE WS_POPUP COLOR CLR_BLACK, CLR_MSPURPLE

   oWnd:SetSize( 500, 300 )

   @ 1, oWnd:nWidth - 46 BTNBMP oBtnClose BITMAP "../bitmaps/16x16/closew.bmp" ;
      FLAT NOBORDER NOROUND ACTION oWnd:End() SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   @ 1, oWnd:nWidth - 92 BTNBMP oBtnMax BITMAP "../bitmaps/16x16/max.bmp" ;
      FLAT NOBORDER NOROUND ACTION If( ! IsZoomed( oWnd:hWnd ), oWnd:Maximize(), oWnd:Restore() ) SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   oBtnClose:bMMoved = { || oBtnClose:SetColor( CLR_BLACK, If( oBtnClose:lMOver, CLR_MSRED, oWnd:nClrPane ) ) }
   oBtnMax:bMMoved   = { || oBtnMax:SetColor( CLR_BLACK, If( oBtnMax:lMOver, CLR_MSGRAY, oWnd:nClrPane ) ) }

   oWnd:bResized = { || oBtnClose:Move( 1, oWnd:nWidth - 46 ), oBtnMax:Move( 1, oWnd:nWidth - 92 ) } 

   ACTIVATE WINDOW oWnd CENTER

return nil


regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: User defined Windows captions
Posted: Tue May 07, 2019 08:01 AM
Min, Max and Close:

captions.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"

#define CLR_MSPURPLE RGB( 128,  57, 123 )
#define CLR_MSRED    RGB( 232,  17,  35 )
#define CLR_MSGRAY   RGB( 229, 229, 229 )

function Main()

   local oWnd, oBtnClose, oBtnMax, oBtnMin

   DEFINE WINDOW oWnd STYLE WS_POPUP COLOR CLR_BLACK, CLR_MSPURPLE

   oWnd:SetSize( 500, 300 )

   @ 1, oWnd:nWidth - 46 BTNBMP oBtnClose BITMAP "../bitmaps/16x16/closew.bmp" ;
      FLAT NOBORDER NOROUND ACTION oWnd:End() SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   @ 1, oWnd:nWidth - 92 BTNBMP oBtnMax BITMAP "../bitmaps/16x16/max.bmp" ;
      FLAT NOBORDER NOROUND ACTION If( ! IsZoomed( oWnd:hWnd ), oWnd:Maximize(), oWnd:Restore() ) SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   @ 1, oWnd:nWidth - 138 BTNBMP oBtnMin BITMAP "../bitmaps/16x16/min.bmp" ;
      FLAT NOBORDER NOROUND ACTION If( ! IsIconic( oWnd:hWnd ), oWnd:Iconize(), oWnd:Restore() ) SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   oBtnClose:bMMoved = { || oBtnClose:SetColor( CLR_BLACK, If( oBtnClose:lMOver, CLR_MSRED, oWnd:nClrPane ) ) }
   oBtnMax:bMMoved   = { || oBtnMax:SetColor( CLR_BLACK, If( oBtnMax:lMOver, CLR_MSGRAY, oWnd:nClrPane ) ) }
   oBtnMin:bMMoved   = { || oBtnMin:SetColor( CLR_BLACK, If( oBtnMin:lMOver, CLR_MSGRAY, oWnd:nClrPane ) ) }

   oWnd:bResized = { || oBtnClose:Move( 1, oWnd:nWidth - 46 ), oBtnMax:Move( 1, oWnd:nWidth - 92 ),;
                        oBtnMin:Move( 1, oWnd:nWidth - 138 ) } 

   ACTIVATE WINDOW oWnd CENTER

return nil


regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: User defined Windows captions
Posted: Tue May 07, 2019 08:07 AM

Dear Antonio,
thank you so much.
Would you be so kind to post the bmps too.
Best regards
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: User defined Windows captions
Posted: Tue May 07, 2019 08:24 AM
Dear Otto,

These are the bitmaps.

I have asked Uwe help to implement the alpha channel on them.
I don't know how to use PixelFormer to do it (Uwe recommended tool to add alpha channel)

https://github.com/FiveTechSoft/screenshots/raw/master/closew.bmp
https://github.com/FiveTechSoft/screenshots/raw/master/closeb.bmp
https://github.com/FiveTechSoft/screenshots/raw/master/max.bmp
https://github.com/FiveTechSoft/screenshots/raw/master/min.bmp

Next FWH version will include them, and probably they will be supported using FWBitmap( ... ) ( no need to add them to the app resources )

Finally when it is ready, we will turn it into a Class for easy of use :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: User defined Windows captions
Posted: Tue May 07, 2019 08:53 AM
Moving the window around:

captions.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"

#define CLR_MSPURPLE RGB( 128,  57, 123 )
#define CLR_MSRED    RGB( 232,  17,  35 )
#define CLR_MSGRAY   RGB( 229, 229, 229 )

#define TME_LEAVE    2

function Main()

   local oWnd, nRowPos, nColPos, oBtnClose, oBtnMax, oBtnMin, lDrag := .F.

   DEFINE WINDOW oWnd STYLE WS_POPUP COLOR CLR_BLACK, CLR_MSPURPLE

   oWnd:SetSize( 500, 300 )
   oWnd:Center()
   oWnd:Shadow()

   oWnd:bLClicked = { | nRow, nCol | If( nRow < 25, ( oWnd:Capture(), nRowPos := nRow, nColPos := nCol, lDrag := .T. ),) }
      
   oWnd:bMMoved = { | nRow, nCol | TrackMouseEvent( oWnd:hWnd, TME_LEAVE ),;
                                   If( lDrag .and. ! IsZoomed( oWnd:hWnd ) .and. IsOverWnd( oWnd:hWnd, nRow, nCol ),;
                                       oWnd:Move( oWnd:nTop + nRow - nRowPos, oWnd:nLeft + nCol - nColPos,,, .T. ),) }   

   oWnd:bLButtonUp = { || ReleaseCapture(), lDrag := .F. }
   oWnd:bMLeave    = { || lDrag := .F. } 

   @ 1, oWnd:nWidth - 46 BTNBMP oBtnClose BITMAP "../bitmaps/16x16/closew.bmp" ;
      FLAT NOBORDER NOROUND ACTION oWnd:End() SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   @ 1, oWnd:nWidth - 92 BTNBMP oBtnMax BITMAP "../bitmaps/16x16/max.bmp" ;
      FLAT NOBORDER NOROUND ACTION If( ! IsZoomed( oWnd:hWnd ), oWnd:Maximize(), oWnd:Restore() ) SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   @ 1, oWnd:nWidth - 138 BTNBMP oBtnMin BITMAP "../bitmaps/16x16/min.bmp" ;
      FLAT NOBORDER NOROUND ACTION If( ! IsIconic( oWnd:hWnd ), oWnd:Iconize(), oWnd:Restore() ) SIZE 45, 29 ;
      COLOR CLR_BLACK, CLR_MSPURPLE 

   oBtnClose:bMMoved = { || oBtnClose:SetColor( CLR_BLACK, If( oBtnClose:lMOver, CLR_MSRED, oWnd:nClrPane ) ) }
   oBtnMax:bMMoved   = { || oBtnMax:SetColor( CLR_BLACK, If( oBtnMax:lMOver, CLR_MSGRAY, oWnd:nClrPane ) ) }
   oBtnMin:bMMoved   = { || oBtnMin:SetColor( CLR_BLACK, If( oBtnMin:lMOver, CLR_MSGRAY, oWnd:nClrPane ) ) }

   oWnd:bResized = { || oBtnClose:Move( 1, oWnd:nWidth - 46 ), oBtnMax:Move( 1, oWnd:nWidth - 92 ),;
                        oBtnMin:Move( 1, oWnd:nWidth - 138 ) } 

   ACTIVATE WINDOW oWnd

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: User defined Windows captions
Posted: Tue May 07, 2019 10:43 AM
Now we can have great looking RibbonBars :-)

viewtopic.php?p=221663#p221663

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: User defined Windows captions
Posted: Tue May 07, 2019 04:43 PM

Antonio,

This is looking great! It really enhances the ribbonbar look.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: User defined Windows captions
Posted: Fri May 10, 2019 05:34 PM

Antonio,

I tried a few things, and did some Internet searching, but I cannot figure out how to add a title to the colored title bar.

It seems that the window style WS_POPUP will not allow titles.

Any ideas?

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 244
Joined: Fri Oct 28, 2005 06:29 PM
Re: User defined Windows captions
Posted: Fri May 10, 2019 05:51 PM
James Bott wrote:Antonio,

I tried a few things, and did some Internet searching, but I cannot figure out how to add a title to the colored title bar.

It seems that the window style WS_POPUP will not allow titles.

Any ideas?


James

DEFINE WINDOW oWnd STYLE nOR( WS_POPUP, WS_CAPTION ) COLOR CLR_BLACK, CLR_MSPURPLE TITLE "Wnd title"
Alejandro Cebolido

Buenos Aires, Argentina
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: User defined Windows captions
Posted: Fri May 10, 2019 05:56 PM

There is no caption. It is a simulated caption, so we have to paint the caption text ourselves

I spent several days trying to find another choice (WM_NCPAINT) to avoid removing the caption but there is no way, unless the proposed solution here

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: User defined Windows captions
Posted: Fri May 10, 2019 06:06 PM
Antonio,

so we have to paint the caption text ourselves


Any idea how we can do that?

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: User defined Windows captions
Posted: Fri May 10, 2019 06:08 PM
Alejandro,

DEFINE WINDOW oWnd STYLE nOR( WS_POPUP, WS_CAPTION ) COLOR CLR_BLACK, CLR_MSPURPLE TITLE "Wnd title"


Thanks, that shows the title, but on a white title bar not the colored one we are looking for. And you have to use Alt-F4 to exit as there is no exit button.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: User defined Windows captions
Posted: Fri May 10, 2019 06:56 PM
James, try with this

Code (fw): Select all Collapse
   oCtrl := TTitle():New( oWnd, 2, 40 - 2, 200, 40 - 2, , , .F., , , , , , , , 0 )
   oCtrl:aGrdBack := { { 1, oRb:nClrPaneRB, oRb:nClrPaneRB } }
   oCtrl:AddText( 2, 40, "Title Test", , , , , oFnt    , CLR_WHITE, )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: User defined Windows captions
Posted: Fri May 10, 2019 07:23 PM
James,

oWnd:bPainted = { || oWnd:Say( 8, 30, "Caption", CLR_WHITE, CLR_MSPURPLE, oWnd:oFont, .T., .T. ) }

regards, saludos

Antonio Linares
www.fivetechsoft.com