All pastes #273260 Raw Edit

Someone

public c v1 · immutable
·published 2006-12-09 19:36 UTC
rendered paste body
#ifndef UNICODE	#define UNICODE#endif#include <windows.h>HWND mainframe;LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);HWND CreateButton(LPCTSTR name, int x, int y, int w, int h, HWND parent);int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){	MSG msg; // MSG structure to store messages	WNDCLASSEX wcx; // WINDOW class information	HWND button, hOKButton;	// Initialize the struct to zero	ZeroMemory(&wcx,sizeof(WNDCLASSEX));	wcx.cbSize = sizeof(WNDCLASSEX); // Window size. Must always be sizeof(WNDCLASSEX)	wcx.style = CS_HREDRAW|CS_VREDRAW |CS_DBLCLKS ; // Class styles	wcx.lpfnWndProc = (WNDPROC)MainWndProc; // Pointer to the callback procedure	wcx.cbClsExtra = 0; // Extra byte to allocate following the wndclassex structure	wcx.cbWndExtra = 0; // Extra byte to allocate following an instance of the structure	wcx.hInstance = hInst; // Instance of the application	wcx.hIcon = NULL; // Class Icon	wcx.hCursor = LoadCursor(NULL, IDC_ARROW); // Class Cursor	wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW); // Background brush	wcx.lpszMenuName = NULL; // Menu resource	wcx.lpszClassName = TEXT("Lesson2"); // Name of this class	wcx.hIconSm = NULL; // Small icon for this class// Register this window class with MS-Windows	if (!RegisterClassEx(&wcx))		return 0;	mainframe = CreateWindowEx(0, //Extended window style			TEXT("Lesson2"), // Window class name			TEXT("Whatever"), // Window title			WS_OVERLAPPEDWINDOW, // Window style			CW_USEDEFAULT,CW_USEDEFAULT, // (x,y) pos of the window			CW_USEDEFAULT,CW_USEDEFAULT, // Width and height of the window			HWND_DESKTOP, // HWND of the parent window (can be null also)			NULL, // Handle to menu			hInst, // Handle to application instance			NULL); // Pointer to window creation data	if (mainframe)	{		printf("no");	}	button = CreateButton("Test", 1, 1, 500, 500, mainframe);	ShowWindow(mainframe, nCmdShow);	UpdateWindow(mainframe);	while (GetMessage(&msg,NULL,0,0))	{		TranslateMessage(&msg);		DispatchMessage(&msg);	}	return msg.wParam;}LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){	switch (msg)	{		case WM_DESTROY:			PostQuitMessage(0);			break;		default:			// Call the default window handler			return DefWindowProc(hwnd,msg,wParam,lParam);	}	return 0;}HWND CreateButton(LPCTSTR name, int x, int y, int w, int h, HWND parent){	return CreateWindow("BUTTON", name, WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, x, y, w, h, parent, NULL, (HINSTANCE)GetWindowLong(parent, GWL_HINSTANCE), NULL);}