Hexboy
Dec 31 2003, 02:18 PM
A ANSI C compatable win32 program. I'm posting this so you other coders out ther have a clean (C..ANSI C) skeleton to get an idea off of. Compiled with lcc. Cheers.
wincode.c CODE /* clean.c A ANSI C compatable win32 program. -Dexter Haslem(12/31/03) */ #define WIN32_LEAN_AND_MEAN #include <windows.h> long CALLBACK WndProc( HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT PaintStruct; HDC hDC; switch( uMessage ) { case WM_CREATE: { /* CreateWindow() was called */ return 0; } case WM_PAINT: { hDC = BeginPaint( hWnd, &PaintStruct ); /* GDI Drawing here */ Rectangle(hDC, 10,10,100,100); EndPaint( hWnd, &PaintStruct ); return 0; } case WM_DESTROY: { PostQuitMessage( 0 ); return 0; } default: { return DefWindowProc( hWnd, uMessage, wParam, lParam ); } }/* switch */ } /*WndProc*/ /* for some reason, i forgot CreateWindowEx params, so this prevents LCC from bitching about passing NULL for the first param. HACK */ unsigned long nothing = 1; int WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd,int iCmd) { HWND hWnd; MSG msg; WNDCLASSEX wc; static char strAppName[] = "Clean C Window"; /*Fill in the window class attributes */ wc.cbSize = sizeof( WNDCLASSEX ); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.lpfnWndProc = WndProc; wc.hInstance = hInst; wc.hbrBackground= (HBRUSH)GetStockObject( DKGRAY_BRUSH ); wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hIconSm = LoadIcon( NULL, IDI_HAND ); wc.hCursor = LoadCursor( NULL, IDC_CROSS ); wc.lpszMenuName = NULL; wc.lpszClassName= strAppName; RegisterClassEx( &wc ); hWnd = CreateWindowEx( nothing, strAppName, strAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 512,512, NULL, NULL, hInst, NULL ); ShowWindow( hWnd, iCmd ); UpdateWindow( hWnd ); /* message loop */ while( GetMessage( &msg, NULL,0,0 ) ) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
Hexboy
Dec 31 2003, 02:19 PM
posting totally raped my beautiful tabbing :/
Hexboy
Dec 31 2003, 08:07 PM
D'oh, what the (filtered) was I thinking earlier - instead of having
CODE unsigned long nothing = 1;
I could have just passed a 0 to CreateWindowEx. Oh well, brainfart
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here .