Current date:
Welcome Guest
...
Untitled
/* Generated using Yuraj's Win32 Designer */
#include <windows.h>

HINSTANCE hInstance;
HWND hParent;
const char sWindowClass[] = "myWindowClass";

void InitWindow();

//Control handles
HWND hButton1;
HWND hTextBox1;
//

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
 switch(msg)
 {
 case WM_COMMAND:
 //TODO: Commands here
 if ((HWND)lParam == hButton1)
 {
 MessageBoxA(hParent, "Button Clicked", "hButton1", MB_OK);
 }

 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;
 MSG Msg;

 wc.cbSize = sizeof(WNDCLASSEX);
 wc.style = 0;
 wc.lpfnWndProc = WndProc;
 wc.cbClsExtra = 0;
 wc.cbWndExtra = 0;
 wc.hInstance = hInstance;
 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
 wc.lpszMenuName = NULL;
 wc.lpszClassName = sWindowClass;
 wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

 if(!RegisterClassEx(&wc))
 {
 MessageBox(NULL, "Window Registration Failed!", "Error!",
 MB_ICONEXCLAMATION | MB_OK);
 return 0;
 }

 hParent = CreateWindowEx(
 WS_TILED,
 sWindowClass,
 "My window",
 WS_CAPTION | WS_SYSMENU,
 CW_USEDEFAULT, CW_USEDEFAULT, 290, 290,
 NULL, NULL, hInstance, NULL);

 if(hParent == NULL)
 {
 MessageBox(NULL, "Window Creation Failed!", "Error!",
 MB_ICONEXCLAMATION | MB_OK);
 return 0;
 }

 hInstance = hInstance;

 InitWindow();

 ShowWindow(hParent, nCmdShow);
 UpdateWindow(hParent);

 while(GetMessage(&Msg, NULL, 0, 0) > 0)
 {
 DispatchMessage(&Msg);
 TranslateMessage(&Msg);
 }

 return Msg.wParam;
}

////////////////////////////////////////////////////////////////
// Init. window
////////////////////////////////////////////////////////////////

void InitWindow()
{
 //Controls initialization
 hButton1 = CreateWindowEx(0,"BUTTON","Click Here!",
 WS_CHILD | WS_VISIBLE,
 91,223,92,29,
 hParent, NULL, hInstance, NULL);

 hTextBox1 = CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
 WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL,
 15,15,256,184,
 hParent, NULL, hInstance, NULL);


 //Setting default font controls
 HFONT hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
 SendMessage(hButton1, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
 SendMessage(hTextBox1, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));

}


This page has been moved. If you are not redirected within 5 seconds, click here.