Dan Kegel
unread,Jun 16, 2012, 5:03:51 PM6/16/12You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
What is the absolute simplest win32 program that draws a line in a window?
I tried
#include <windows.h>
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nShowCmd)
{
MSG msg;
HWND hwnd;
HDC hdc;
RECT rect;
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = hinst;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszClassName = "Foobar";
RegisterClass(&wc);
hwnd = CreateWindow(
"Foobar",
"Foobar",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
512, 512,
NULL,
NULL,
hinst,
0);
hdc = GetDC(hwnd);
GetClientRect(hwnd, &rect);
FillRect(hdc, &rect, (HBRUSH) (COLOR_WINDOW+1));
MoveToEx(hdc, 100, 100, NULL);
LineTo(hdc, 200, 200);
ReleaseDC(hwnd, hdc);
ShowWindow(hwnd, nShowCmd);
Sleep(5000);
return 0;
}
but the window was not shown. Is the problem that I
don't have a window proc? I was hoping I could just
draw immediately without having to use the event system.
Thanks,
Dan