1 // Static Control Test.c
3 //#define WIN32_LEAN_AND_MEAN
8 #define SS_ENDELLIPSIS 0x00004000L
9 #endif /* SS_ENDELLIPSIS */
13 #define nStaticWidth 384
14 #define nStaticHeight 18
17 HINSTANCE g_hInst = 0;
19 HWND g_hwndCtrl[nMaxCtrls];
21 static void CreateStatic ( const char* lpWindowName, DWORD dwStyle )
24 assert ( n < nMaxCtrls );
25 g_hwndCtrl[n] = CreateWindow (
26 "STATIC", // lpClassName
27 lpWindowName, // lpWindowName
28 WS_VISIBLE|WS_CHILD|dwStyle, // dwStyle
30 nStaticHeight*n+1, // y
31 nStaticWidth, // nWidth
32 nStaticHeight-1, // nHeight
39 LRESULT CALLBACK WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
46 for ( i = 0; i < nMaxCtrls; i++ )
49 CreateStatic ( "SS_NOTIFY test (click/double-click here)", SS_NOTIFY );
51 CreateStatic ( "SS_ENDELLIPSIS test test test test test test test test test test test", SS_ENDELLIPSIS );
53 CreateStatic ( "SS_CENTER test", SS_CENTER );
55 CreateStatic ( "SS_RIGHT test", SS_RIGHT );
57 CreateStatic ( "SS_BLACKFRAME test:", 0 );
58 CreateStatic ( "this text shouldn't be visible!", SS_BLACKFRAME );
60 CreateStatic ( "SS_BLACKRECT test:", 0 );
61 CreateStatic ( "this text shouldn't be visible!", SS_BLACKRECT );
63 CreateStatic ( "SS_ETCHEDFRAME test:", 0 );
64 CreateStatic ( "this text shouldn't be visible!", SS_ETCHEDFRAME );
66 CreateStatic ( "SS_ETCHEDHORZ test:", 0 );
67 CreateStatic ( "this text shouldn't be visible!", SS_ETCHEDHORZ );
69 CreateStatic ( "SS_ETCHEDVERT test", 0 );
70 CreateStatic ( "this text shouldn't be visible!", SS_ETCHEDVERT );
72 CreateStatic ( "SS_GRAYFRAME test", 0 );
73 CreateStatic ( "this text shouldn't be visible!", SS_GRAYFRAME );
75 CreateStatic ( "SS_GRAYRECT test", 0 );
76 CreateStatic ( "this text shouldn't be visible!", SS_GRAYRECT );
78 CreateStatic ( "SS_NOPREFIX &test", SS_NOPREFIX );
80 CreateStatic ( "SS_OWNERDRAW test", SS_OWNERDRAW );
82 CreateStatic ( "SS_SUNKEN test", SS_SUNKEN );
84 CreateStatic ( "SS_WHITEFRAME test:", 0 );
85 CreateStatic ( "this text shouldn't be visible!", SS_WHITEFRAME );
87 CreateStatic ( "SS_WHITERECT test:", 0 );
88 CreateStatic ( "this text shouldn't be visible!", SS_WHITERECT );
90 //if ( creation fails )
95 if ( HIWORD(wParam) == STN_CLICKED )
96 SetWindowText ( (HWND)lParam, "SS_NOTIFY:STN_CLICKED!" );
97 if ( HIWORD(wParam) == STN_DBLCLK )
98 SetWindowText ( (HWND)lParam, "SS_NOTIFY:STN_DBLCLK!" );
103 LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
104 DrawText ( lpDrawItem->hDC, "SS_DRAWITEM test successful!", 28, &(lpDrawItem->rcItem), 0 );
112 return DefWindowProc ( hwnd, msg, wParam, lParam );
115 HWND RegisterAndCreateWindow (
117 const char* className,
125 wc.cbSize = sizeof (WNDCLASSEX);
126 wc.lpfnWndProc = WndProc; // window procedure: mandatory
127 wc.hInstance = hInst; // owner of the class: mandatory
128 wc.lpszClassName = className; // mandatory
129 wc.hCursor = LoadCursor ( 0, IDC_ARROW ); // optional
130 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // optional
137 if ( !RegisterClassEx ( &wc ) )
140 hwnd = CreateWindowEx (
142 className, // class name
143 title, // window title
144 WS_OVERLAPPEDWINDOW, // dwStyle
147 CW_USEDEFAULT, // width
148 CW_USEDEFAULT, // height
157 ShowWindow ( hwnd, SW_SHOW );
158 UpdateWindow ( hwnd );
163 int WINAPI WinMain ( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow )
165 char className [] = "Static Control Test";
170 hwnd = RegisterAndCreateWindow ( hInst, className, "Static Control Test" );
173 while ((status = GetMessage (& msg, 0, 0, 0)) != 0)
177 DispatchMessage ( &msg );