diff options
Diffstat (limited to 'source/tools/dummy_gui')
-rw-r--r-- | source/tools/dummy_gui/callbacks.c | 94 | ||||
-rw-r--r-- | source/tools/dummy_gui/callbacks.h | 12 | ||||
-rw-r--r-- | source/tools/dummy_gui/res/Application.ico | bin | 0 -> 23558 bytes | |||
-rw-r--r-- | source/tools/dummy_gui/res/Application.manifest | 16 | ||||
-rw-r--r-- | source/tools/dummy_gui/res/resource.rc | 73 | ||||
-rw-r--r-- | source/tools/dummy_gui/resource.h | 10 | ||||
-rw-r--r-- | source/tools/dummy_gui/winmain.c | 83 |
7 files changed, 288 insertions, 0 deletions
diff --git a/source/tools/dummy_gui/callbacks.c b/source/tools/dummy_gui/callbacks.c new file mode 100644 index 0000000..3bc40fd --- /dev/null +++ b/source/tools/dummy_gui/callbacks.c @@ -0,0 +1,94 @@ +#include "callbacks.h" +#include "resource.h" + +// Window procedure for our main window. +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static HINSTANCE hInstance; + + switch (msg) + { + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case ID_HELP_ABOUT: + { + DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hWnd, &AboutDialogProc); + return 0; + } + + case ID_FILE_EXIT: + { + DestroyWindow(hWnd); + return 0; + } + } + break; + } + + case WM_GETMINMAXINFO: + { + MINMAXINFO *minMax = (MINMAXINFO*) lParam; + minMax->ptMinTrackSize.x = 220; + minMax->ptMinTrackSize.y = 110; + + return 0; + } + + case WM_SYSCOMMAND: + { + switch (LOWORD(wParam)) + { + case ID_HELP_ABOUT: + { + DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hWnd, &AboutDialogProc); + return 0; + } + } + break; + } + + case WM_CREATE: + { + hInstance = ((LPCREATESTRUCT) lParam)->hInstance; + return 0; + } + + case WM_DESTROY: + { + PostQuitMessage(0); + return 0; + } + } + + return DefWindowProc(hWnd, msg, wParam, lParam); +} + + +// Dialog procedure for our "about" dialog. +INT_PTR CALLBACK AboutDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + (void)lParam; + switch (uMsg) + { + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + { + EndDialog(hwndDlg, (INT_PTR) LOWORD(wParam)); + return (INT_PTR) TRUE; + } + } + break; + } + + case WM_INITDIALOG: + return (INT_PTR) TRUE; + } + + return (INT_PTR) FALSE; +} diff --git a/source/tools/dummy_gui/callbacks.h b/source/tools/dummy_gui/callbacks.h new file mode 100644 index 0000000..7cc79c5 --- /dev/null +++ b/source/tools/dummy_gui/callbacks.h @@ -0,0 +1,12 @@ +#ifndef CALLBACKS_H +#define CALLBACKS_H + +#include <windows.h> + +// Window procedure for our main window. +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + +// Dialog procedure for our "about" dialog. +INT_PTR CALLBACK AboutDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + +#endif diff --git a/source/tools/dummy_gui/res/Application.ico b/source/tools/dummy_gui/res/Application.ico Binary files differnew file mode 100644 index 0000000..d551aa3 --- /dev/null +++ b/source/tools/dummy_gui/res/Application.ico diff --git a/source/tools/dummy_gui/res/Application.manifest b/source/tools/dummy_gui/res/Application.manifest new file mode 100644 index 0000000..d984135 --- /dev/null +++ b/source/tools/dummy_gui/res/Application.manifest @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> + +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> + <security> + <requestedPrivileges> + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> + </requestedPrivileges> + </security> + </trustInfo> + <dependency> + <dependentAssembly> + <assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/> + </dependentAssembly> + </dependency> +</assembly>
\ No newline at end of file diff --git a/source/tools/dummy_gui/res/resource.rc b/source/tools/dummy_gui/res/resource.rc new file mode 100644 index 0000000..489dd7a --- /dev/null +++ b/source/tools/dummy_gui/res/resource.rc @@ -0,0 +1,73 @@ +#include <windows.h> +#include "resource.h" + +// Win32 application icon. +IDI_APPICON ICON "Application.ico" + +// Our main menu. +IDR_MAINMENU MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", ID_FILE_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About", ID_HELP_ABOUT + END +END + +// Application manifest. +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "Application.manifest" + +// Executable version information. +VS_VERSION_INFO VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG | VS_FF_PRERELEASE +#else + FILEFLAGS 0 +#endif +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "CompanyName", "Transmission Zero" + VALUE "FileDescription", "Win32 Test application" + VALUE "FileVersion", "1.0.0.0" + VALUE "InternalName", "Win32App" + VALUE "LegalCopyright", "©2013 Transmission Zero" + VALUE "OriginalFilename", "Win32App.exe" + VALUE "ProductName", "Win32 Test application" + VALUE "ProductVersion", "1.0.0.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END +END + +// Our "about" dialog. +IDD_ABOUTDIALOG DIALOGEX 0, 0, 147, 67 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + ICON IDI_APPICON,IDC_STATIC,7,7,20,20 + LTEXT "Win32 Test application.",IDC_STATIC,34,7,86,8 + LTEXT "©2013 Transmission Zero",IDC_STATIC,34,17,86,8 + DEFPUSHBUTTON "OK",IDOK,90,46,50,14,WS_GROUP +END + +// Our accelerators. +IDR_ACCELERATOR ACCELERATORS +BEGIN + "A", ID_HELP_ABOUT, VIRTKEY, ALT, NOINVERT +END diff --git a/source/tools/dummy_gui/resource.h b/source/tools/dummy_gui/resource.h new file mode 100644 index 0000000..ccda0e7 --- /dev/null +++ b/source/tools/dummy_gui/resource.h @@ -0,0 +1,10 @@ +#define IDI_APPICON 101 +#define IDR_MAINMENU 102 +#define IDR_ACCELERATOR 103 +#define IDD_ABOUTDIALOG 104 +#define ID_FILE_EXIT 40001 +#define ID_HELP_ABOUT 40002 + +#ifndef IDC_STATIC + #define IDC_STATIC -1 +#endif diff --git a/source/tools/dummy_gui/winmain.c b/source/tools/dummy_gui/winmain.c new file mode 100644 index 0000000..e2de4ac --- /dev/null +++ b/source/tools/dummy_gui/winmain.c @@ -0,0 +1,83 @@ +#include <windows.h> +#include <commctrl.h> +#include "resource.h" +#include "callbacks.h" + +// Our application entry point. +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + INITCOMMONCONTROLSEX icc; + WNDCLASSEX wc; + LPCTSTR MainWndClass = TEXT("Win32 Test application"); + HWND hWnd; + HACCEL hAccelerators; + HMENU hSysMenu; + MSG msg; + + (void)hPrevInstance; + (void)lpCmdLine; + + // Initialise common controls. + icc.dwSize = sizeof(icc); + icc.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&icc); + + // Class for our main window. + wc.cbSize = sizeof(wc); + wc.style = 0; + wc.lpfnWndProc = &MainWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_APPICON), IMAGE_ICON, 0, 0, + LR_DEFAULTSIZE | LR_DEFAULTCOLOR | LR_SHARED); + wc.hCursor = (HCURSOR) LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED); + wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); + wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU); + wc.lpszClassName = MainWndClass; + wc.hIconSm = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_APPICON), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), + LR_DEFAULTCOLOR | LR_SHARED); + + // Register our window classes, or error. + if (! RegisterClassEx(&wc)) + { + MessageBox(NULL, TEXT("Error registering window class."), TEXT("Error"), MB_ICONERROR | MB_OK); + return 0; + } + + // Create instance of main window. + hWnd = CreateWindowEx(0, MainWndClass, MainWndClass, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, + 320, 200, NULL, NULL, hInstance, NULL); + + // Error if window creation failed. + if (! hWnd) + { + MessageBox(NULL, TEXT("Error creating main window."), TEXT("Error"), MB_ICONERROR | MB_OK); + return 0; + } + + // Load accelerators. + hAccelerators = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR)); + + // Add "about" to the system menu. + hSysMenu = GetSystemMenu(hWnd, FALSE); + InsertMenu(hSysMenu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + InsertMenu(hSysMenu, 6, MF_BYPOSITION, ID_HELP_ABOUT, TEXT("About")); + + // Show window and force a paint. + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + // Main message loop. + while(GetMessage(&msg, NULL, 0, 0) > 0) + { + if (! TranslateAccelerator(msg.hwnd, hAccelerators, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return (int) msg.wParam; +} |