-
change background color
I'm trying to change the background color of a static control (text). I know that this can be normally done by the message WM_CTLCOLORSTATIC, however, the control i'm talking about is the child of another static control (because i'm using tabs), so there is no way i can check WM_CTLCOLORSTATIC. How can i achieve this?
Thanks in advance...
-
That's how you get boxed in when using tabs...
Rather than doing "child of child" you should probably investigate making borderless child dialogs that fit in your tab control's client area. Show/hide the entire dialog according to the selected tab... This gives you separate message procedures for each dialog (hense, each tab) where you can do a lot more customization than by the more conventional methods.
Code:
//////////////////////////////////////////////////////////////////////////////
// Tab message handlers
//
BOOL CALLBACK TabTosser(HWND Dlg,UINT Msg,WPARAM wParm,LPARAM lParm)
{ switch(Msg)
{ case WM_INITDIALOG :
EnableThemeDialogTexture(Dlg,ETDT_USETABTEXTURE);
return TRUE;
case WM_COMMAND :
switch (LOWORD(wParm))
{ case 4002 :
GetFolderName(Dlg,4001);
return FALSE;
case 4003 :
RemoveFolderNames(Dlg,4001);
return FALSE;
case 4004 :
ClearFolderNames(Dlg,4001);
return FALSE;
case 4006 :
GetFolderName(Dlg,4005);
return FALSE;
case 4007 :
RemoveFolderNames(Dlg,4005);
return FALSE;
case 4008 :
ClearFolderNames(Dlg,4005);
return FALSE;
case 4103 :
GetFolderName(Dlg,4102);
return FALSE;
case 4104 :
RemoveFolderNames(Dlg,4102);
return FALSE;
case 4105 :
ClearFolderNames(Dlg,4102);
return FALSE;
case 4202 :
GetFolderName(Dlg,4201);
return FALSE;
case 4203 :
RemoveFolderNames(Dlg,4201);
return FALSE;
case 4204 :
ClearFolderNames(Dlg,4201);
return FALSE;
case 4206 :
GetFolderName(Dlg,4205);
return FALSE;
case 4207 :
RemoveFolderNames(Dlg,4205);
return FALSE;
case 4208 :
ClearFolderNames(Dlg,4205);
return FALSE;
case 4302 :
GetFileName(Dlg,4301,_T("Help File (*.chm)\0*.chm\0\0"));
return FALSE;
default :
return FALSE; }
default :
return FALSE; } }
//////////////////////////////////////////////////////////////////////////////
// Main Dialog functions
//
// switch tab out
VOID HideTab(HWND Ctrl )
{ ShowWindow(hPage[TabCtrl_GetCurSel(Ctrl)],SW_HIDE); }
// switch tab in
VOID ShowTab(HWND Ctrl )
{ ShowWindow(hPage[TabCtrl_GetCurSel(Ctrl)],SW_SHOW); }
// initialize tabs and sub-dialogs
BOOL InitSetup(HWND Dlg)
{ TCITEM tci; //tab struct
TCHAR tab[16]; // tab text
hTabCtrl = GetDlgItem(Dlg,4901); // page global handle
// add tabs to main dialog
tci.mask = TCIF_TEXT;
tci.cchTextMax = 16;
tci.pszText = tab;
lstrcpy(tab, _T("Executables"));
TabCtrl_InsertItem(GetDlgItem(Dlg,4901),0,&tci);
lstrcpy(tab, _T("Compiler"));
TabCtrl_InsertItem(GetDlgItem(Dlg,4901),1,&tci);
lstrcpy(tab, _T("Linker"));
TabCtrl_InsertItem(GetDlgItem(Dlg,4901),2,&tci);
lstrcpy(tab, _T("Help"));
TabCtrl_InsertItem(GetDlgItem(Dlg,4901),3,&tci);
TabCtrl_SetCurSel(Dlg,0);
// create tab dialogs
hPage[0] = CreateDialog(hInst,_T("SETUP0"),Dlg,(DLGPROC)&TabTosser);
hPage[1] = CreateDialog(hInst,_T("SETUP1"),Dlg,(DLGPROC)&TabTosser);
hPage[2] = CreateDialog(hInst,_T("SETUP2"),Dlg,(DLGPROC)&TabTosser);
hPage[3] = CreateDialog(hInst,_T("SETUP3"),Dlg,(DLGPROC)&TabTosser);
// get settings from registry
LoadSettings();
return TRUE; }
// tosser for the main setup dialog
BOOL CALLBACK SetupTosser(HWND Dlg,UINT Msg,WPARAM wParm,LPARAM lParm)
{ switch(Msg)
{ case WM_INITDIALOG :
InitSetup(Dlg);
return TRUE;
case WM_COMMAND :
switch(LOWORD(wParm))
{ case IDOK : // save button
SaveSettings();
EndDialog(Dlg,1);
return FALSE;
case IDCANCEL : // cancel button
EndDialog(Dlg,0);
return FALSE;
default :
return FALSE; }
case WM_NOTIFY : // from tab control
switch(wParm)
{ case 4901 :
switch ( ((LPNMHDR) lParm)->code)
{ case TCN_SELCHANGING : // hide old dialog
HideTab(((LPNMHDR) lParm)->hwndFrom);
return FALSE;
case TCN_SELCHANGE : // show new dialog
ShowTab(((LPNMHDR) lParm)->hwndFrom);
return FALSE;
default :
return FALSE; }
default :
return FALSE; }
default :
return FALSE; } }
void ShowGlobalSetup(HWND Parent)
{ DialogBox(hInst,_T("SETUP"),Parent,(DLGPROC) &SetupTosser); }