Page 1 of 2

User defined Windows captions

Posted: Tue May 07, 2019 6:53 am
by Antonio Linares
Time to have the WinRT look on our captions

captions.prg

Code: Select all

#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
Image

Re: User defined Windows captions

Posted: Tue May 07, 2019 7:39 am
by Antonio Linares
Max and Close buttons

captions.prg

Code: Select all

#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
Image

Re: User defined Windows captions

Posted: Tue May 07, 2019 8:01 am
by Antonio Linares
Min, Max and Close:

captions.prg

Code: Select all

#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
Image

Re: User defined Windows captions

Posted: Tue May 07, 2019 8:07 am
by Otto
Dear Antonio,
thank you so much.
Would you be so kind to post the bmps too.
Best regards
Otto

Re: User defined Windows captions

Posted: Tue May 07, 2019 8:24 am
by Antonio Linares
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/screens ... closew.bmp
https://github.com/FiveTechSoft/screens ... closeb.bmp
https://github.com/FiveTechSoft/screens ... er/max.bmp
https://github.com/FiveTechSoft/screens ... er/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 :-)

Re: User defined Windows captions

Posted: Tue May 07, 2019 8:53 am
by Antonio Linares
Moving the window around:

captions.prg

Code: Select all

#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

Re: User defined Windows captions

Posted: Tue May 07, 2019 10:43 am
by Antonio Linares
Now we can have great looking RibbonBars :-)

http://forums.fivetechsupport.com/viewt ... 63#p221663

Image

Re: User defined Windows captions

Posted: Tue May 07, 2019 4:43 pm
by James Bott
Antonio,

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

Re: User defined Windows captions

Posted: Fri May 10, 2019 5:34 pm
by James Bott
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?

Re: User defined Windows captions

Posted: Fri May 10, 2019 5:51 pm
by TecniSoftware
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"

Re: User defined Windows captions

Posted: Fri May 10, 2019 5:56 pm
by Antonio Linares
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

Re: User defined Windows captions

Posted: Fri May 10, 2019 6:06 pm
by James Bott
Antonio,
so we have to paint the caption text ourselves
Any idea how we can do that?

James

Re: User defined Windows captions

Posted: Fri May 10, 2019 6:08 pm
by James Bott
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

Re: User defined Windows captions

Posted: Fri May 10, 2019 6:56 pm
by cnavarro
James, try with this

Code: Select all

   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, )
 

Re: User defined Windows captions

Posted: Fri May 10, 2019 7:23 pm
by Antonio Linares
James,

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

Image