FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour change the title bar of a windows application
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
change the title bar of a windows application
Posted: Thu Dec 10, 2009 09:33 PM

Does someone know how to change the title bar of a windows application using the SetSysColors of Lib "user32". I'm using XP.
Thanks in advance
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: change the title bar of a windows application
Posted: Thu Dec 10, 2009 10:27 PM
Otto,

Have you tested it with the colors defines used in GetSysColor() ?

http://msdn.microsoft.com/en-us/library/ms724371(VS.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: change the title bar of a windows application
Posted: Fri Dec 11, 2009 07:19 AM
Hello Antonio,
this is what I tried. But I get an error.

Thanks in advance and best regards,
Otto

Code (fw): Select all Collapse
#INCLUDE "FiveWin.ch"
#define COLOR_ACTIVECAPTION     2


STATIC odlg
//-------------------------------------------------------------//

FUNCTION Main()

   // local oDlg

   DEFINE DIALOG oDlg FROM 6, 6 TO 20, 60 TITLE "Hide and Show Taskbar"

   @ 2, 2 BUTTON "&Hide" OF oDlg ;
      ACTION task_bar_on(.f.)

   @ 4, 2 BUTTON "&Show" OF oDlg ;
     ACTION task_bar_on(.t.)

 @ 4, 12 BUTTON "&Show" OF oDlg ;
     ACTION msginfo(GetSysColor(COLOR_ACTIVECAPTION))    //returns ---> 13743257



   ACTIVATE DIALOG oDlg ;
      VALID MsgYesNo( "Want to end ?" )

return(NIL)



function task_bar_on(ison)

local hwnd 


    hwnd= FindWndByClass("Shell_TrayWnd", "")
 
     SetSysColors(1,COLOR_ACTIVECAPTION, 13743257 )
    //SetSysColors(1,COLOR_ACTIVECAPTION, nRGB( 219, 230, 244 ) )
    
    If ison 
        ShowWindow(hwnd,5)
    Else
        ShowWindow(hwnd,0)
    End If

return(NIL)



DLL32 Function ShowWindow(hwnd as LONG, nCmdShow as LONG) AS LONG ;
PASCAL FROM "ShowWindow" Lib "user32.dll"
    
DLL32 Function FindWndByClass(wndClass AS LPSTR,WndName as LPSTR) AS LONG ;
PASCAL FROM "FindWindowA" LIB "user32.dll" 



DLL32 Function SetSysColors ( nChanges As LONG, lpSysColor As LONG, lpColorValues As LONG) As Long;
 PASCAL FROM "SetSysColors"    Lib "user32"
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: change the title bar of a windows application
Posted: Fri Dec 11, 2009 11:09 AM
Otto,

If you write in uppercase LONG here then the runtime error is solved:
Code (fw): Select all Collapse
DLL32 Function SetSysColors ( nChanges As LONG, lpSysColor As LONG, lpColorValues As LONG) As LONG ;
 PASCAL FROM "SetSysColors"    Lib "user32"

I am testing it in W7 and it properly hides the taskbar, but I don't see any color change
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: change the title bar of a windows application
Posted: Fri Dec 11, 2009 11:42 AM

Hello Antonio,
thank you.
I read somewhere that if XP Themes is on the caption is a bitmap?
I don't know it I understood this well nor what to do.

Best regards,
Otto

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: change the title bar of a windows application
Posted: Sat Dec 12, 2009 01:36 AM
Hello Antonio,
I am testing it in W7 and it properly hides the taskbar, but I don't see any color change

Do you have another suggestion how to change the color of the caption?

Best regards,
Otto
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: change the title bar of a windows application
Posted: Sat Dec 12, 2009 03:30 AM
For me this program is working on XP, but only when Themes are disabled.

This program sets color of the Active Windows caption ( Yellow, Red ).

Code (fw): Select all Collapse
#include 'fivewin.ch'

function Main()

   msginfo( 'start' )
   clrtest( CLR_YELLOW, CLR_HRED )
   msginfo( 'done' )

return nil

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HB_FUNC( CLRTEST )
{
   int aElements[2] = { COLOR_CAPTIONTEXT, COLOR_ACTIVECAPTION };
   DWORD aColors[2];

   aColors[ 0 ] = hb_parnl( 1 );
   aColors[ 1 ] = hb_parnl( 2 );
   SetSysColors( 2, aElements, aColors );

}

//----------------------------------------------------------------------------//

#pragma ENDDUMP


For further reading:
http://msdn.microsoft.com/en-us/library/ms724940(VS.85).aspx
and
http://msdn.microsoft.com/en-us/library/ms724371(VS.85).aspx
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: change the title bar of a windows application
Posted: Sat Dec 12, 2009 04:01 AM

Hello Mr. Rao,

your source is working. But this seems not to be a solution. The COLOR_CAPTIONTEXT of all applications is changed.
COLOR_ACTIVECAPTION on my VISTA PC works only with classic view.

Thank you for your help and best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: change the title bar of a windows application
Posted: Sat Dec 12, 2009 04:21 AM

SetSysColors() API function changes settings for the entire system.
If you intend to change only for one application, then SetSysColors() is not the way.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion