Code:
// Admin2.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "Admin2.h"
#define MAX_LOADSTRING 100
#define TOGGABLE_KEYS 10002
#define IDT_TIMER WM_USER + 200
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HWND hWnd = CreateWindow(WC_DIALOG,(LPCWSTR)L"", WS_VISIBLE|WS_OVERLAPPEDWINDOW, 400,100,100,80,NULL,NULL,NULL,NULL);
HWND static_label = CreateWindow((LPCWSTR)L"Static", (LPCWSTR)L"", WS_CHILD | WS_VISIBLE, 0, 0, 200, 25, hWnd,(HMENU)-1, NULL, NULL );
HWND myButton = CreateWindow((LPCWSTR)L"BUTTON", (LPCWSTR)L"OK", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 0, 0 , 105, 50, hWnd, (HMENU)ID_BUTTON1, NULL, NULL );
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
// UNREFERENCED_PARAMETER(hPrevInstance);
// UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
// LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_ADMIN2, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_ADMIN2));
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ADMIN2));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_ADMIN2);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
hInst = hInstance; // Store instance handle in our global variable
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, SW_FORCEMINIMIZE);
UpdateWindow(hWnd);
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_INITDIALOG:
//** Set timers
SetTimer(hWnd, TOGGABLE_KEYS, 1, NULL);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_EXIT:
DestroyWindow(hWnd);
break;
case ID_BUTTON1:
{
MessageBox(0, (LPCWSTR)L"Testing...", (LPCWSTR)L"Information", MB_OK);
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_TIMER:
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}