ReactOS  0.4.14-dev-614-gbfd8a84
winhello.c File Reference
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
Include dependency graph for winhello.c:

Go to the source code of this file.

Macros

#define VK_C   'C'
 
#define CTRLC   1 /* Define our HotKeys */
 
#define ALTF1   2 /* Define our HotKeys */
 

Functions

LRESULT WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 

Variables

HFONT tf
 
BOOLEAN bolWM_CHAR
 
BOOLEAN bolWM_KEYDOWN
 

Macro Definition Documentation

◆ ALTF1

#define ALTF1   2 /* Define our HotKeys */

Definition at line 107 of file winhello.c.

◆ CTRLC

#define CTRLC   1 /* Define our HotKeys */

Definition at line 106 of file winhello.c.

◆ VK_C

#define VK_C   'C'

Definition at line 30 of file winhello.c.

Function Documentation

◆ MainWndProc()

LRESULT WINAPI MainWndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 109 of file winhello.c.

110 {
111  PAINTSTRUCT ps; /* Also used during window drawing */
112  HDC hDC; /* A device context used for drawing */
113  RECT rc = {0,0,0,0}, clr, wir; /* A rectangle used during drawing */
114  char spr[100], sir[100];
115  static HBRUSH hbrWhite=NULL, hbrGray=NULL, hbrBlack=NULL, hbrRed=NULL, hbrBlue=NULL, hbrYellow=NULL;
116 
117  /* The window handle for the "Click Me" button. */
118  static HWND hwndButton = 0;
119  static int cx, cy; /* Height and width of our button. */
120 
121  switch(msg)
122  {
123 
124  case WM_CHAR:
125  {
126  TCHAR text[2];
127  hDC = GetDC(hWnd);
128  text[0] = (TCHAR)wParam;
129  text[1] = _T('\0');
130 
131  //Write in window
132  if( bolWM_KEYDOWN )
133  {
134  TextOut(hDC, 400, 10, "WM CHAR:", strlen("WM CHAR:"));
135  bolWM_KEYDOWN = 0;
136  }
137  else
138  {
139  TextOut(hDC, 400, 10, "WM_CHAR:", strlen("WM_CHAR:"));
140  bolWM_KEYDOWN = 1;
141  }
142  TextOut(hDC, 530, 10, text, strlen(text));
143 
144 #if 0
145  // Make a line depending on the typed key
146  Rect.left = 10;
147  Rect.top = 75;
148  Rect.right = 610;
149  Rect.bottom = 85;
150  FillRect(hDC, &Rect, hbrWhite);
151 
152  Rect.left=308;
153  Rect.right=312;
154  FillRect(hDC, &Rect, hbrRed);
155 
156  Rect.left = 310;
157  Rect.top = 75;
158  Rect.right = 310 +text[0]*2;
159  Rect.bottom = 85;
160  HBRUSH hbrCustom = CreateSolidBrush ( RGB(text[0], text[0], text[0]));
161  FillRect(hDC, &Rect, hbrCustom);
162  DeleteObject ( hbrCustom );
163 
164 #endif
165 
166  ReleaseDC(hWnd, hDC);
167  return 0;
168  }
169 
170  case WM_KEYDOWN:
171  {
172  RECT Rect;
173  TCHAR text[2];
174  hDC = GetDC(hWnd);
175  text[0] = (TCHAR)wParam;
176  text[1] = _T('\0');
177 
178 
179  /* Write in window */
180  Rect.left = 400;
181  Rect.top = 50;
182  Rect.right = 550;
183  Rect.bottom = 70;
184  FillRect(hDC, &Rect, hbrWhite);
185  if( bolWM_CHAR )
186  {
187  TextOut(hDC, 400, 30, "WM KEYDOWN:", strlen("WM KEYDOWN:"));
188  bolWM_CHAR = 0;
189  }
190  else
191  {
192  TextOut(hDC, 400, 30, "WM_KEYDOWN:", strlen("WM_KEYDOWN:"));
193  bolWM_CHAR = 1;
194  }
195  TextOut(hDC, 530, 30, text, strlen(text));
196  ReleaseDC(hWnd, hDC);
197  return 0;
198  }
199 
200  case WM_KEYUP:
201  {
202  RECT Rect;
203  TCHAR text[2];
204  hDC = GetDC(hWnd);
205  text[0] = (TCHAR)wParam;
206  text[1] = _T('\0');
207 
208 
209  /* Write in window */
210  Rect.left = 400;
211  Rect.top = 10;
212  Rect.right = 550;
213  Rect.bottom = 70;
214  FillRect(hDC, &Rect, hbrWhite);
215  TextOut(hDC, 400, 50, "WM_KEYUP:", strlen("WM_KEYUP:"));
216  TextOut(hDC, 530, 50, text, strlen(text));
217  ReleaseDC(hWnd, hDC);
218  return 0;
219  }
220 
221 
222  case WM_LBUTTONDOWN:
223  {
224  ULONG x, y;
225  RECT Rect;
226  hDC = GetDC(hWnd);
227  x = LOWORD(lParam);
228  y = HIWORD(lParam);
229 
230  Rect.left = x - 5;
231  Rect.top = y - 5;
232  Rect.right = x + 5;
233  Rect.bottom = y + 5;
234  FillRect(hDC, &Rect, hbrRed);
235 
236  Rect.left = x - 3;
237  Rect.top = y - 3;
238  Rect.right = x + 3;
239  Rect.bottom = y + 3;
240  FillRect(hDC, &Rect, hbrBlack);
241 
242  ReleaseDC(hWnd, hDC);
243  break;
244  }
245  case WM_LBUTTONUP:
246  {
247  ULONG x, y;
248  RECT Rect;
249  hDC = GetDC(hWnd);
250  x = LOWORD(lParam);
251  y = HIWORD(lParam);
252 
253  Rect.left = x - 5;
254  Rect.top = y - 5;
255  Rect.right = x + 5;
256  Rect.bottom = y + 5;
257  FillRect(hDC, &Rect, hbrRed);
258 
259  Rect.left = x - 3;
260  Rect.top = y - 3;
261  Rect.right = x + 3;
262  Rect.bottom = y + 3;
263  FillRect(hDC, &Rect, hbrGray);
264 
265  ReleaseDC(hWnd, hDC);
266  break;
267  }
268  case WM_MBUTTONDOWN:
269  {
270  ULONG x, y;
271  RECT Rect;
272  hDC = GetDC(hWnd);
273  x = LOWORD(lParam);
274  y = HIWORD(lParam);
275 
276  Rect.left = x - 5;
277  Rect.top = y - 5;
278  Rect.right = x + 5;
279  Rect.bottom = y + 5;
280  FillRect(hDC, &Rect, hbrBlue);
281 
282  Rect.left = x - 3;
283  Rect.top = y - 3;
284  Rect.right = x + 3;
285  Rect.bottom = y + 3;
286  FillRect(hDC, &Rect, hbrBlack);
287 
288  ReleaseDC(hWnd, hDC);
289  break;
290  }
291  case WM_MBUTTONUP:
292  {
293  ULONG x, y;
294  RECT Rect;
295  hDC = GetDC(hWnd);
296  x = LOWORD(lParam);
297  y = HIWORD(lParam);
298 
299  Rect.left = x - 5;
300  Rect.top = y - 5;
301  Rect.right = x + 5;
302  Rect.bottom = y + 5;
303  FillRect(hDC, &Rect, hbrBlue);
304 
305  Rect.left = x - 3;
306  Rect.top = y - 3;
307  Rect.right = x + 3;
308  Rect.bottom = y + 3;
309  FillRect(hDC, &Rect, hbrGray);
310 
311  ReleaseDC(hWnd, hDC);
312  break;
313  }
314  case WM_RBUTTONDOWN:
315  {
316  ULONG x, y;
317  RECT Rect;
318  hDC = GetDC(hWnd);
319  x = LOWORD(lParam);
320  y = HIWORD(lParam);
321 
322  Rect.left = x - 5;
323  Rect.top = y - 5;
324  Rect.right = x + 5;
325  Rect.bottom = y + 5;
327 
328  Rect.left = x - 3;
329  Rect.top = y - 3;
330  Rect.right = x + 3;
331  Rect.bottom = y + 3;
332  FillRect(hDC, &Rect, hbrBlack);
333 
334  ReleaseDC(hWnd, hDC);
335  break;
336  }
337  case WM_RBUTTONUP:
338  {
339  ULONG x, y;
340  RECT Rect;
341  hDC = GetDC(hWnd);
342  x = LOWORD(lParam);
343  y = HIWORD(lParam);
344 
345  Rect.left = x - 5;
346  Rect.top = y - 5;
347  Rect.right = x + 5;
348  Rect.bottom = y + 5;
350 
351  Rect.left = x - 3;
352  Rect.top = y - 3;
353  Rect.right = x + 3;
354  Rect.bottom = y + 3;
355  FillRect(hDC, &Rect, hbrGray);
356 
357  ReleaseDC(hWnd, hDC);
358  break;
359  }
360 
361  case WM_MOUSEMOVE:
362  {
363  int fwKeys;
364  int x;
365  int y;
366  RECT Rect;
367  int temp;
368  TCHAR text[256];
369 
370  hDC = GetDC(hWnd);
371  fwKeys = wParam; // key flags
372  x = LOWORD(lParam); // horizontal position of cursor
373  y = HIWORD(lParam); // vertical position of cursor
374 
375  Rect.left = 10;
376  Rect.top = 100;
377  Rect.right = 160;
378  Rect.bottom = 300;
379  FillRect(hDC, &Rect, hbrWhite);
380 
381  temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("x: %d"), x );
382  TextOut(hDC,10,100,text,strlen(text));
383  temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("y: %d"), y );
384  TextOut(hDC,10,120,text,strlen(text));
385 
386  Rect.left = x - 2;
387  Rect.top = y - 2;
388  Rect.right = x + 2;
389  Rect.bottom = y + 2;
390 
391  switch ( fwKeys )
392  {
393  case MK_CONTROL:
394  TextOut(hDC,10,140,"Control",strlen("Control"));
395  break;
396  case MK_SHIFT:
397  TextOut(hDC,10,160,"Shift",strlen("Shift"));
398  break;
399  case MK_LBUTTON:
400  TextOut(hDC,10,180,"Left",strlen("Left"));
401  FillRect(hDC, &Rect, hbrRed);
402  break;
403  case MK_MBUTTON:
404  TextOut(hDC,10,200,"Middle",strlen("Middle"));
405  FillRect(hDC, &Rect, hbrBlue);
406  break;
407  case MK_RBUTTON:
408  TextOut(hDC,10,220,"Right",strlen("Right"));
410  break;
411  }
412  ReleaseDC(hWnd, hDC);
413  break;
414  }
415 
416  case WM_HSCROLL:
417  {
418  int nPos;
419  int temp;
420  RECT Rect;
421  int nScrollCode;
422  HWND hwndScrollBar;
423  TCHAR text[256];
424  SCROLLINFO Scrollparameter;
425  nScrollCode = (int) LOWORD(wParam); // scroll bar value
426  nPos = (short int) HIWORD(wParam); // scroll box position
427  hwndScrollBar = (HWND) lParam; // handle to scroll bar
428  hDC = GetDC(hWnd);
429 
430  Scrollparameter.cbSize = sizeof(Scrollparameter);
431  Scrollparameter.fMask = SIF_ALL;
432  GetScrollInfo ( hWnd, SB_HORZ, &Scrollparameter );
433 
434  Rect.left = 200;
435  Rect.top = 100;
436  Rect.right = 350;
437  Rect.bottom = 300;
438  FillRect(hDC, &Rect, hbrWhite);
439 
440  switch ( nScrollCode )
441  {
442  case SB_ENDSCROLL: //Ends scroll.
443  TextOut(hDC,200,120,"SB_ENDSCROLL ",16);
444  Scrollparameter.nPos = Scrollparameter.nPos;
445  break;
446  case SB_LEFT: //Scrolls to the upper left.
447  TextOut(hDC,200,140,"SB_LEFT ",16);
448  Scrollparameter.nPos = Scrollparameter.nMin;
449  break;
450  case SB_RIGHT: //Scrolls to the lower right.
451  TextOut(hDC,200,160,"SB_RIGHT ",16);
452  Scrollparameter.nPos = Scrollparameter.nMax;
453  break;
454  case SB_LINELEFT: //Scrolls left by one unit.
455  TextOut(hDC,200,180,"SB_LINELEFT ",16);
456  Scrollparameter.nPos--;
457  break;
458  case SB_LINERIGHT: //Scrolls right by one unit.
459  TextOut(hDC,200,200,"SB_LINERIGHT ",16);
460  Scrollparameter.nPos++;
461  break;
462  case SB_PAGELEFT: //Scrolls left by the width of the window.
463  TextOut(hDC,200,220,"SB_PAGELEFT ",16);
464  Scrollparameter.nPos -= Scrollparameter.nPage;
465  break;
466  case SB_PAGERIGHT: //Scrolls right by the width of the window.
467  TextOut(hDC,200,240,"PAGERIGHT ",16);
468  Scrollparameter.nPos += Scrollparameter.nPage;
469  break;
470  case SB_THUMBPOSITION: //The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
471  TextOut(hDC,200,260,"SB_THUMBPOSITION",16);
472  Scrollparameter.nPos = Scrollparameter.nTrackPos;
473  break;
474  case SB_THUMBTRACK: //
475  TextOut(hDC,200,280,"SB_THUMBTRACK ",16);
476  Scrollparameter.nPos = Scrollparameter.nTrackPos;
477  break;
478  }
479 
481  hWnd, // handle to window with scroll bar
482  SB_HORZ, // scroll bar flag
483  &Scrollparameter, // pointer to structure with scroll parameters
484  1 // redraw flag
485  );
486  temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("Horizontal: %d"), Scrollparameter.nPos );
487  TextOut(hDC,200,100,text,strlen(text));
488  ReleaseDC(hWnd, hDC);
489  return 0;
490  }
491 
492  case WM_VSCROLL:
493  {
494  int nPos;
495  int temp;
496  RECT Rect;
497  int nScrollCode;
498  HWND hwndScrollBar;
499  TCHAR text[256];
500  SCROLLINFO Scrollparameter;
501  nScrollCode = (int) LOWORD(wParam); // scroll bar value
502  nPos = (short int) HIWORD(wParam); // scroll box position
503  hwndScrollBar = (HWND) lParam; // handle to scroll bar
504  hDC = GetDC(hWnd);
505 
506  Scrollparameter.cbSize = sizeof(Scrollparameter);
507  Scrollparameter.fMask = SIF_ALL;
508  GetScrollInfo ( hWnd, SB_VERT, &Scrollparameter );
509 
510  Rect.left = 400;
511  Rect.top = 100;
512  Rect.right = 550;
513  Rect.bottom = 300;
514  FillRect(hDC, &Rect, hbrWhite);
515 
516  switch ( nScrollCode )
517  {
518  case SB_ENDSCROLL: //Ends scroll.
519  TextOut(hDC,400,120,"SB_ENDSCROLL ",16);
520  Scrollparameter.nPos = Scrollparameter.nPos;
521  break;
522  case SB_LEFT: //Scrolls to the upper left.
523  TextOut(hDC,400,140,"SB_LEFT ",16);
524  Scrollparameter.nPos = Scrollparameter.nMin;
525  break;
526  case SB_RIGHT: //Scrolls to the lower right.
527  TextOut(hDC,400,160,"SB_RIGHT ",16);
528  Scrollparameter.nPos = Scrollparameter.nMax;
529  break;
530  case SB_LINELEFT: //Scrolls left by one unit.
531  TextOut(hDC,400,180,"SB_LINELEFT ",16);
532  Scrollparameter.nPos--;
533  break;
534  case SB_LINERIGHT: //Scrolls right by one unit.
535  TextOut(hDC,400,200,"SB_LINERIGHT ",16);
536  Scrollparameter.nPos++;
537  break;
538  case SB_PAGELEFT: //Scrolls left by the width of the window.
539  TextOut(hDC,400,220,"SB_PAGELEFT ",16);
540  Scrollparameter.nPos -= Scrollparameter.nPage;
541  break;
542  case SB_PAGERIGHT: //Scrolls right by the width of the window.
543  TextOut(hDC,400,240,"PAGERIGHT ",16);
544  Scrollparameter.nPos += Scrollparameter.nPage;
545  break;
546  case SB_THUMBPOSITION: //The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
547  TextOut(hDC,400,260,"SB_THUMBPOSITION",16);
548  Scrollparameter.nPos = Scrollparameter.nTrackPos;
549  break;
550  case SB_THUMBTRACK: //
551  TextOut(hDC,400,280,"SB_THUMBTRACK ",16);
552  Scrollparameter.nPos = Scrollparameter.nTrackPos;
553  break;
554  }
555 
557  hWnd, // handle to window with scroll bar
558  SB_VERT, // scroll bar flag
559  &Scrollparameter, // pointer to structure with scroll parameters
560  1 // redraw flag
561  );
562  temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("Vertical: %d"), Scrollparameter.nPos );
563  TextOut(hDC,400,100,text,strlen(text));
564  ReleaseDC(hWnd, hDC);
565  return 0;
566  }
567 
568  case WM_HOTKEY:
569  switch(wParam)
570  {
571  case CTRLC:
572  MessageBox(hWnd, "You just pressed Ctrl+C", "Hotkey", MB_OK | MB_ICONINFORMATION);
573  break;
574  case ALTF1:
575  MessageBox(hWnd, "You just pressed Ctrl+Alt+F1", "Hotkey", MB_OK | MB_ICONINFORMATION);
576  break;
577  }
578  break;
579 
580  case WM_DESTROY:
583  PostQuitMessage(0);
584  DeleteObject ( hbrWhite );
585  DeleteObject ( hbrGray );
586  DeleteObject ( hbrBlack );
587  DeleteObject ( hbrRed );
588  DeleteObject ( hbrBlue );
590  break;
591 
592  case WM_CREATE:
593  {
594  SCROLLINFO si;
595  TEXTMETRIC tm;
596  /* Register a Ctrl+Alt+C hotkey*/
599 
600  hbrWhite = CreateSolidBrush ( RGB(0xFF, 0xFF, 0xFF));
601  hbrGray = CreateSolidBrush ( RGB(0xAF, 0xAF, 0xAF));
602  hbrBlack = CreateSolidBrush ( RGB(0x00, 0x00, 0x00));
603  hbrRed = CreateSolidBrush ( RGB(0xFF, 0x00, 0x00));
604  hbrBlue = CreateSolidBrush ( RGB(0x00, 0x00, 0xFF));
605  hbrYellow = CreateSolidBrush ( RGB(0xFF, 0xFF, 0x00));
606 
607  si.cbSize = sizeof(si);
608  si.fMask = SIF_ALL;
609  si.nMin = 0;
610  si.nMax = 100;
611  si.nPage = 5;
612  si.nPos = 0;
613 
614  SetScrollInfo ( hWnd, SB_HORZ, &si, FALSE );
615  SetScrollInfo ( hWnd, SB_VERT, &si, FALSE );
616 
617 
618  /* The window is being created. Create our button
619  * window now. */
620 
621  /* First we use the system fixed font size to choose
622  * a nice button size. */
623  hDC = GetDC (hWnd);
625  GetTextMetrics (hDC, &tm);
626  cx = tm.tmAveCharWidth * 30;
627  cy = (tm.tmHeight + tm.tmExternalLeading) * 2;
628  ReleaseDC (hWnd, hDC);
629 
630  /* Now create the button */
631  hwndButton = CreateWindow (
632  "button", /* Builtin button class */
633  "Click Here",
635  0, 0, cx, cy,
636  hWnd, /* Parent is this window. */
637  (HMENU) 1, /* Control ID: 1 */
639  NULL
640  );
641 
642  return 0;
643  break;
644  }
645 
646  case WM_PAINT:
647  hDC = BeginPaint(hWnd, &ps);
648  TextOut(hDC, 10, 10, "Hello World from ReactOS!",
649  strlen("Hello World from ReactOS!"));
650  TextOut(hDC, 10, 80, "Press Ctrl+C or Ctrl+Alt+F1 to test Hotkey support.",
651  strlen("Press Ctrl+C or Ctrl+Alt+F1 to test Hotkey support."));
652  GetClientRect(hWnd, &clr);
653  GetWindowRect(hWnd, &wir);
654  sprintf(spr, "%lu,%lu,%lu,%lu ", clr.left, clr.top, clr.right, clr.bottom);
655  sprintf(sir, "%lu,%lu,%lu,%lu ", wir.left, wir.top, wir.right, wir.bottom);
656  TextOut(hDC, 10, 30, spr, 20);
657  TextOut(hDC, 10, 50, sir, 20);
658 
659  /* Draw "Hello, World" in the middle of the upper
660  * half of the window. */
661  rc.bottom = rc.bottom / 2;
662  DrawText (hDC, "Hello, World", -1, &rc,
664 
665  EndPaint (hWnd, &ps);
666  return 0;
667  break;
668 
669  case WM_SIZE:
670  /* The window size is changing. If the button exists
671  * then place it in the center of the bottom half of
672  * the window. */
673  if (hwndButton &&
674  (wParam == SIZEFULLSCREEN ||
675  wParam == SIZENORMAL)
676  )
677  {
678  rc.left = (LOWORD(lParam) - cx) / 2;
679  rc.top = HIWORD(lParam) * 3 / 4 - cy / 2;
680  MoveWindow (
681  hwndButton,
682  rc.left, rc.top, cx, cy, TRUE);
683  }
684  break;
685 
686  case WM_COMMAND:
687  /* Check the control ID, notification code and
688  * control handle to see if this is a button click
689  * message from our child button. */
690  if (LOWORD(wParam) == 1 &&
691  HIWORD(wParam) == BN_CLICKED &&
692  (HWND) lParam == hwndButton)
693  {
694  /* Our button was clicked. Close the window. */
696  }
697  return 0;
698  break;
699 
700  default:
701  return DefWindowProc(hWnd, msg, wParam, lParam);
702  }
703  return 0;
704 }
#define WM_MBUTTONUP
Definition: winuser.h:1765
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRUE
Definition: types.h:120
#define MK_SHIFT
Definition: winuser.h:2344
#define WM_CHAR
Definition: winuser.h:1699
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
#define CreateWindow
Definition: winuser.h:5729
#define MK_LBUTTON
Definition: winuser.h:2342
#define SB_RIGHT
Definition: winuser.h:576
HDC WINAPI GetDC(_In_opt_ HWND)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define SB_VERT
Definition: winuser.h:553
#define WM_HOTKEY
Definition: winuser.h:1861
const WCHAR * text
Definition: package.c:1827
#define MK_MBUTTON
Definition: winuser.h:2346
#define SB_HORZ
Definition: winuser.h:552
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
HANDLE HWND
Definition: compat.h:13
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:306
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define GetTextMetrics
Definition: wingdi.h:4473
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI UnregisterHotKey(_In_opt_ HWND, _In_ int)
#define DrawText
Definition: winuser.h:5746
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define ALTF1
Definition: winhello.c:107
HINSTANCE hInstance
Definition: charmap.c:20
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define VK_C
Definition: winhello.c:30
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
smooth NULL
Definition: ftsmooth.c:416
#define SB_THUMBPOSITION
Definition: winuser.h:572
#define WM_KEYDOWN
Definition: winuser.h:1697
#define DT_VCENTER
Definition: winuser.h:543
#define SB_ENDSCROLL
Definition: winuser.h:574
#define MK_RBUTTON
Definition: winuser.h:2343
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
BOOLEAN bolWM_KEYDOWN
Definition: winhello.c:40
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define SB_THUMBTRACK
Definition: winuser.h:573
#define WM_SIZE
Definition: winuser.h:1593
HBRUSH hbrBlue
#define RGB(r, g, b)
Definition: wingdi.h:2939
#define WM_KEYUP
Definition: winuser.h:1698
#define BN_CLICKED
Definition: winuser.h:1907
HBRUSH hbrRed
#define WM_RBUTTONUP
Definition: winuser.h:1762
#define WM_PAINT
Definition: winuser.h:1602
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define SB_PAGELEFT
Definition: winuser.h:570
#define _sntprintf
Definition: xmlstorage.h:201
#define SB_LEFT
Definition: winuser.h:575
#define MessageBox
Definition: winuser.h:5797
Definition: time.h:76
#define WM_COMMAND
Definition: winuser.h:1722
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOLEAN bolWM_CHAR
Definition: winhello.c:39
#define SB_LINERIGHT
Definition: winuser.h:567
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define SIZENORMAL
Definition: winuser.h:2485
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_SINGLELINE
Definition: winuser.h:540
#define MOD_ALT
Definition: imm.h:311
#define MOD_CONTROL
Definition: imm.h:312
static calc_node_t temp
Definition: rpn_ieee.c:38
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define WM_MBUTTONDOWN
Definition: winuser.h:1764
#define SB_PAGERIGHT
Definition: winuser.h:571
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define WM_HSCROLL
Definition: winuser.h:1725
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define MB_OK
Definition: winuser.h:784
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define MK_CONTROL
Definition: winuser.h:2345
#define VK_F1
Definition: winuser.h:2230
#define msg(x)
Definition: auth_time.c:54
_Out_opt_ int * cx
Definition: commctrl.h:581
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
#define TextOut
Definition: wingdi.h:4482
#define SB_LINELEFT
Definition: winuser.h:566
LONG bottom
Definition: windef.h:309
#define DT_CENTER
Definition: winuser.h:527
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI RegisterHotKey(_In_opt_ HWND, _In_ int, _In_ UINT, _In_ UINT)
HBRUSH hbrYellow
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
struct Rect Rect
#define WM_VSCROLL
Definition: winuser.h:1726
#define SIF_ALL
Definition: winuser.h:1218
#define CTRLC
Definition: winhello.c:106
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define SYSTEM_FIXED_FONT
Definition: wingdi.h:911
#define SIZEFULLSCREEN
Definition: winuser.h:2487

Referenced by WinMain().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 43 of file winhello.c.

47 {
48  WNDCLASS wc;
49  MSG msg;
50  HWND hWnd;
51  bolWM_CHAR = 0;
52  bolWM_KEYDOWN = 0;
53 
54  wc.lpszClassName = "HelloClass";
57  wc.hInstance = hInstance;
61  wc.lpszMenuName = NULL;
62  wc.cbClsExtra = 0;
63  wc.cbWndExtra = 0;
64  if (RegisterClass(&wc) == 0)
65  {
66  fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
67  GetLastError());
68  return(1);
69  }
70 
71  hWnd = CreateWindow("HelloClass",
72  "Hello World",
74  0, //Position; you can use CW_USEDEFAULT, too
75  0,
76  600, //height
77  400,
78  NULL,
79  NULL,
80  hInstance,
81  NULL);
82  if (hWnd == NULL)
83  {
84  fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
85  GetLastError());
86  return(1);
87  }
88 
92 
93  ShowWindow(hWnd, nCmdShow);
94 
95  while(GetMessage(&msg, NULL, 0, 0))
96  {
99  }
100 
101  DeleteObject(tf);
102 
103  return msg.wParam;
104 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define DEFAULT_QUALITY
Definition: wingdi.h:435
#define CreateWindow
Definition: winuser.h:5729
#define FF_DONTCARE
Definition: wingdi.h:447
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
int cbClsExtra
Definition: winuser.h:3140
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3146
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3145
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int cbWndExtra
Definition: winuser.h:3141
HINSTANCE hInstance
Definition: charmap.c:20
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define FIXED_PITCH
Definition: wingdi.h:443
#define TA_BASELINE
Definition: wingdi.h:927
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
HCURSOR hCursor
Definition: winuser.h:3144
smooth NULL
Definition: ftsmooth.c:416
#define GRAY_BRUSH
Definition: wingdi.h:897
BOOLEAN bolWM_KEYDOWN
Definition: winhello.c:40
#define CS_VREDRAW
Definition: winuser.h:653
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
HFONT tf
Definition: winhello.c:37
#define WS_HSCROLL
Definition: pedump.c:628
LPCSTR lpszClassName
Definition: winuser.h:3147
BOOLEAN bolWM_CHAR
Definition: winhello.c:39
#define LoadCursor
Definition: winuser.h:5787
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
UINT style
Definition: winuser.h:3138
HINSTANCE hInstance
Definition: winuser.h:3142
#define WS_VSCROLL
Definition: pedump.c:627
#define GetMessage
Definition: winuser.h:5765
#define FW_NORMAL
Definition: wingdi.h:372
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
FILE * stderr
#define RegisterClass
Definition: winuser.h:5811
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: winhello.c:109
#define LoadIcon
Definition: winuser.h:5788
#define ANSI_CHARSET
Definition: wingdi.h:382
HICON hIcon
Definition: winuser.h:3143

Variable Documentation

◆ bolWM_CHAR

BOOLEAN bolWM_CHAR

Definition at line 39 of file winhello.c.

Referenced by MainWndProc(), and WinMain().

◆ bolWM_KEYDOWN

BOOLEAN bolWM_KEYDOWN

Definition at line 40 of file winhello.c.

Referenced by MainWndProc(), and WinMain().

◆ tf

HFONT tf

Definition at line 37 of file winhello.c.

Referenced by WinMain().