ReactOS 0.4.15-dev-7942-gd23573b
popupmenu.c
Go to the documentation of this file.
1#include <windows.h>
2#include <stdio.h>
3#include <string.h>
4#include "resource.h"
5
7
8int WINAPI
10 HINSTANCE hPrevInstance,
11 LPSTR lpszCmdLine,
12 int nCmdShow)
13{
14 WNDCLASS wc;
15 MSG msg;
16 HWND hWnd;
17
18 wc.lpszClassName = "MenuTestClass";
24 wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
26 wc.cbClsExtra = 0;
27 wc.cbWndExtra = 0;
28 if (RegisterClass(&wc) == 0)
29 {
30 fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
31 GetLastError());
32 return(1);
33 }
34
35 hWnd = CreateWindow("MenuTestClass",
36 "PopupMenu Test",
38 0,
39 0,
42 NULL,
43 NULL,
45 NULL);
46 if (hWnd == NULL)
47 {
48 fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
49 GetLastError());
50 return(1);
51 }
52
53 while(GetMessage(&msg, NULL, 0, 0))
54 {
57 }
58
59 return msg.wParam;
60}
61
63{
64 switch(msg)
65 {
66 case WM_COMMAND:
67 {
68 switch(LOWORD(wParam))
69 {
70 case IDM_EXIT:
72 break;
73 }
74 break;
75 }
76 case WM_RBUTTONUP:
77 {
78 POINT pos;
79 HMENU Menu;
80
81 pos.x = LOWORD(lParam);
82 pos.y = HIWORD(lParam);
84
85 if((Menu = GetMenu(hWnd)) && (Menu = GetSubMenu(Menu, 1)))
86 {
87 TrackPopupMenu(Menu, 0, pos.x, pos.y, 0, hWnd, NULL);
88 }
89 break;
90 }
91 case WM_DESTROY:
92 {
94 break;
95 }
96 default:
97 {
99 }
100 }
101 return 0;
102}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define IDM_EXIT
Definition: resource.h:27
#define IDM_MAINMENU
Definition: resources.h:3
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define CALLBACK
Definition: compat.h:35
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: popupmenu.c:9
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: popupmenu.c:62
#define DefWindowProc
Definition: ros2win.h:31
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
#define HIWORD(l)
Definition: typedefs.h:247
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1740
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define WM_RBUTTONUP
Definition: winuser.h:1780
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define IDI_APPLICATION
Definition: winuser.h:704
#define CreateWindow
Definition: winuser.h:5754
#define GetMessage
Definition: winuser.h:5790
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define LoadIcon
Definition: winuser.h:5813
#define LoadCursor
Definition: winuser.h:5812
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define RegisterClass
Definition: winuser.h:5836
#define WM_DESTROY
Definition: winuser.h:1609
#define DispatchMessage
Definition: winuser.h:5765
HMENU WINAPI GetMenu(_In_ HWND)
#define COLOR_BTNFACE
Definition: winuser.h:928
char * LPSTR
Definition: xmlstorage.h:182
const CHAR * LPCTSTR
Definition: xmlstorage.h:193