ReactOS 0.4.15-dev-7906-g1b85a5f
accelerator.c File Reference
#include <windows.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for accelerator.c:

Go to the source code of this file.

Macros

#define ID_ACCEL1   0x100
 
#define ID_ACCEL2   0x101
 
#define ID_ACCEL3   0x102
 
#define ID_ACCEL4   0x103
 
#define VK_A   0x41
 

Functions

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

Variables

static ACCEL Accelerators [4]
 
static HACCEL hAcceleratorTable
 
static char Event [200]
 

Macro Definition Documentation

◆ ID_ACCEL1

#define ID_ACCEL1   0x100

Definition at line 5 of file accelerator.c.

◆ ID_ACCEL2

#define ID_ACCEL2   0x101

Definition at line 6 of file accelerator.c.

◆ ID_ACCEL3

#define ID_ACCEL3   0x102

Definition at line 7 of file accelerator.c.

◆ ID_ACCEL4

#define ID_ACCEL4   0x103

Definition at line 8 of file accelerator.c.

◆ VK_A

#define VK_A   0x41

Definition at line 11 of file accelerator.c.

Function Documentation

◆ MainWndProc()

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

Definition at line 112 of file accelerator.c.

113{
114 PAINTSTRUCT ps;
115 HDC hDC;
116 char buf[200];
117
118 switch(msg)
119 {
120 case WM_PAINT:
121 hDC = BeginPaint(hWnd, &ps);
122 //SelectObject(hDC, tf);
123 sprintf(buf, "Event: '%s'", Event);
124 TextOut(hDC, 10, 10, buf, strlen(buf));
125 EndPaint(hWnd, &ps);
126 break;
127
128 case WM_DESTROY:
130 break;
131
132 case WM_COMMAND:
133
134 switch (LOWORD(wParam))
135 {
136 case ID_ACCEL1:
137 strcpy(Event, "A");
138 break;
139
140 case ID_ACCEL2:
141 strcpy(Event, "SHIFT+A");
142 break;
143
144 case ID_ACCEL3:
145 strcpy(Event, "CTRL+A");
146 break;
147
148 case ID_ACCEL4:
149 strcpy(Event, "ALT+A");
150 break;
151
152 default:
153 sprintf(Event, "%d", LOWORD(wParam));
154 break;
155 }
156
159 break;
160
161 default:
163 }
164 return 0;
165}
static HDC hDC
Definition: 3dtext.c:33
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define ID_ACCEL2
Definition: accelerator.c:6
#define ID_ACCEL4
Definition: accelerator.c:8
#define ID_ACCEL1
Definition: accelerator.c:5
#define ID_ACCEL3
Definition: accelerator.c:7
static HDC
Definition: imagelist.c:92
#define LOWORD(l)
Definition: pedump.c:82
#define DefWindowProc
Definition: ros2win.h:31
#define TextOut
Definition: wingdi.h:4483
#define WM_PAINT
Definition: winuser.h:1620
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1740
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
BOOL WINAPI UpdateWindow(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by WinMain().

◆ WinMain()

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

Definition at line 30 of file accelerator.c.

34{
35 WNDCLASS wc;
36 MSG msg;
37 HWND hWnd;
38
39 wc.lpszClassName = "AcceleratorTest";
46 wc.lpszMenuName = NULL;
47 wc.cbClsExtra = 0;
48 wc.cbWndExtra = 0;
49 if (RegisterClass(&wc) == 0)
50 {
51 fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
52 GetLastError());
53 return(1);
54 }
55
56 hWnd = CreateWindow("AcceleratorTest",
57 "Accelerator Test",
59 0,
60 0,
63 NULL,
64 NULL,
66 NULL);
67 if (hWnd == NULL)
68 {
69 fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
70 GetLastError());
71 return(1);
72 }
73
74 /*tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
75 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
76 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");*/
77
78 Event[0] = 0;
79
80 ShowWindow(hWnd, nCmdShow);
81
83 sizeof(Accelerators)/sizeof(Accelerators[1]));
85 {
86 fprintf(stderr, "CreateAcceleratorTable failed (last error 0x%lX)\n",
87 GetLastError());
88 return(1);
89 }
90
91 while(GetMessage(&msg, NULL, 0, 0))
92 {
94 {
97 }
98 }
99
101 {
102 fprintf(stderr, "DestroyAcceleratorTable failed (last error 0x%lX)\n",
103 GetLastError());
104 return(1);
105 }
106
107 //DeleteObject(tf);
108
109 return msg.wParam;
110}
HINSTANCE hInstance
Definition: charmap.c:19
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: accelerator.c:112
static HACCEL hAcceleratorTable
Definition: accelerator.c:24
static ACCEL Accelerators[4]
Definition: accelerator.c:19
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define GRAY_BRUSH
Definition: wingdi.h:898
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CreateAcceleratorTable
Definition: winuser.h:5748
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
#define CreateWindow
Definition: winuser.h:5754
#define GetMessage
Definition: winuser.h:5790
#define LoadIcon
Definition: winuser.h:5813
#define LoadCursor
Definition: winuser.h:5812
#define CW_USEDEFAULT
Definition: winuser.h:225
#define RegisterClass
Definition: winuser.h:5836
#define DispatchMessage
Definition: winuser.h:5765
BOOL WINAPI DestroyAcceleratorTable(_In_ HACCEL)
#define TranslateAccelerator
Definition: winuser.h:5860
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Variable Documentation

◆ Accelerators

ACCEL Accelerators[4]
static
Initial value:
= {
#define VK_A
Definition: accelerator.c:11
#define FVIRTKEY
Definition: winuser.h:24
#define FSHIFT
Definition: winuser.h:23
#define FCONTROL
Definition: winuser.h:21
#define FALT
Definition: winuser.h:20

Definition at line 19 of file accelerator.c.

Referenced by WinMain().

◆ Event

char Event[200]
static

Definition at line 25 of file accelerator.c.

◆ hAcceleratorTable

HACCEL hAcceleratorTable
static

Definition at line 24 of file accelerator.c.

Referenced by WinMain().