From cda2695c4c812fb4b56797fa62d1ebd2a9a0dfe0 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 27 Dec 2003 23:45:48 +0000 Subject: [PATCH] added test app for TrackPopupMenu(Ex)() svn path=/trunk/; revision=7273 --- reactos/apps/tests/Makefile | 2 +- reactos/apps/tests/popupmenu/.cvsignore | 6 ++ reactos/apps/tests/popupmenu/makefile | 23 +++++ reactos/apps/tests/popupmenu/popupmenu.c | 102 ++++++++++++++++++++++ reactos/apps/tests/popupmenu/popupmenu.rc | 47 ++++++++++ reactos/apps/tests/popupmenu/resource.h | 2 + 6 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 reactos/apps/tests/popupmenu/.cvsignore create mode 100644 reactos/apps/tests/popupmenu/makefile create mode 100644 reactos/apps/tests/popupmenu/popupmenu.c create mode 100644 reactos/apps/tests/popupmenu/popupmenu.rc create mode 100644 reactos/apps/tests/popupmenu/resource.h diff --git a/reactos/apps/tests/Makefile b/reactos/apps/tests/Makefile index ec4477f8bff..7b0659668ee 100644 --- a/reactos/apps/tests/Makefile +++ b/reactos/apps/tests/Makefile @@ -14,7 +14,7 @@ hivetest hotkey icontest isotest lineclip linetest lock lpc messagebox \ mktime mstest multithrdwin multiwin mutex nptest patblt pipe primitives pteb \ regtest sectest sertest shaptest shm statst statst2 stretchblt suspend \ tcpsvr terminate txtscale thread thread_msg tokentest vmtest \ -winhello winhello2 wm_erasebkgnd wm_paint eventpair threadwait \ +winhello winhello2 wm_erasebkgnd wm_paint eventpair threadwait popupmenu \ map_dup_inherit p_dup_handle apc2 enhmetafile dirdlg guithreadinfo TEST_MISC = diff --git a/reactos/apps/tests/popupmenu/.cvsignore b/reactos/apps/tests/popupmenu/.cvsignore new file mode 100644 index 00000000000..d63774a7353 --- /dev/null +++ b/reactos/apps/tests/popupmenu/.cvsignore @@ -0,0 +1,6 @@ +*.o +*.d +*.exe +*.coff +*.sym +*.map diff --git a/reactos/apps/tests/popupmenu/makefile b/reactos/apps/tests/popupmenu/makefile new file mode 100644 index 00000000000..3b162ac5bbc --- /dev/null +++ b/reactos/apps/tests/popupmenu/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2003/12/27 23:45:48 weiden Exp $ + +PATH_TO_TOP = ../../.. + +TARGET_NORC = no + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = popupmenu + +TARGET_SDKLIBS = kernel32.a gdi32.a user32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/reactos/apps/tests/popupmenu/popupmenu.c b/reactos/apps/tests/popupmenu/popupmenu.c new file mode 100644 index 00000000000..e6a33c2e4f5 --- /dev/null +++ b/reactos/apps/tests/popupmenu/popupmenu.c @@ -0,0 +1,102 @@ +#include +#include +#include +#include "resource.h" + +LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM); + +int WINAPI +WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) +{ + WNDCLASS wc; + MSG msg; + HWND hWnd; + + wc.lpszClassName = "MenuTestClass"; + wc.lpfnWndProc = MainWndProc; + wc.style = CS_VREDRAW | CS_HREDRAW; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wc.lpszMenuName = (LPCTSTR)IDM_MAINMENU; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + if (RegisterClass(&wc) == 0) + { + fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n", + GetLastError()); + return(1); + } + + hWnd = CreateWindow("MenuTestClass", + "PopupMenu Test", + WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 0, + 0, + CW_USEDEFAULT, + CW_USEDEFAULT, + NULL, + NULL, + hInstance, + NULL); + if (hWnd == NULL) + { + fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n", + GetLastError()); + return(1); + } + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return msg.wParam; +} + +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDM_EXIT: + PostQuitMessage(0); + break; + } + break; + } + case WM_RBUTTONUP: + { + POINT pos; + HMENU Menu; + + pos.x = LOWORD(lParam); + pos.y = HIWORD(lParam); + ClientToScreen(hWnd, &pos); + + if((Menu = GetMenu(hWnd)) && (Menu = GetSubMenu(Menu, 1))) + { + TrackPopupMenu(Menu, 0, pos.x, pos.y, 0, hWnd, NULL); + } + break; + } + case WM_DESTROY: + { + PostQuitMessage(0); + break; + } + default: + { + return DefWindowProc(hWnd, msg, wParam, lParam); + } + } + return 0; +} diff --git a/reactos/apps/tests/popupmenu/popupmenu.rc b/reactos/apps/tests/popupmenu/popupmenu.rc new file mode 100644 index 00000000000..9c4af8b0542 --- /dev/null +++ b/reactos/apps/tests/popupmenu/popupmenu.rc @@ -0,0 +1,47 @@ +#include +#include +#include "resource.h" + +IDM_MAINMENU MENU LOADONCALL MOVEABLE DISCARDABLE +{ + POPUP "&File" + { + MENUITEM "&New\tCtrl+N", 1 + MENUITEM "&Open\tCtrl+O", 2 + POPUP "Open &Recent" + { + MENUITEM "&1", 11 + MENUITEM "&2", 12 + MENUITEM "&3", 13 + MENUITEM "&4", 14 + MENUITEM "&5", 15 + MENUITEM "&6", 16 + MENUITEM "&7", 17 + MENUITEM "&8", 18 + MENUITEM "&9", 19 + } + MENUITEM SEPARATOR + MENUITEM "&Save\tCtrl+S", 3 + MENUITEM "Save &as...", 4 + MENUITEM SEPARATOR + MENUITEM "E&xit\tAlt-F4", IDM_EXIT + } + POPUP "&Edit" + { + MENUITEM "&Undo\tCtrl+Z", 20 + MENUITEM "&Redo\tShift+Ctrl+Z", 21 + MENUITEM SEPARATOR + MENUITEM "&Cut\tCtrl+X", 22 + MENUITEM "&Copy\tCtrl+C", 23 + MENUITEM "&Paste\tCtrl+V", 24 + MENUITEM SEPARATOR + MENUITEM "Select &all", 25 + MENUITEM "&Delete\tDel", 26 + } + POPUP "&Help" + { + MENUITEM "&Help Topics\tF1", 30 + MENUITEM SEPARATOR + MENUITEM "&About...", 31 + } +} diff --git a/reactos/apps/tests/popupmenu/resource.h b/reactos/apps/tests/popupmenu/resource.h new file mode 100644 index 00000000000..b4929dbf2d2 --- /dev/null +++ b/reactos/apps/tests/popupmenu/resource.h @@ -0,0 +1,2 @@ +#define IDM_MAINMENU 101 +#define IDM_EXIT 199