Vitucho
May 26th, 2006, 06:36 PM
Okey, listen up : this is a simple fact....
what function i should use to change window's default components fonts.(buttons, label's or static's, ect ect..)
There is no SetWindowFont =( grgrgr...
By the way, what's is the function to change the background style...
Okey, okey...there where 2 jeje, sorry.
Thanks anyway = D.
Vitucho.
JamesSchumacher
May 26th, 2006, 07:47 PM
Okey, listen up : this is a simple fact....
what function i should use to change window's default components fonts.(buttons, label's or static's, ect ect..)
There is no SetWindowFont =( grgrgr...
By the way, what's is the function to change the background style...
Okey, okey...there where 2 jeje, sorry.
Thanks anyway = D.
Vitucho.
You are right - there is no function... But.....
HFONT hFont = ::CreateFontW(12,0,0,400,FALSE,FALSE,FALSE,ANSI_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE,L"MS Sans Serif");
::SendMessage(HWND_OF_WINDOW,WM_SETFONT,(WPARAM)hFont,TRUE); // LPARAM set to TRUE redraws window
So you could write one.
void SetWindowFont(HWND hWnd,HFONT hFont)
{
::SendMessage(hWnd,WM_SETFONT,(WPARAM)hFont,TRUE);
}
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_setfont.asp
As for background style - I am assuming opaque or transparent correct?
In that case you are speaking of how the window is drawn. You will need to process WM_PAINT in your window process.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_88ac.asp
The function you need to look for setting background mode in a painting situation is:
int SetBkMode(HDC hDC,int nBkMode);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_47hh.asp
Simple WM_PAINT processing example:
INT_PTR __stdcall WindowProcess(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
if (message == WM_PAINT)
{
PAINTSTRUCT ps;
HDC hDC = ::BeginPaint(hWnd,&ps);
if (ps.fErase != 0)
{
// background needs painting
HBRUSH hBackground = ::CreateSolidBrush(RGB(0,0,0));
::FillRect(hDC,&ps.rcPaint,hBackground);
::DeleteObject(hBackground);
}
HFONT hTextFont = ::CreateFontW(12,0,0,400,FALSE,FALSE,FALSE,ANSI_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_DONTCARE,
L"MS Sans Serif");
HFONT hOldFont = (HFONT)::SelectObject(hDC,hTextFont);
const int nOldBkMode = ::SetBkMode(hDC,TRANSPARENT);
// Draw some red text with transparent background
const COLORREF clrOldText = ::SetTextColor(hDC,RGB(255,0,0));
::ExtTextOutW(hDC,0,0,ETO_CLIPPED,NULL,L"Red Text",8,NULL);
// Draw some blue text with white background
const COLORREF clrOldBack = ::SetBkColor(hDC,RGB(255,255,255));
::SetTextColor(hDC,RGB(0,0,255));
::SetBkMode(hDC,OPAQUE);
::ExtTextOutW(hDC,0,20,ETO_CLIPPED,NULL,L"White Background",16,NULL);
// Cleanup time
::SetBkMode(hDC,nOldBkMode);
::SetBkColor(hDC,clrOldBack);
::SetTextColor(hDC,clrOldText);
::SelectObject(hDC,hOldFont);
::DeleteObject(hTextFont);
::EndPaint(hWnd,&ps);
return 0;
}
// rest omitted for simplicity
}