#include <windows.h>
#include <stdio.h>
#define ID_TEXT_TITLE 1001
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,
int iCmdShow)
{
static TCHAR szAppName[] = "TestApp";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
int iWidth, iHeigth;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); //(HBRUSH)
GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
iWidth = GetSystemMetrics(SM_CXSCREEN);
iHeigth = GetSystemMetrics(SM_CYSCREEN);
if (!RegisterClass (&wndclass)) {
MessageBox (NULL, "This program requires Windows!", szAppName,
MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, // window class name
"Test Application", // window caption
WS_OVERLAPPEDWINDOW, // window style
iWidth - iWidth/2 - 598/2, // initial x position
iHeigth - iHeigth/2 - 104, // initial y position
598, // initial x size
104, // initial y size
NULL, // parent window
handle
NULL, // window menu handle
hInstance, // program instance
handle
NULL) ; // creation parameters
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
static HWND st_title;
int iControlId;
static HBRUSH hBrushStatic ;
switch (message){
case WM_CREATE : st_title = CreateWindow ("static", "This line has
white background Get rid of it!",
WS_CHILDWINDOW | WS_VISIBLE | SS_CENTER,
23, 16, 598 - 46, 16,
hwnd, (HMENU) ID_TEXT_TITLE,
(HINSTANCE) GetWindowLong (hwnd,
GWL_HINSTANCE),
NULL) ;
hBrushStatic = CreateSolidBrush
(GetSysColor(COLOR_BTNHIGHLIGHT)) ;
return 0 ;
case WM_PAINT : //hdc = BeginPaint (hwnd, &ps) ;
//GetClientRect (hwnd, &rect) ;
//DrawText (hdc, "Hello, Windows 98!", -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
//EndPaint (hwnd, &ps) ;
return 0 ;
case WM_CTLCOLOREDIT :
case WM_CTLCOLORBTN :
case WM_CTLCOLORDLG :
case WM_CTLCOLORSTATIC : iControlId = GetWindowLong ((HWND) lParam,
GWL_ID) ;
switch(iControlId){
case ID_TEXT_TITLE: SetTextColor ((HDC)
wParam, RGB(0,0,0)) ;
SetBkColor ((HDC)
wParam, RGB(125,125,125));
return (LRESULT)
hBrushStatic ;
break;
}
break ;
case WM_DESTROY: DeleteObject (hBrushStatic) ;
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}