Free Q2 Map Viewer
Click here to go to the Q2View program





Source code for

Group Boxes

Listing of resource.h

#define IDI_ICON 101 #define IDB_RADIO1 102 #define IDB_RADIO2 103

Listing of resource.rc

#include "resource.h" IDI_ICON ICON "icon.ico"

Listing of main.cpp

// Win32 Tutorial (Group Boxes) // Alan Baylis 2004 #include <windows.h> #include "resource.h" const char ClassName[] = "MainWindowClass"; HWND hWndButton1; HWND hWndButton2; LRESULT CALLBACK WndProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ) { switch (Msg) { case WM_CREATE: { HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); HWND hWndGroupbox = CreateWindowEx( 0, "BUTTON", "Group Box", WS_VISIBLE | WS_CHILD | BS_GROUPBOX, 5, 5, 90, 70, hWnd, NULL, hInstance, NULL); hWndButton1 = CreateWindowEx( 0, "BUTTON", "Button 1", WS_VISIBLE | WS_CHILD | WS_GROUP | BS_AUTORADIOBUTTON, 10, 30, 80, 20, hWnd, (HMENU)IDB_RADIO1, hInstance, NULL); hWndButton2 = CreateWindowEx( 0, "BUTTON", "Button 2", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON, 10, 50, 80, 20, hWnd, (HMENU)IDB_RADIO2, hInstance, NULL); } break; case WM_CLOSE: DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return (DefWindowProc(hWnd, Msg, wParam, lParam)); } return 0; } INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow ) { WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); wc.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszMenuName = NULL; wc.lpszClassName = ClassName; if (!RegisterClassEx(&wc)) { MessageBox(NULL, "Failed To Register The Window Class.", "Error", MB_OK | MB_ICONERROR); return 0; } HWND hWnd; hWnd = CreateWindowEx( WS_EX_CLIENTEDGE, ClassName, "Group Boxes", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 200, 120, NULL, NULL, hInstance, NULL); if (!hWnd) { MessageBox(NULL, "Window Creation Failed.", "Error", MB_OK | MB_ICONERROR); return 0; } ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); MSG Msg; while (GetMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }


Copyright © 1998 - 2010 Alan Baylis, All Rights Reserved