1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
#include <windows.h>
#include "resource.h"
//g_ = global
//sz_ = string zero I guess?
//forward declare toolbar id
HWND g_hToolbar = NULL;
//Register Window Class
const char g_sz_myClass [] = "window1";
//Toolbar Process >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
LRESULT CALLBACK ToolDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_PRESS:
MessageBox(hwnd, "This does nothing.", "NULL", MB_OK | MB_ICONINFORMATION);
break;
case IDC_OTHER:
MessageBox(hwnd, "This also does nothing", "NULL", MB_OK | MB_ICONINFORMATION);
break;
}
break;
}
case WM_CLOSE:{
ShowWindow(g_hToolbar, SW_HIDE);
//I tried SetActiveWindow and SetFocus here, with no result.
break;
}
default:
return FALSE;
}
return TRUE;
}
//Toolbar Process <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//Main Window Process >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_COMMAND:{
switch(LOWORD(wParam)){
// MenuBar Command >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
case ID_FILE_EXIT:{
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
}
//MenuBar Command <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//Toolbar Command >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
case ID_TOOLBAR_ON:
if(g_hToolbar == NULL){
g_hToolbar = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_TOOLBAR), hwnd, ToolDlgProc);
ShowWindow(g_hToolbar, SW_SHOW);
}
else{
ShowWindow(g_hToolbar, SW_SHOW);
}
break;
case ID_TOOLBAR_OFF:
ShowWindow(g_hToolbar, SW_HIDE);
break;
//Toolbar Command <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
break;
}
//Close Command >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
case WM_CLOSE:{
DestroyWindow(hwnd);
break;
case WM_DESTROY:
DestroyWindow(g_hToolbar);
PostQuitMessage (0);
break;
break;
}
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
//Close Command <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
return 0;
}
//Main Window Process <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//Main Window Register >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{
WNDCLASSEX test;
HWND hwnd;
MSG msg;
test.cbSize = sizeof (WNDCLASSEX);
test.style = 0;
test.lpfnWndProc = WndProc;
test.cbClsExtra = 0;
test.cbWndExtra = 0;
test.hInstance = hInstance;
test.hIcon = LoadIcon(NULL, IDI_APPLICATION);
test.hCursor = LoadCursor(NULL, IDC_ARROW);
test.hbrBackground = CreateSolidBrush(RGB(24, 15, 56));
test.lpszMenuName = MAKEINTRESOURCE(IDR_MENUBAR);
test.lpszClassName = g_sz_myClass;
test.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&test))
{
MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
//Create Window >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_sz_myClass,
"myWindowName",
WS_OVERLAPPEDWINDOW,
15, 15, 1200, 700,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Create Window <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
ShowWindow(hwnd, CmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//Main Window Register <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|