|
From: Daniel G. <sp...@ho...> - 2001-10-17 20:27:55
|
<html><div style='background-color:'><DIV>
<P>I got into it via Andre LaMothe's Windows game programming for dummies.</P>
<P>Here's a basic window. Try to play with it and see how it works. There are loads of flags etc. that I can't mention here, so get a book lol.</P>
<P>Remember to build a win32 project!!!</P>
<P>If it doesn;t work check the libraries.</P>
<P> </P>
<P>//PP - A complete windows program</P>
<P>// INCLUDES ///////////////////////////////////////////////<BR>#define WIN32_LEAN_AND_MEAN </P>
<P>#include <windows.h> <BR>#include <windowsx.h><BR>#include <stdio.h><BR>#include <math.h></P>
<P>// DEFINES ////////////////////////////////////////////////</P>
<P>// defines for windows <BR>#define WINDOW_CLASS_NAME "WINCLASS1"</P>
<P>// GLOBALS ////////////////////////////////////////////////<BR>HWND main_window_handle = NULL; // save the window handle</P>
<P>// FUNCTIONS //////////////////////////////////////////////<BR>LRESULT CALLBACK WindowProc(HWND hwnd, <BR> UINT msg, <BR> WPARAM wparam, <BR> LPARAM lparam)<BR>{<BR>// this is the main message handler of the system<BR>PAINTSTRUCT ps; // used in WM_PAINT<BR>HDC hdc; // handle to a device context</P>
<P>// what is the message <BR>switch(msg)<BR> { <BR> case WM_CREATE: <BR> {<BR> // do initialization stuff here<BR> return(0);<BR> } break;</P>
<P> case WM_PAINT: <BR> {<BR> // simply validate the window<BR> hdc = BeginPaint(hwnd,&ps); <BR> EndPaint(hwnd,&ps);<BR> return(0);<BR> } break;</P>
<P> case WM_DESTROY: <BR> {<BR> // kill the application <BR> PostQuitMessage(0);<BR> return(0);<BR> } break;</P>
<P> default:break;</P>
<P> } // end switch</P>
<P>// process any messages that we didn't take care of <BR>return (DefWindowProc(hwnd, msg, wparam, lparam));</P>
<P>} // end WinProc</P>
<P>// WINMAIN ////////////////////////////////////////////////<BR>int WINAPI WinMain( HINSTANCE hinstance,<BR> HINSTANCE hprevinstance,<BR> LPSTR lpcmdline,<BR> int ncmdshow)<BR>{</P>
<P>WNDCLASS winclass; // this will hold the class we create<BR>HWND hwnd; // generic window handle<BR>MSG msg; // generic message</P>
<P>// first fill in the window class stucture<BR>winclass.style = CS_DBLCLKS | CS_OWNDC | <BR> CS_HREDRAW | CS_VREDRAW;<BR>winclass.lpfnWndProc = WindowProc;<BR>winclass.cbClsExtra = 0;<BR>winclass.cbWndExtra = 0;<BR>winclass.hInstance = hinstance;<BR>winclass.hIcon = LoadIcon(NULL, IDI_HAND);<BR>winclass.hCursor = LoadCursor(NULL, IDC_IBEAM);<BR>winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);<BR>winclass.lpszMenuName = NULL;<BR>winclass.lpszClassName = WINDOW_CLASS_NAME;</P>
<P>// register the window class<BR>if (!RegisterClass(&winclass))<BR> return(0);</P>
<P>// create the window<BR>if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class<BR> "Dan's Window", // title<BR> WS_OVERLAPPEDWINDOW | WS_VISIBLE,<BR> 6,99, // x,y<BR> 540,200, // width, height<BR> NULL, // handle to parent <BR> NULL, // handle to menu<BR> hinstance,// instance<BR> NULL))) // creation parms<BR>return(0);</P>
<P>// save the window handle in a global<BR>main_window_handle = hwnd;</P>
<P>// enter main event loop<BR>while(1)<BR> {<BR> if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))<BR> { <BR> // test if this is a quit<BR> if (msg.message == WM_QUIT)<BR> break;<BR> <BR> // translate any accelerator keys<BR> TranslateMessage(&msg);</P>
<P> // send the message to the window proc<BR> DispatchMessage(&msg);<BR> } // end if<BR> <BR> // main game processing goes here<BR> <BR> } // end while</P>
<P>// return to Windows like this<BR>return(msg.wParam);</P>
<P>} // end WinMain</P>
<P>///////////////////////////////////////////////////////////</P>
<P> </P>
<P><BR><BR> </P></DIV>
<DIV></DIV>
<DIV></DIV>>From: mi...@ju...
<DIV></DIV>>To: dev...@li...
<DIV></DIV>>Subject: [Dev-C++] Windows programming
<DIV></DIV>>Date: Wed, 17 Oct 2001 15:24:05 -0400
<DIV></DIV>>
<DIV></DIV>>I've been programming C++ for a while now, but I've always been making
<DIV></DIV>>console applications. Using Dev C++ has really gotten me interested in
<DIV></DIV>>making windows applications. Does anyone know about tutorials for C++
<DIV></DIV>>Windows programming? Is it worth it to try to do this?
<DIV></DIV>>________________________________________________________________
<DIV></DIV>>GET INTERNET ACCESS FROM JUNO!
<DIV></DIV>>Juno offers FREE or PREMIUM Internet access for less!
<DIV></DIV>>Join Juno today! For your FREE software, visit:
<DIV></DIV>>http://dl.www.juno.com/get/web/.
<DIV></DIV>>
<DIV></DIV>>_______________________________________________
<DIV></DIV>>Dev-cpp-users mailing list
<DIV></DIV>>Dev...@li...
<DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html>
|