xref: /reactos/modules/rostests/tests/edit/edittest.c (revision 7d2f6b65)
1c2c66affSColin Finck /* Edit Control Test for ReactOS, quick n' dirty. Very rigid too.
2c2c66affSColin Finck  * There you go, is only a test program. Not made to be fast, small
3c2c66affSColin Finck  * easy to mantain, or portable. Lots of duplicated code too.
4c2c66affSColin Finck 
5c2c66affSColin Finck  * I'm not erasing text because I don't want to use other functions from th API
6c2c66affSColin Finck  * or make this more complex.
7c2c66affSColin Finck 
8c2c66affSColin Finck  * This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
9c2c66affSColin Finck  * by Waldo Alvarez Ca�izares <wac at ghost.matcom.uh.cu>, June 22, 2003. */
10c2c66affSColin Finck 
11c2c66affSColin Finck //#define WIN32_LEAN_AND_MEAN
12c2c66affSColin Finck #include <windows.h>
13c2c66affSColin Finck #include "utils.h"
14c2c66affSColin Finck 
15c2c66affSColin Finck #define CREATEWINDOW 106
16c2c66affSColin Finck #define CREATEWINDOWEX 107
17c2c66affSColin Finck #define CREATEWINDOWW 108
18c2c66affSColin Finck 
19c2c66affSColin Finck #define ResultX 0
20c2c66affSColin Finck #define ResultY 305
21c2c66affSColin Finck 
22c2c66affSColin Finck #define NOTIFYX 350
23c2c66affSColin Finck #define NOTIFYY 285
24c2c66affSColin Finck 
25c2c66affSColin Finck #define BUFFERLEN 80 /* Size of buffer to hold result strings */
26c2c66affSColin Finck 
27c2c66affSColin Finck /* Edit is created with this text */
28c2c66affSColin Finck #define TestStr "The quick brown fox jumps over the lazy dog"
29c2c66affSColin Finck 
30c2c66affSColin Finck #define TestStrW L"This is a WCHAR string" /*  Wide to support unicode edits */
31c2c66affSColin Finck 
32c2c66affSColin Finck #define MAXMESSAGEBUTTONS 42
33c2c66affSColin Finck 
34c2c66affSColin Finck HWND g_hwnd = NULL;
35c2c66affSColin Finck HINSTANCE g_hInst = NULL;
36c2c66affSColin Finck 
37c2c66affSColin Finck int pos = 10;
38c2c66affSColin Finck int n = 0;
39c2c66affSColin Finck int yButPos = 10;
40c2c66affSColin Finck int xButPos = 10;
41c2c66affSColin Finck 
42c2c66affSColin Finck DWORD EditStyle = 0;
43c2c66affSColin Finck DWORD EditWidth = 240;
44c2c66affSColin Finck DWORD EditHeight = 250;
45c2c66affSColin Finck 
46c2c66affSColin Finck BOOL UnicodeUsed = FALSE;
47c2c66affSColin Finck 
48c2c66affSColin Finck HWND hwndEdit = NULL;
49c2c66affSColin Finck 
50c2c66affSColin Finck POINTL point={10,3};
51c2c66affSColin Finck RECT  rect = {0,0,20,20},rect2;
52c2c66affSColin Finck DWORD StartP,EndP;
53c2c66affSColin Finck 
54c2c66affSColin Finck #define ReplaceTextStr "->> Replaced!! <<-"
55c2c66affSColin Finck 
56c2c66affSColin Finck char* AllocatedText;  /* Buffer in the heap to feed it to the edit control */
57c2c66affSColin Finck char* NewText = "New text for the edit control";
58c2c66affSColin Finck wchar_t* NewTextW = L"New text for the edit control in UNICODE"; // Wide
59c2c66affSColin Finck 
60c2c66affSColin Finck char TextBuffer[BUFFERLEN]={'R','e','s','u','l','t',':',' '};
61c2c66affSColin Finck 
62c2c66affSColin Finck typedef void FunctionHandler(HWND,DWORD,WPARAM,LPARAM);
63c2c66affSColin Finck typedef FunctionHandler* LPFUNCTIONHANDLER;
64c2c66affSColin Finck 
65c2c66affSColin Finck VOID
PrintTextXY(char * Text,int x,int y,int len)66c2c66affSColin Finck PrintTextXY(char* Text,int x,int y,int len)
67c2c66affSColin Finck {
68c2c66affSColin Finck       HDC hdc;
69c2c66affSColin Finck       hdc = GetDC (g_hwnd);
70c2c66affSColin Finck       SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
71c2c66affSColin Finck 
72c2c66affSColin Finck       TextOut (hdc, x,y,Text,len);
73c2c66affSColin Finck       ReleaseDC (g_hwnd, hdc);
74c2c66affSColin Finck       ValidateRect (g_hwnd, &rect);
75c2c66affSColin Finck }
76c2c66affSColin Finck 
77c2c66affSColin Finck static
78c2c66affSColin Finck VOID
HandlePrintReturnHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)79c2c66affSColin Finck HandlePrintReturnHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
80c2c66affSColin Finck     {
81c2c66affSColin Finck       int ret;
82c2c66affSColin Finck       ret = SendMessage(handle,Msg,wParam,lParam);
83c2c66affSColin Finck       htoa(ret,&TextBuffer[8]);
84c2c66affSColin Finck       PrintTextXY(TextBuffer,ResultX,ResultY,16);
85c2c66affSColin Finck     }
86c2c66affSColin Finck 
87c2c66affSColin Finck static
88c2c66affSColin Finck VOID
HandleSetHandlePrintHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)89c2c66affSColin Finck HandleSetHandlePrintHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
90c2c66affSColin Finck     {
91c2c66affSColin Finck       LPVOID pMem;
92c2c66affSColin Finck       HANDLE hNewBuffer;
93c2c66affSColin Finck       int ret;
94c2c66affSColin Finck 
95c2c66affSColin Finck       LocalFree((HLOCAL)SendMessage(handle, EM_GETHANDLE, 0, 0L));
96c2c66affSColin Finck       if (UnicodeUsed)
97c2c66affSColin Finck           {
98c2c66affSColin Finck             hNewBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, 100);
99c2c66affSColin Finck             pMem = LocalLock(hNewBuffer);
100c2c66affSColin Finck             strcpyw_((wchar_t*)pMem,NewTextW);
101c2c66affSColin Finck           }
102c2c66affSColin Finck       else
103c2c66affSColin Finck           {
104c2c66affSColin Finck             hNewBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT,50);
105c2c66affSColin Finck             pMem = LocalLock(hNewBuffer);
106c2c66affSColin Finck             strcpy_((char*)pMem,NewText);
107c2c66affSColin Finck           }
108c2c66affSColin Finck 
109c2c66affSColin Finck       LocalUnlock(pMem);
110c2c66affSColin Finck       hNewBuffer = LocalHandle(pMem);
111c2c66affSColin Finck 
112c2c66affSColin Finck 	  /* Updates the buffer and displays new buffer */
113c2c66affSColin Finck       ret =  SendMessage(handle, EM_SETHANDLE, (WPARAM)hNewBuffer, 0L);
114c2c66affSColin Finck 
115c2c66affSColin Finck       htoa(ret,&TextBuffer[8]);
116c2c66affSColin Finck       PrintTextXY(TextBuffer,ResultX,ResultY,16);
117c2c66affSColin Finck     }
118c2c66affSColin Finck 
119c2c66affSColin Finck static
120c2c66affSColin Finck VOID
HandlePrintReturnStr(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)121c2c66affSColin Finck HandlePrintReturnStr(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
122c2c66affSColin Finck     {
123c2c66affSColin Finck       int ret;
124c2c66affSColin Finck       TextBuffer[8] = (char)(BUFFERLEN - 8); /* Setting the max size to put chars in first byte */
125c2c66affSColin Finck       ret = SendMessage(handle,Msg,wParam,lParam);
126c2c66affSColin Finck       PrintTextXY(TextBuffer,ResultX,ResultY,8+ret);
127c2c66affSColin Finck     }
128c2c66affSColin Finck 
129c2c66affSColin Finck static
130c2c66affSColin Finck VOID
HandlePrintRect(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)131c2c66affSColin Finck HandlePrintRect(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
132c2c66affSColin Finck     {
133c2c66affSColin Finck       TextBuffer[8] = (char)(BUFFERLEN - 8); /* Setting the max size to put chars in first byte */
134c2c66affSColin Finck       SendMessage(handle,Msg,wParam,lParam);
135c2c66affSColin Finck 
136c2c66affSColin Finck       htoa(rect.top,&TextBuffer[8]);
137c2c66affSColin Finck       TextBuffer[8+8] = ' ';
138c2c66affSColin Finck       htoa(rect.bottom,&TextBuffer[8+8+1]);
139c2c66affSColin Finck       TextBuffer[8+8+8+1] = ' ';
140c2c66affSColin Finck       htoa(rect.left,&TextBuffer[8+8+8+1+1]);
141c2c66affSColin Finck       TextBuffer[8+8+8+8+1+1] = ' ';
142c2c66affSColin Finck       htoa(rect.right,&TextBuffer[8+8+8+8+1+1+1]);
143c2c66affSColin Finck 
144c2c66affSColin Finck       PrintTextXY(TextBuffer,ResultX,ResultY,8+4*9-1);
145c2c66affSColin Finck     }
146c2c66affSColin Finck 
147c2c66affSColin Finck static
148c2c66affSColin Finck VOID
HandlePrintPasswdChar(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)149c2c66affSColin Finck HandlePrintPasswdChar(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
150c2c66affSColin Finck     {
151c2c66affSColin Finck       HDC hdc;
152c2c66affSColin Finck       int ret = SendMessage(handle,Msg,wParam,lParam);
153c2c66affSColin Finck 
154c2c66affSColin Finck       int s;
155c2c66affSColin Finck 
156c2c66affSColin Finck       if (ret)
157c2c66affSColin Finck           {
158c2c66affSColin Finck             s = 1;
159c2c66affSColin Finck             TextBuffer[8] = (char)(ret);
160c2c66affSColin Finck           }
161c2c66affSColin Finck       else
162c2c66affSColin Finck           {
163c2c66affSColin Finck             TextBuffer[8]  = 'N';
164c2c66affSColin Finck             TextBuffer[9]  = 'U';
165c2c66affSColin Finck             TextBuffer[10] = 'L';
166c2c66affSColin Finck             TextBuffer[11] = 'L';
167c2c66affSColin Finck             s = 4;
168c2c66affSColin Finck           }
169c2c66affSColin Finck 
170c2c66affSColin Finck       hdc = GetDC (g_hwnd);
171c2c66affSColin Finck       SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
172c2c66affSColin Finck 
173c2c66affSColin Finck       TextOut (hdc,ResultX ,ResultY,TextBuffer,8+s);
174c2c66affSColin Finck       ReleaseDC (g_hwnd, hdc);
175c2c66affSColin Finck       ValidateRect (g_hwnd, &rect);
176c2c66affSColin Finck     }
177c2c66affSColin Finck 
178c2c66affSColin Finck 
179c2c66affSColin Finck struct
180c2c66affSColin Finck {
181c2c66affSColin Finck         char* Text;                	/* Text for the button */
182c2c66affSColin Finck         DWORD MsgCode;             	/* Message Code */
183c2c66affSColin Finck         WPARAM wParam;             	/* Well hope you can understand this */
184c2c66affSColin Finck         LPARAM lParam;             	/* ditto */
185c2c66affSColin Finck         LPFUNCTIONHANDLER Handler; 	/* Funtion called to handle the result of each message */
186c2c66affSColin Finck }
187c2c66affSColin Finck Msg[] =
188c2c66affSColin Finck {
189c2c66affSColin Finck 	{"EM_CANUNDO",EM_CANUNDO,0,0,&HandlePrintReturnHex},
190c2c66affSColin Finck 	{"EM_CHARFROMPOS",EM_CHARFROMPOS,(WPARAM)&point,0,&HandlePrintReturnHex},
191c2c66affSColin Finck 	{"EM_EMPTYUNDOBUFFER",EM_EMPTYUNDOBUFFER,0,0,&HandlePrintReturnHex},
192c2c66affSColin Finck 	{"EM_FMTLINES",EM_FMTLINES,TRUE,0,&HandlePrintReturnHex},
193c2c66affSColin Finck 	{"EM_GETFIRSTVISIBLELINE",EM_GETFIRSTVISIBLELINE,0,0,&HandlePrintReturnHex},
194c2c66affSColin Finck 
195c2c66affSColin Finck     {"EM_GETLIMITTEXT",EM_GETLIMITTEXT,0,0,&HandlePrintReturnHex},
196c2c66affSColin Finck 	{"EM_GETLINE",EM_GETLINE,2,(WPARAM)&TextBuffer[8],&HandlePrintReturnStr},
197c2c66affSColin Finck 	{"EM_GETLINECOUNT",EM_GETLINECOUNT,0,0,&HandlePrintReturnHex},
198c2c66affSColin Finck 	{"EM_GETMARGINS",EM_GETMARGINS,0,0,&HandlePrintReturnHex},
199c2c66affSColin Finck 	{"EM_SETMARGINS",EM_SETMARGINS,EC_LEFTMARGIN,10,&HandlePrintReturnHex},
200c2c66affSColin Finck 
201c2c66affSColin Finck 	{"EM_GETMODIFY",EM_GETMODIFY,0,0,&HandlePrintReturnHex},
202c2c66affSColin Finck 	{"EM_SETMODIFY",EM_SETMODIFY,TRUE,0,&HandlePrintReturnHex},
203c2c66affSColin Finck 
204c2c66affSColin Finck 	{"EM_GETSEL",EM_GETSEL,(WPARAM)&StartP,(LPARAM)&EndP,&HandlePrintReturnHex},
205c2c66affSColin Finck 
206c2c66affSColin Finck 	{"EM_GETTHUMB",EM_GETTHUMB,0,0,&HandlePrintReturnHex},
207c2c66affSColin Finck 
208c2c66affSColin Finck 	{"EM_LIMITTEXT",EM_LIMITTEXT,10,0,&HandlePrintReturnHex},
209c2c66affSColin Finck 	{"EM_LINEFROMCHAR",EM_LINEFROMCHAR,-1,0,&HandlePrintReturnHex},
210c2c66affSColin Finck 	{"EM_POSFROMCHAR",EM_POSFROMCHAR,10,0,&HandlePrintReturnHex},
211c2c66affSColin Finck 	{"EM_LINEINDEX",EM_LINEINDEX,2,0,&HandlePrintReturnHex},
212c2c66affSColin Finck 	{"EM_LINELENGTH",EM_LINELENGTH,-1,0,&HandlePrintReturnHex},
213c2c66affSColin Finck 
214c2c66affSColin Finck 	{"EM_GETWORDBREAKPROC",EM_GETWORDBREAKPROC,0,0,&HandlePrintReturnHex},
215c2c66affSColin Finck 	{"EM_REPLACESEL",EM_REPLACESEL,TRUE,(LPARAM)&ReplaceTextStr,&HandlePrintReturnHex},
216c2c66affSColin Finck 
217c2c66affSColin Finck 	{"EM_LINESCROLL",EM_LINESCROLL,5,1,&HandlePrintReturnHex},
218c2c66affSColin Finck 	{"EM_SCROLL",EM_SCROLL,SB_LINEDOWN,0,&HandlePrintReturnHex},
219c2c66affSColin Finck 	{"EM_SCROLLCARET",EM_SCROLLCARET,0,0,&HandlePrintReturnHex},
220c2c66affSColin Finck 
221c2c66affSColin Finck 	{"EM_SETHANDLE",EM_SETHANDLE,0,0,&HandleSetHandlePrintHex},
222c2c66affSColin Finck 	{"EM_GETHANDLE",EM_GETHANDLE,0,0,&HandlePrintReturnHex},
223c2c66affSColin Finck 	{"EM_GETPASSWORDCHAR",EM_GETPASSWORDCHAR,0,0,&HandlePrintPasswdChar},
224c2c66affSColin Finck 	{"EM_SETPASSWORDCHAR - clear",EM_SETPASSWORDCHAR,0,0,&HandlePrintReturnHex},
225c2c66affSColin Finck 	{"EM_SETPASSWORDCHAR - x",EM_SETPASSWORDCHAR,'x',0,&HandlePrintReturnHex},
226c2c66affSColin Finck 
227c2c66affSColin Finck 	{"EM_SETREADONLY - set",EM_SETREADONLY,TRUE,0,&HandlePrintReturnHex},
228c2c66affSColin Finck 	{"EM_SETREADONLY - clear",EM_SETREADONLY,FALSE,0,&HandlePrintReturnHex},
229c2c66affSColin Finck 
230c2c66affSColin Finck 	{"EM_GETRECT",EM_GETRECT,0,(LPARAM)&rect2,&HandlePrintRect},
231c2c66affSColin Finck 	{"EM_SETRECT",EM_SETRECT,0,(LPARAM)&rect,&HandlePrintReturnHex},
232c2c66affSColin Finck 	{"EM_SETRECTNP",EM_SETRECTNP,0,(LPARAM)&rect,&HandlePrintReturnHex},
233c2c66affSColin Finck 	{"EM_SETSEL",EM_SETSEL,1,3,&HandlePrintReturnHex},
234c2c66affSColin Finck 
235c2c66affSColin Finck 	{"EM_SETSEL - all",EM_SETSEL,0,-1,&HandlePrintReturnHex},
236c2c66affSColin Finck 	{"EM_SETSEL - remove",EM_SETSEL,-1,0,&HandlePrintReturnHex},
237c2c66affSColin Finck 	{"EM_UNDO",EM_UNDO,0,0,&HandlePrintReturnHex},
238c2c66affSColin Finck 	{"WM_UNDO",WM_UNDO,0,0,&HandlePrintReturnHex},
239c2c66affSColin Finck 	{"WM_PASTE",WM_PASTE,0,0,&HandlePrintReturnHex},
240c2c66affSColin Finck 
241c2c66affSColin Finck 	{"WM_CUT",WM_CUT,0,0,&HandlePrintReturnHex},
242c2c66affSColin Finck 	{"WM_COPY",WM_COPY,0,0,&HandlePrintReturnHex}
243c2c66affSColin Finck 
244c2c66affSColin Finck };
245c2c66affSColin Finck 
246c2c66affSColin Finck DWORD EditStyles[] = {
247c2c66affSColin Finck                       WS_THICKFRAME,WS_DISABLED,WS_BORDER,ES_LOWERCASE,ES_UPPERCASE,ES_NUMBER,ES_AUTOVSCROLL,
248c2c66affSColin Finck                       ES_AUTOHSCROLL,ES_LEFT,ES_CENTER,ES_RIGHT,ES_MULTILINE,
249c2c66affSColin Finck                       ES_NOHIDESEL,ES_OEMCONVERT,ES_PASSWORD,ES_READONLY,ES_WANTRETURN,
250c2c66affSColin Finck                       WS_HSCROLL,WS_VSCROLL
251c2c66affSColin Finck                      };
252c2c66affSColin Finck 
253c2c66affSColin Finck char* StyleNames[] = {
254c2c66affSColin Finck        		      "WS_THICKFRAME","WS_DISABLED","WS_BORDER","ES_LOWERCASE","ES_UPPERCASE","ES_NUMBER","ES_AUTOVSCROLL",
255c2c66affSColin Finck                       "ES_AUTOHSCROLL","ES_LEFT","ES_CENTER","ES_RIGHT","ES_MULTILINE",
256c2c66affSColin Finck                       "ES_NOHIDESEL","ES_OEMCONVERT","ES_PASSWORD","ES_READONLY","ES_WANTRETURN",
257c2c66affSColin Finck                       "WS_HSCROLL","WS_VSCROLL"
258c2c66affSColin Finck                      };
259c2c66affSColin Finck 
260c2c66affSColin Finck #define NUMBERBUTTONS 26
261c2c66affSColin Finck HWND Buttons[NUMBERBUTTONS];
262c2c66affSColin Finck HWND MessageButtons[MAXMESSAGEBUTTONS];
263c2c66affSColin Finck HWND Back1But,Back2But;
264c2c66affSColin Finck HWND NextBut;
265c2c66affSColin Finck 
266c2c66affSColin Finck 
267c2c66affSColin Finck HWND
CreateCheckButton(const char * lpWindowName,DWORD xSize,DWORD id)268c2c66affSColin Finck CreateCheckButton(const char* lpWindowName, DWORD xSize, DWORD id)
269c2c66affSColin Finck     {
270c2c66affSColin Finck     	HWND h;
271c2c66affSColin Finck  	h  = CreateWindowEx(0,
272c2c66affSColin Finck 			  "BUTTON",
273c2c66affSColin Finck                           lpWindowName,
274c2c66affSColin Finck 			  WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
275c2c66affSColin Finck 			  xButPos, /*  x  */
276c2c66affSColin Finck 		          yButPos, /*  y  */
277c2c66affSColin Finck 		          xSize,   /* nWidth  */
278c2c66affSColin Finck 		          20,      /* nHeight */
279c2c66affSColin Finck 			  g_hwnd,
280c2c66affSColin Finck 			  UlongToHandle(id),
281c2c66affSColin Finck 			  g_hInst,
282c2c66affSColin Finck 			  NULL
283c2c66affSColin Finck                          );
284c2c66affSColin Finck     	yButPos += 21;
285c2c66affSColin Finck 	return h;
286c2c66affSColin Finck     }
287c2c66affSColin Finck 
288c2c66affSColin Finck HWND
CreatePushButton(const char * lpWindowName,DWORD xSize,DWORD id,DWORD Style)289c2c66affSColin Finck CreatePushButton(const char* lpWindowName, DWORD xSize, DWORD id,DWORD Style)
290c2c66affSColin Finck     {
291c2c66affSColin Finck 
292c2c66affSColin Finck     HWND h = CreateWindow("BUTTON",
293c2c66affSColin Finck                           lpWindowName,
294c2c66affSColin Finck                           WS_CHILD | BS_PUSHBUTTON | Style,
295c2c66affSColin Finck 					      xButPos, // x
296c2c66affSColin Finck 		                  yButPos, // y
297c2c66affSColin Finck 		                  xSize,   // nWidth
298c2c66affSColin Finck 		                  20,      // nHeight
299c2c66affSColin Finck 					      g_hwnd,
300c2c66affSColin Finck                           (HMENU)(ULONG_PTR) id,
301c2c66affSColin Finck                           g_hInst,
302c2c66affSColin Finck                           NULL
303c2c66affSColin Finck                           );
304c2c66affSColin Finck 
305c2c66affSColin Finck     yButPos += 21;
306c2c66affSColin Finck     return h;
307c2c66affSColin Finck     }
308c2c66affSColin Finck 
309c2c66affSColin Finck VOID
ReadNHide()310c2c66affSColin Finck ReadNHide()
311c2c66affSColin Finck     {
312c2c66affSColin Finck         int i;
313c2c66affSColin Finck         EditStyle = 0;
314c2c66affSColin Finck         for (i=0 ; i< 19 ; i++)
315c2c66affSColin Finck         {
316c2c66affSColin Finck         if(BST_CHECKED == SendMessage(Buttons[i],BM_GETCHECK,0,0))
317c2c66affSColin Finck         EditStyle |= EditStyles[i];
318c2c66affSColin Finck         ShowWindow(Buttons[i],SW_HIDE);
319c2c66affSColin Finck         }
320c2c66affSColin Finck 
321c2c66affSColin Finck         for (; i< NUMBERBUTTONS ; i++)ShowWindow(Buttons[i],SW_HIDE);
322c2c66affSColin Finck         for (i=0 ; i< 26 ; i++) ShowWindow(MessageButtons[i],SW_SHOW);
323c2c66affSColin Finck 
324c2c66affSColin Finck         ShowWindow(Back1But,SW_SHOW);
325c2c66affSColin Finck         ShowWindow(NextBut,SW_SHOW);
326c2c66affSColin Finck     }
327c2c66affSColin Finck 
328c2c66affSColin Finck VOID
ForwardToSecondPage()329c2c66affSColin Finck ForwardToSecondPage()
330c2c66affSColin Finck     {
331c2c66affSColin Finck         int i;
332c2c66affSColin Finck         for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_HIDE);
333c2c66affSColin Finck         for(;i<MAXMESSAGEBUTTONS;i++)ShowWindow(MessageButtons[i],SW_SHOW);
334c2c66affSColin Finck         ShowWindow(Back2But,SW_SHOW);
335c2c66affSColin Finck 
336c2c66affSColin Finck         ShowWindow(Back1But,SW_HIDE);
337c2c66affSColin Finck         ShowWindow(NextBut,SW_HIDE);
338c2c66affSColin Finck     }
339c2c66affSColin Finck 
340c2c66affSColin Finck VOID
BackToFirstPage()341c2c66affSColin Finck BackToFirstPage()
342c2c66affSColin Finck     {
343c2c66affSColin Finck         int i;
344c2c66affSColin Finck         for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_SHOW);
345c2c66affSColin Finck         for(;i<MAXMESSAGEBUTTONS;i++)ShowWindow(MessageButtons[i],SW_HIDE);
346c2c66affSColin Finck         ShowWindow(Back2But,SW_HIDE);
347c2c66affSColin Finck         ShowWindow(Back1But,SW_SHOW);
348c2c66affSColin Finck         ShowWindow(NextBut,SW_SHOW);
349c2c66affSColin Finck     }
350c2c66affSColin Finck 
351c2c66affSColin Finck VOID
BackToInitialPage()352c2c66affSColin Finck BackToInitialPage()
353c2c66affSColin Finck     {
354c2c66affSColin Finck         int i;
355c2c66affSColin Finck         DestroyWindow(hwndEdit);
356c2c66affSColin Finck         for (i=0 ; i< NUMBERBUTTONS ; i++) {ShowWindow(Buttons[i],SW_SHOW);}
357c2c66affSColin Finck         for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_HIDE);
358c2c66affSColin Finck         ShowWindow(Back1But,SW_HIDE);
359c2c66affSColin Finck         ShowWindow(NextBut,SW_HIDE);
360c2c66affSColin Finck     }
361c2c66affSColin Finck 
362c2c66affSColin Finck LRESULT
363c2c66affSColin Finck CALLBACK
WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)364c2c66affSColin Finck WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
365c2c66affSColin Finck {
366c2c66affSColin Finck     int i;
367c2c66affSColin Finck 	switch ( msg )
368c2c66affSColin Finck 	{
369c2c66affSColin Finck 	case WM_CREATE:
370c2c66affSColin Finck 		g_hwnd = hwnd;
371c2c66affSColin Finck 
372c2c66affSColin Finck         /* ---- Initial page ---- */
373c2c66affSColin Finck 
374c2c66affSColin Finck         for (i = 0 ; i < 14 ; i++)
375c2c66affSColin Finck             Buttons[i] = CreateCheckButton(StyleNames[i],150,500+i);
376c2c66affSColin Finck 
377c2c66affSColin Finck         xButPos += 160;
378c2c66affSColin Finck         yButPos = 10;
379c2c66affSColin Finck 
380c2c66affSColin Finck         for (; i < 19 ; i++)
381c2c66affSColin Finck             Buttons[i] = CreateCheckButton(StyleNames[i],140,500+i);
382c2c66affSColin Finck 
383c2c66affSColin Finck         Buttons[i++] = CreatePushButton("Width +",70,100,WS_VISIBLE);
384c2c66affSColin Finck         Buttons[i++] = CreatePushButton("Width -",70,101,WS_VISIBLE);
385c2c66affSColin Finck 
386*7d2f6b65SMustafa Ateş Uzun         Buttons[i++] = CreatePushButton("Height +",70,102,WS_VISIBLE);
387*7d2f6b65SMustafa Ateş Uzun         Buttons[i++] = CreatePushButton("Height -",70,103,WS_VISIBLE);
388c2c66affSColin Finck 
389c2c66affSColin Finck         Buttons[i++] = CreatePushButton("CreateWindowA",140,CREATEWINDOW,WS_VISIBLE);
390c2c66affSColin Finck         Buttons[i++] = CreatePushButton("CreateWindowExA",140,CREATEWINDOWEX,WS_VISIBLE);
391c2c66affSColin Finck         Buttons[i++] = CreatePushButton("CreateWindowExW",140,CREATEWINDOWW,WS_VISIBLE);
392c2c66affSColin Finck 
393c2c66affSColin Finck 
394c2c66affSColin Finck         /* ---- The 1st page of buttons ---- */
395c2c66affSColin Finck 
396c2c66affSColin Finck         xButPos = 0;
397c2c66affSColin Finck         yButPos = 10;
398c2c66affSColin Finck 
399c2c66affSColin Finck         for (i = 0 ; i < 14 ; i++)
400c2c66affSColin Finck             MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
401c2c66affSColin Finck 
402c2c66affSColin Finck         xButPos += 180;
403c2c66affSColin Finck         yButPos = 10;
404c2c66affSColin Finck 
405c2c66affSColin Finck         for (; i < 26 ; i++)
406c2c66affSColin Finck             MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
407c2c66affSColin Finck 
408c2c66affSColin Finck         Back1But = CreatePushButton("Back - destroys edit",170,400,0);
409c2c66affSColin Finck         NextBut = CreatePushButton("Next",170,401,0);
410c2c66affSColin Finck 
411c2c66affSColin Finck         /* ---- The 2nd page of buttons ------*/
412c2c66affSColin Finck 
413c2c66affSColin Finck         xButPos = 0;
414c2c66affSColin Finck         yButPos = 10;
415c2c66affSColin Finck 
416c2c66affSColin Finck         for (; i<40; i++)
417c2c66affSColin Finck             MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
418c2c66affSColin Finck 
419c2c66affSColin Finck         xButPos += 180;
420c2c66affSColin Finck         yButPos = 10;
421c2c66affSColin Finck 
422c2c66affSColin Finck         for (; i < MAXMESSAGEBUTTONS ; i++)
423c2c66affSColin Finck             MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
424c2c66affSColin Finck 
425c2c66affSColin Finck         Back2But = CreatePushButton("Back",170,402,0);
426c2c66affSColin Finck 
427c2c66affSColin Finck 		break;
428c2c66affSColin Finck 
429c2c66affSColin Finck 	case WM_COMMAND:
430c2c66affSColin Finck         if (LOWORD(wParam) >= 600)
431c2c66affSColin Finck             {
432c2c66affSColin Finck             Msg[LOWORD(wParam)-600].Handler(hwndEdit,
433c2c66affSColin Finck                         Msg[LOWORD(wParam)-600].MsgCode,
434c2c66affSColin Finck                         Msg[LOWORD(wParam)-600].wParam,
435c2c66affSColin Finck                         Msg[LOWORD(wParam)-600].lParam);
436c2c66affSColin Finck             break;
437c2c66affSColin Finck             }
438c2c66affSColin Finck 
439c2c66affSColin Finck         switch(LOWORD(wParam)){
440c2c66affSColin Finck 
441c2c66affSColin Finck         case 100:
442c2c66affSColin Finck             EditWidth += 10;
443c2c66affSColin Finck             break;
444c2c66affSColin Finck 
445c2c66affSColin Finck         case 101:
446c2c66affSColin Finck             EditWidth -= 10;
447c2c66affSColin Finck             break;
448c2c66affSColin Finck 
449c2c66affSColin Finck         case 102:
450c2c66affSColin Finck             EditHeight += 10;
451c2c66affSColin Finck             break;
452c2c66affSColin Finck 
453c2c66affSColin Finck         case 103:
454c2c66affSColin Finck             EditHeight -= 10;
455c2c66affSColin Finck             break;
456c2c66affSColin Finck 
457c2c66affSColin Finck         case 400:
458c2c66affSColin Finck             BackToInitialPage();
459c2c66affSColin Finck             break;
460c2c66affSColin Finck 
461c2c66affSColin Finck         case 401:
462c2c66affSColin Finck             ForwardToSecondPage();
463c2c66affSColin Finck             break;
464c2c66affSColin Finck 
465c2c66affSColin Finck         case 402:
466c2c66affSColin Finck             BackToFirstPage();
467c2c66affSColin Finck             break;
468c2c66affSColin Finck 
469c2c66affSColin Finck         case CREATEWINDOW:
470c2c66affSColin Finck                   UnicodeUsed = FALSE;
471c2c66affSColin Finck                   ReadNHide();
472c2c66affSColin Finck                   hwndEdit = CreateWindow("EDIT",
473c2c66affSColin Finck                                TestStr,
474c2c66affSColin Finck                                EditStyle | WS_CHILD | WS_VISIBLE,
475c2c66affSColin Finck                                350,
476c2c66affSColin Finck                                10,
477c2c66affSColin Finck                                EditWidth,
478c2c66affSColin Finck                                EditHeight,
479c2c66affSColin Finck                                g_hwnd,
480c2c66affSColin Finck                                NULL,
481c2c66affSColin Finck                                g_hInst,
482c2c66affSColin Finck                                NULL);
483c2c66affSColin Finck                   break;
484c2c66affSColin Finck 
485c2c66affSColin Finck         case CREATEWINDOWEX:
486c2c66affSColin Finck                   UnicodeUsed = FALSE;
487c2c66affSColin Finck                   ReadNHide();
488c2c66affSColin Finck                   hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
489c2c66affSColin Finck                                "EDIT",
490c2c66affSColin Finck                                TestStr,
491c2c66affSColin Finck                                EditStyle | WS_CHILD | WS_VISIBLE ,
492c2c66affSColin Finck                                350,
493c2c66affSColin Finck                                10,
494c2c66affSColin Finck                                EditWidth,
495c2c66affSColin Finck                                EditHeight,
496c2c66affSColin Finck                                g_hwnd,
497c2c66affSColin Finck                                NULL,
498c2c66affSColin Finck                                g_hInst,
499c2c66affSColin Finck                                NULL);
500c2c66affSColin Finck                   break;
501c2c66affSColin Finck 
502c2c66affSColin Finck         case CREATEWINDOWW:
503c2c66affSColin Finck                   UnicodeUsed = TRUE;
504c2c66affSColin Finck                   ReadNHide();
505c2c66affSColin Finck                   hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE,
506c2c66affSColin Finck                                L"EDIT",
507c2c66affSColin Finck                                TestStrW,
508c2c66affSColin Finck                                EditStyle | WS_CHILD | WS_VISIBLE ,
509c2c66affSColin Finck                                350,
510c2c66affSColin Finck                                10,
511c2c66affSColin Finck                                EditWidth,
512c2c66affSColin Finck                                EditHeight,
513c2c66affSColin Finck                                g_hwnd,
514c2c66affSColin Finck                                NULL,
515c2c66affSColin Finck                                g_hInst,
516c2c66affSColin Finck                                NULL);
517c2c66affSColin Finck                   break;
518c2c66affSColin Finck             }
519c2c66affSColin Finck 
520c2c66affSColin Finck 	if (lParam == (LPARAM)hwndEdit)
521c2c66affSColin Finck 		switch(HIWORD(wParam))
522c2c66affSColin Finck 		{
523c2c66affSColin Finck 		case EN_CHANGE:
524c2c66affSColin Finck                 PrintTextXY("EN_CHANGE notification",NOTIFYX,NOTIFYY,22);
525c2c66affSColin Finck 		break;
526c2c66affSColin Finck 
527c2c66affSColin Finck                 case EN_ERRSPACE:
528c2c66affSColin Finck 		PrintTextXY("EN_ERRSPACE notification",NOTIFYX,NOTIFYY,24);
529c2c66affSColin Finck 		break;
530c2c66affSColin Finck 
531c2c66affSColin Finck 		/* --- FIXME not defined in w32api-2.3 headers
532c2c66affSColin Finck 		case H_SCROLL:
533c2c66affSColin Finck 		PrintTextXY("H_SCROLL notification",NOTIFYX,NOTIFYY,21);
534c2c66affSColin Finck 		break; */
535c2c66affSColin Finck 
536c2c66affSColin Finck 		/* --- FIXME not defined in w32api-2.3 headers
537c2c66affSColin Finck 		case KILL_FOCUS:
538c2c66affSColin Finck 		PrintTextXY("KILL_FOCUS notification",NOTIFYX,NOTIFYY,23);
539c2c66affSColin Finck 		break; */
540c2c66affSColin Finck 
541c2c66affSColin Finck 		/* --- FIXME not defined in w32api-2.3 headers
542c2c66affSColin Finck 		case EN_MAXTEST:
543c2c66affSColin Finck 		PrintTextXY("EN_MAXTEXT notification",NOTIFYX,NOTIFYY,23);
544c2c66affSColin Finck 		break; */
545c2c66affSColin Finck 
546c2c66affSColin Finck 		case EN_SETFOCUS:
547c2c66affSColin Finck 		PrintTextXY("EN_SETFOCUS notification",NOTIFYX,NOTIFYY,24);
548c2c66affSColin Finck 		break;
549c2c66affSColin Finck 
550c2c66affSColin Finck 		case EN_UPDATE:
551c2c66affSColin Finck 		PrintTextXY("EN_UPDATE notification",NOTIFYX,NOTIFYY + 20,22);
552c2c66affSColin Finck 		break;
553c2c66affSColin Finck 
554c2c66affSColin Finck 		case EN_VSCROLL:
555c2c66affSColin Finck 		PrintTextXY("EN_VSCROLL notification",NOTIFYX,NOTIFYY,23);
556c2c66affSColin Finck 		break;
557c2c66affSColin Finck 
558c2c66affSColin Finck 		}
559c2c66affSColin Finck 
560c2c66affSColin Finck 	break;
561c2c66affSColin Finck 
562c2c66affSColin Finck     case WM_SIZE :
563c2c66affSColin Finck         return 0;
564c2c66affSColin Finck 
565c2c66affSColin Finck     case WM_CLOSE:
566c2c66affSColin Finck 	DestroyWindow (g_hwnd);
567c2c66affSColin Finck 	return 0;
568c2c66affSColin Finck 
569c2c66affSColin Finck     case WM_QUERYENDSESSION:
570c2c66affSColin Finck 	return 0;
571c2c66affSColin Finck 
572c2c66affSColin Finck     case WM_DESTROY:
573c2c66affSColin Finck 	PostQuitMessage(0);
574c2c66affSColin Finck 	return 0;
575c2c66affSColin Finck      }
576c2c66affSColin Finck      return DefWindowProc ( hwnd, msg, wParam, lParam );
577c2c66affSColin Finck }
578c2c66affSColin Finck 
579c2c66affSColin Finck HWND
RegisterAndCreateWindow(HINSTANCE hInst,const char * className,const char * title)580c2c66affSColin Finck RegisterAndCreateWindow (HINSTANCE hInst,
581c2c66affSColin Finck 			 const char* className,
582c2c66affSColin Finck 			 const char* title)
583c2c66affSColin Finck {
584c2c66affSColin Finck 	WNDCLASSEX wc;
585c2c66affSColin Finck 	HWND hwnd;
586c2c66affSColin Finck 
587c2c66affSColin Finck 	g_hInst = hInst;
588c2c66affSColin Finck 
589c2c66affSColin Finck 	wc.cbSize = sizeof (WNDCLASSEX);
590c2c66affSColin Finck 
591c2c66affSColin Finck 	wc.lpfnWndProc = WndProc;   /* window procedure */
592c2c66affSColin Finck 	wc.hInstance = hInst;       /* owner of the class */
593c2c66affSColin Finck 
594c2c66affSColin Finck 	wc.lpszClassName = className;
595c2c66affSColin Finck 	wc.hCursor = LoadCursor ( 0, (LPCTSTR)IDC_ARROW );
596c2c66affSColin Finck 	wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
597c2c66affSColin Finck 	wc.style = CS_HREDRAW | CS_VREDRAW;
598c2c66affSColin Finck 	wc.cbClsExtra = 0;
599c2c66affSColin Finck 	wc.cbWndExtra = 0;
600c2c66affSColin Finck 	wc.hIcon = 0;
601c2c66affSColin Finck 	wc.hIconSm = 0;
602c2c66affSColin Finck 	wc.lpszMenuName = 0;
603c2c66affSColin Finck 
604c2c66affSColin Finck 	if ( !RegisterClassEx ( &wc ) )
605c2c66affSColin Finck 		return NULL;
606c2c66affSColin Finck 
607c2c66affSColin Finck 	hwnd = CreateWindowEx (
608c2c66affSColin Finck 				0, 	   /* dwStyleEx */
609c2c66affSColin Finck 				className, /* class name */
610c2c66affSColin Finck 				title,     /* window title */
611c2c66affSColin Finck 
612c2c66affSColin Finck 				WS_OVERLAPPEDWINDOW, /* dwStyle */
613c2c66affSColin Finck 
614c2c66affSColin Finck 				1,    /* x */
615c2c66affSColin Finck 				1,    /* y */
616c2c66affSColin Finck 				560,  /* width */
617c2c66affSColin Finck 				350,  /* height */
618c2c66affSColin Finck 				NULL, /* hwndParent */
619c2c66affSColin Finck 				NULL, /* hMenu */
620c2c66affSColin Finck 				hInst,
621c2c66affSColin Finck 				0
622c2c66affSColin Finck 			       );
623c2c66affSColin Finck 
624c2c66affSColin Finck 	if (!hwnd) return NULL;
625c2c66affSColin Finck 
626c2c66affSColin Finck 	ShowWindow (hwnd, SW_SHOW);
627c2c66affSColin Finck 	UpdateWindow (hwnd);
628c2c66affSColin Finck 
629c2c66affSColin Finck 	return hwnd;
630c2c66affSColin Finck }
631c2c66affSColin Finck 
632c2c66affSColin Finck int
633c2c66affSColin Finck WINAPI
WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR cmdParam,int cmdShow)634c2c66affSColin Finck WinMain ( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow )
635c2c66affSColin Finck {
636c2c66affSColin Finck 	char className [] = "Edit Control Test";
637c2c66affSColin Finck 	MSG msg;
638c2c66affSColin Finck 
639c2c66affSColin Finck 	RegisterAndCreateWindow ( hInst, className, "Edit Control Styles Test" );
640c2c66affSColin Finck 
641c2c66affSColin Finck 	// Message loop
642c2c66affSColin Finck 	while (GetMessage (&msg, NULL, 0, 0))
643c2c66affSColin Finck      {
644c2c66affSColin Finck           TranslateMessage (&msg);
645c2c66affSColin Finck           DispatchMessage (&msg);
646c2c66affSColin Finck      }
647c2c66affSColin Finck      return msg.wParam;
648c2c66affSColin Finck 
649c2c66affSColin Finck }
650