ReactOS 0.4.15-dev-5669-g09dde2c
statst2.c File Reference
#include <windows.h>
#include <assert.h>
Include dependency graph for statst2.c:

Go to the source code of this file.

Macros

#define SS_ENDELLIPSIS   0x00004000L
 
#define nMaxCtrls   32
 
#define nStaticWidth   384
 
#define nStaticHeight   18
 

Functions

static void CreateStatic (const char *lpWindowName, DWORD dwStyle)
 
LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
HWND RegisterAndCreateWindow (HINSTANCE hInst, const char *className, const char *title)
 
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow)
 

Variables

HWND g_hwnd = NULL
 
HINSTANCE g_hInst = 0
 
int nNextCtrl = 0
 
HWND g_hwndCtrl [nMaxCtrls]
 

Macro Definition Documentation

◆ nMaxCtrls

#define nMaxCtrls   32

Definition at line 12 of file statst2.c.

◆ nStaticHeight

#define nStaticHeight   18

Definition at line 14 of file statst2.c.

◆ nStaticWidth

#define nStaticWidth   384

Definition at line 13 of file statst2.c.

◆ SS_ENDELLIPSIS

#define SS_ENDELLIPSIS   0x00004000L

Definition at line 8 of file statst2.c.

Function Documentation

◆ CreateStatic()

static void CreateStatic ( const char lpWindowName,
DWORD  dwStyle 
)
static

Definition at line 21 of file statst2.c.

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}
#define NULL
Definition: types.h:112
#define assert(x)
Definition: debug.h:53
GLdouble n
Definition: glext.h:7729
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define nMaxCtrls
Definition: statst2.c:12
#define nStaticHeight
Definition: statst2.c:14
HWND g_hwnd
Definition: statst2.c:16
#define nStaticWidth
Definition: statst2.c:13
int nNextCtrl
Definition: statst2.c:18
HINSTANCE g_hInst
Definition: statst2.c:17
HWND g_hwndCtrl[nMaxCtrls]
Definition: statst2.c:19
#define CreateWindow
Definition: winuser.h:5744

Referenced by WndProc().

◆ RegisterAndCreateWindow()

HWND RegisterAndCreateWindow ( HINSTANCE  hInst,
const char className,
const char title 
)

Definition at line 115 of file statst2.c.

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
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
158 UpdateWindow ( hwnd );
159
160 return hwnd;
161}
HINSTANCE hInst
Definition: dxdiag.c:13
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
static char title[]
Definition: ps.c:92
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: statst2.c:39
int cbClsExtra
Definition: winuser.h:3194
HINSTANCE hInstance
Definition: winuser.h:3196
HCURSOR hCursor
Definition: winuser.h:3198
LPCSTR lpszMenuName
Definition: winuser.h:3200
HICON hIconSm
Definition: winuser.h:3202
UINT style
Definition: winuser.h:3192
int cbWndExtra
Definition: winuser.h:3195
UINT cbSize
Definition: winuser.h:3191
WNDPROC lpfnWndProc
Definition: winuser.h:3193
LPCSTR lpszClassName
Definition: winuser.h:3201
HICON hIcon
Definition: winuser.h:3197
HBRUSH hbrBackground
Definition: winuser.h:3199
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define CreateWindowEx
Definition: winuser.h:5745
#define COLOR_WINDOW
Definition: winuser.h:912
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDC_ARROW
Definition: winuser.h:682
#define RegisterClassEx
Definition: winuser.h:5827
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5802
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5709
#define CW_USEDEFAULT
Definition: winuser.h:225
#define SW_SHOW
Definition: winuser.h:769
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Referenced by WinMain().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInst,
HINSTANCE  hPrevInst,
LPSTR  cmdParam,
int  cmdShow 
)

Definition at line 163 of file statst2.c.

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 msg(x)
Definition: auth_time.c:54
HWND RegisterAndCreateWindow(HINSTANCE hInst, const char *className, const char *title)
Definition: statst2.c:115
Definition: ps.c:97
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define GetMessage
Definition: winuser.h:5780
#define DispatchMessage
Definition: winuser.h:5755

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 39 of file statst2.c.

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:
110 return 0;
111 }
112 return DefWindowProc ( hwnd, msg, wParam, lParam );
113}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
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
#define SS_WHITERECT
Definition: pedump.c:698
#define SS_WHITEFRAME
Definition: pedump.c:701
#define SS_BLACKRECT
Definition: pedump.c:696
#define SS_RIGHT
Definition: pedump.c:694
#define SS_GRAYFRAME
Definition: pedump.c:700
#define SS_CENTER
Definition: pedump.c:693
#define SS_GRAYRECT
Definition: pedump.c:697
#define SS_BLACKFRAME
Definition: pedump.c:699
#define DefWindowProc
Definition: ros2win.h:31
static void CreateStatic(const char *lpWindowName, DWORD dwStyle)
Definition: statst2.c:21
#define SS_ENDELLIPSIS
Definition: statst2.c:8
#define HIWORD(l)
Definition: typedefs.h:247
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define WM_CREATE
Definition: winuser.h:1598
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SS_OWNERDRAW
Definition: winuser.h:352
#define WM_COMMAND
Definition: winuser.h:1730
#define SS_NOTIFY
Definition: winuser.h:351
#define SS_ETCHEDFRAME
Definition: winuser.h:342
#define SS_NOPREFIX
Definition: winuser.h:350
#define SS_ETCHEDHORZ
Definition: winuser.h:343
#define SS_ETCHEDVERT
Definition: winuser.h:344
#define WM_DRAWITEM
Definition: winuser.h:1635
#define DrawText
Definition: winuser.h:5761
#define WM_DESTROY
Definition: winuser.h:1599
#define SetWindowText
Definition: winuser.h:5847
#define STN_DBLCLK
Definition: winuser.h:2085
#define SS_SUNKEN
Definition: winuser.h:358
#define STN_CLICKED
Definition: winuser.h:2084

Referenced by RegisterAndCreateWindow().

Variable Documentation

◆ g_hInst

HINSTANCE g_hInst = 0

Definition at line 17 of file statst2.c.

Referenced by CreateStatic(), and RegisterAndCreateWindow().

◆ g_hwnd

HWND g_hwnd = NULL

Definition at line 16 of file statst2.c.

Referenced by CreateStatic(), and WndProc().

◆ g_hwndCtrl

HWND g_hwndCtrl[nMaxCtrls]

Definition at line 19 of file statst2.c.

Referenced by CreateStatic(), and WndProc().

◆ nNextCtrl

int nNextCtrl = 0

Definition at line 18 of file statst2.c.

Referenced by CreateStatic().