User defined Windows captions

User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

User defined Windows captions

Post by Antonio Linares »

Time to have the WinRT look on our captions

captions.prg

Code: Select all | Expand

#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: User defined Windows captions

Post by Antonio Linares »

Max and Close buttons

captions.prg

Code: Select all | Expand

#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: User defined Windows captions

Post by Antonio Linares »

Min, Max and Close:

captions.prg

Code: Select all | Expand

#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 6403
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 22 times
Been thanked: 2 times
Contact:

Re: User defined Windows captions

Post by Otto »

Dear Antonio,
thank you so much.
Would you be so kind to post the bmps too.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: User defined Windows captions

Post 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/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
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: User defined Windows captions

Post by Antonio Linares »

Moving the window around:

captions.prg

Code: Select all | Expand

#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
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: User defined Windows captions

Post by Antonio Linares »

Now we can have great looking RibbonBars :-)

viewtopic.php?p=221663#p221663

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: User defined Windows captions

Post by James Bott »

Antonio,

This is looking great! It really enhances the ribbonbar look.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: User defined Windows captions

Post 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?
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
TecniSoftware
Posts: 236
Joined: Fri Oct 28, 2005 6:29 pm
Location: Quilmes, Buenos Aires, Argentina

Re: User defined Windows captions

Post 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"
Alejandro Cebolido
Buenos Aires, Argentina
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: User defined Windows captions

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: User defined Windows captions

Post by James Bott »

Antonio,

so we have to paint the caption text ourselves


Any idea how we can do that?

James
Last edited by James Bott on Fri May 10, 2019 6:09 pm, edited 1 time in total.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: User defined Windows captions

Post 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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: User defined Windows captions

Post by cnavarro »

James, try with this

Code: Select all | Expand


   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
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: User defined Windows captions

Post by Antonio Linares »

James,

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

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply