ReactOS  0.4.15-dev-1201-gb2cf5a4
statst2.c
Go to the documentation of this file.
1 // Static Control Test.c
2 
3 //#define WIN32_LEAN_AND_MEAN
4 #include <windows.h>
5 #include <assert.h>
6 
7 #ifndef SS_ENDELLIPSIS
8 #define SS_ENDELLIPSIS 0x00004000L
9 #endif /* SS_ENDELLIPSIS */
10 
11 
12 #define nMaxCtrls 32
13 #define nStaticWidth 384
14 #define nStaticHeight 18
15 
18 int nNextCtrl = 0;
20 
21 static void CreateStatic ( const char* lpWindowName, DWORD dwStyle )
22 {
23  int n = nNextCtrl++;
24  assert ( n < nMaxCtrls );
26  "STATIC", // lpClassName
27  lpWindowName, // lpWindowName
28  WS_VISIBLE|WS_CHILD|dwStyle, // dwStyle
29  n+2, // x
30  nStaticHeight*n+1, // y
31  nStaticWidth, // nWidth
32  nStaticHeight-1, // nHeight
33  g_hwnd, // hWndParent
34  NULL, // hMenu
35  g_hInst, // hInstance
36  NULL ); // lParam
37 }
38 
40 {
41  int i;
42  switch ( msg )
43  {
44  case WM_CREATE:
45  g_hwnd = hwnd;
46  for ( i = 0; i < nMaxCtrls; i++ )
47  g_hwndCtrl[i] = NULL;
48 
49  CreateStatic ( "SS_NOTIFY test (click/double-click here)", SS_NOTIFY );
50 
51  CreateStatic ( "SS_ENDELLIPSIS test test test test test test test test test test test", SS_ENDELLIPSIS );
52 
53  CreateStatic ( "SS_CENTER test", SS_CENTER );
54 
55  CreateStatic ( "SS_RIGHT test", SS_RIGHT );
56 
57  CreateStatic ( "SS_BLACKFRAME test:", 0 );
58  CreateStatic ( "this text shouldn't be visible!", SS_BLACKFRAME );
59 
60  CreateStatic ( "SS_BLACKRECT test:", 0 );
61  CreateStatic ( "this text shouldn't be visible!", SS_BLACKRECT );
62 
63  CreateStatic ( "SS_ETCHEDFRAME test:", 0 );
64  CreateStatic ( "this text shouldn't be visible!", SS_ETCHEDFRAME );
65 
66  CreateStatic ( "SS_ETCHEDHORZ test:", 0 );
67  CreateStatic ( "this text shouldn't be visible!", SS_ETCHEDHORZ );
68 
69  CreateStatic ( "SS_ETCHEDVERT test", 0 );
70  CreateStatic ( "this text shouldn't be visible!", SS_ETCHEDVERT );
71 
72  CreateStatic ( "SS_GRAYFRAME test", 0 );
73  CreateStatic ( "this text shouldn't be visible!", SS_GRAYFRAME );
74 
75  CreateStatic ( "SS_GRAYRECT test", 0 );
76  CreateStatic ( "this text shouldn't be visible!", SS_GRAYRECT );
77 
78  CreateStatic ( "SS_NOPREFIX &test", SS_NOPREFIX );
79 
80  CreateStatic ( "SS_OWNERDRAW test", SS_OWNERDRAW );
81 
82  CreateStatic ( "SS_SUNKEN test", SS_SUNKEN );
83 
84  CreateStatic ( "SS_WHITEFRAME test:", 0 );
85  CreateStatic ( "this text shouldn't be visible!", SS_WHITEFRAME );
86 
87  CreateStatic ( "SS_WHITERECT test:", 0 );
88  CreateStatic ( "this text shouldn't be visible!", SS_WHITERECT );
89 
90  //if ( creation fails )
91  // return 0;
92  break;
93 
94  case WM_COMMAND:
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!" );
99  break;
100 
101  case WM_DRAWITEM:
102  {
104  DrawText ( lpDrawItem->hDC, "SS_DRAWITEM test successful!", 28, &(lpDrawItem->rcItem), 0 );
105  }
106  break;
107 
108  case WM_DESTROY:
109  PostQuitMessage(0);
110  return 0;
111  }
112  return DefWindowProc ( hwnd, msg, wParam, lParam );
113 }
114 
117  const char* className,
118  const char* title )
119 {
120  WNDCLASSEX wc;
121  HWND hwnd;
122 
123  g_hInst = hInst;
124 
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, (LPCTSTR)IDC_ARROW ); // optional
130  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // optional
131  wc.style = 0;
132  wc.cbClsExtra = 0;
133  wc.cbWndExtra = 0;
134  wc.hIcon = 0;
135  wc.hIconSm = 0;
136  wc.lpszMenuName = 0;
137  if ( !RegisterClassEx ( &wc ) )
138  return NULL;
139 
140  hwnd = CreateWindowEx (
141  0, // dwStyleEx
142  className, // class name
143  title, // window title
144  WS_OVERLAPPEDWINDOW, // dwStyle
145  CW_USEDEFAULT, // x
146  CW_USEDEFAULT, // y
147  CW_USEDEFAULT, // width
148  CW_USEDEFAULT, // height
149  NULL, // hwndParent
150  NULL, // hMenu
151  hInst, // hInstance
152  0 ); // lParam
153 
154  if ( !hwnd )
155  return NULL;
156 
157  ShowWindow ( hwnd, SW_SHOW );
158  UpdateWindow ( hwnd );
159 
160  return hwnd;
161 }
162 
163 int WINAPI WinMain ( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow )
164 {
165  char className [] = "Static Control Test";
166  HWND hwnd;
167  MSG msg;
168  int status;
169 
170  hwnd = RegisterAndCreateWindow ( hInst, className, "Static Control Test" );
171 
172  // Message loop
173  while ((status = GetMessage (& msg, 0, 0, 0)) != 0)
174  {
175  if (status == -1)
176  return -1;
177  DispatchMessage ( &msg );
178  }
179  return msg.wParam;
180 }
#define nStaticWidth
Definition: statst2.c:13
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT style
Definition: winuser.h:3177
#define DispatchMessage
Definition: winuser.h:5740
LPCSTR lpszMenuName
Definition: winuser.h:3185
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define RegisterClassEx
Definition: winuser.h:5812
HCURSOR hCursor
Definition: winuser.h:3183
WNDPROC lpfnWndProc
Definition: winuser.h:3178
#define CreateWindow
Definition: winuser.h:5729
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
LPCSTR lpszClassName
Definition: winuser.h:3186
#define SS_BLACKRECT
Definition: pedump.c:696
#define SS_OWNERDRAW
Definition: winuser.h:352
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define CALLBACK
Definition: compat.h:35
#define SS_ETCHEDFRAME
Definition: winuser.h:342
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SS_ENDELLIPSIS
Definition: statst2.c:8
GLdouble n
Definition: glext.h:7729
HWND RegisterAndCreateWindow(HINSTANCE hInst, const char *className, const char *title)
Definition: statst2.c:115
#define assert(x)
Definition: debug.h:53
UINT_PTR WPARAM
Definition: windef.h:207
#define WS_CHILD
Definition: pedump.c:617
#define nStaticHeight
Definition: statst2.c:14
HICON hIconSm
Definition: winuser.h:3187
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
char * LPSTR
Definition: xmlstorage.h:182
#define COLOR_WINDOW
Definition: winuser.h:908
static void CreateStatic(const char *lpWindowName, DWORD dwStyle)
Definition: statst2.c:21
WPARAM wParam
Definition: combotst.c:138
#define SS_RIGHT
Definition: pedump.c:694
HWND g_hwndCtrl[nMaxCtrls]
Definition: statst2.c:19
#define DrawText
Definition: winuser.h:5746
#define STN_DBLCLK
Definition: winuser.h:2077
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HINSTANCE hInstance
Definition: winuser.h:3181
#define nMaxCtrls
Definition: statst2.c:12
#define SS_GRAYRECT
Definition: pedump.c:697
#define CreateWindowEx
Definition: winuser.h:5730
#define CW_USEDEFAULT
Definition: winuser.h:225
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow)
Definition: statst2.c:163
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
UINT cbSize
Definition: winuser.h:3176
int nNextCtrl
Definition: statst2.c:18
#define SW_SHOW
Definition: winuser.h:769
#define SS_GRAYFRAME
Definition: pedump.c:700
HWND g_hwnd
Definition: statst2.c:16
HBRUSH hbrBackground
Definition: winuser.h:3184
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define SS_ETCHEDHORZ
Definition: winuser.h:343
#define SS_CENTER
Definition: pedump.c:693
#define SS_NOTIFY
Definition: winuser.h:351
#define STN_CLICKED
Definition: winuser.h:2076
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
int cbWndExtra
Definition: winuser.h:3180
HICON hIcon
Definition: winuser.h:3182
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: statst2.c:39
HINSTANCE g_hInst
Definition: statst2.c:17
#define SS_NOPREFIX
Definition: winuser.h:350
#define WM_COMMAND
Definition: winuser.h:1722
#define LoadCursor
Definition: winuser.h:5787
#define SS_BLACKFRAME
Definition: pedump.c:699
int cbClsExtra
Definition: winuser.h:3179
HINSTANCE hInst
Definition: dxdiag.c:13
#define SS_SUNKEN
Definition: winuser.h:358
#define SS_ETCHEDVERT
Definition: winuser.h:344
#define SetWindowText
Definition: winuser.h:5832
unsigned int UINT
Definition: ndis.h:50
#define GetMessage
Definition: winuser.h:5765
#define WM_DRAWITEM
Definition: winuser.h:1627
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WM_CREATE
Definition: winuser.h:1590
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define HIWORD(l)
Definition: typedefs.h:247
#define SS_WHITEFRAME
Definition: pedump.c:701
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5694
LONG_PTR LRESULT
Definition: windef.h:209
#define WS_VISIBLE
Definition: pedump.c:620
static SERVICE_STATUS status
Definition: service.c:31
#define SS_WHITERECT
Definition: pedump.c:698
LPARAM lParam
Definition: combotst.c:139
static char title[]
Definition: ps.c:92
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
Definition: ps.c:97