#include "stdafx.h"
HINSTANCE hInst;
HWND Main_Window_Hwnd;
HWND Button_Hwnd;
HWND Listbox_Hwnd;
HWND Edit_Hwnd;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,int nCmdShow)
{
hInst = hInstance;
MSG msg;
WNDCLASSEX wcex;
ZeroMemory(&wcex,sizeof(wcex));
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszClassName = "this is what you name your window class";
if (RegisterClassEx(&wcex)==NULL)
{
MessageBox(NULL,"Window failed to register","Error",MB_OK);
}
Main_Window_Hwnd = CreateWindow("this is what you name your window class",
"the title",
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
Button_Hwnd = CreateWindow("button", "pwn3dddddd", WS_CHILD | WS_BORDER
| WS_VISIBLE,100, 100, 100,
50,Main_Window_Hwnd,NULL, hInst, NULL);
Listbox_Hwnd = CreateWindow("listbox", "pwnt", WS_CHILD | WS_BORDER |
WS_VISIBLE,500, 300, 200,
200,Main_Window_Hwnd,NULL, hInst, NULL);
Button_Hwnd = CreateWindow("edit", "got pwned?", WS_CHILD | WS_BORDER |
WS_VISIBLE,500, 100, 100,
20,Main_Window_Hwnd,NULL, hInst, NULL);
ShowWindow(Main_Window_Hwnd,SW_SHOW);
if (Main_Window_Hwnd == NULL)
{
MessageBox(NULL,"Failed to create window","Error",MB_OK);
}
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
/*
This could fail to compile for the following reasons:
1. You must create a win 32 application NOT a win 32 console application
2. You recieve the error "cannot convert from 'const char [40]' to
'LPCWSTR'1> Types pointed to are unrelated; conversion requires reinterpret_cast,
C-style cast or function-style cast"
This problem has 2 solutions: First you can go to
Project-->[project name] properties-->Configuration Properties-->General
and change character set to 'not set' instead of unicode character set.
The second solution is typing a capital l in front of all string literals like this
' L"this is a string" '.
3. Can't find file stfafx.h. stdafx.h is a precompiled header file that
includes the important files used in windows applications. One should be
created for you when you start a win32 application. If itis not just google
stdafx.h and you should find some information.
*/