Sign in to follow this  
brandonman

hm...

Recommended Posts

just got a directx book today and tried the first window code. i needed to include windows.h and my visual C++ express or whatever it's called doesn't have windows.h. I tred in dev C++ and keep getting macro `CreateWindowA' used with only 10 args here's the code: I get this on all my things outta books: //include windows header file that's needed for all windows applications #include <windows.h> HINSTANCE hInst; //global variable to handle application instance HWND wndHandle; //global variable to hold the window handle //foreward declaration bool initwindow( HINSTANCE hInstance ); LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); //this is winmain, main entry point int WINAPI WinMain( HINSTANCE hInstance, HISTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ); { //initialize the window if ( !initWindow( hInstance ) ); return false; //main message loop; Msg msg; ZeroMemory( &msg, sizeof( msg ) ) ; while( msg.message!=WM_QUIT ) { //check message queue while (GetMessage(&msg, windHandle, 0, 0) ); { TranslateMessage( &msg ); DispatchMessage( &msg ); } } return (int) msg.wParam; } /************************************************** * bool initWindow( HINSTANCE hInstance ) * initWindow registers the window class for the application, creates window ***************************************************/ bool initWindow( HINSTANCE hInstance ) { WNDCLASSEX wcex; //fill in wndclassex structure...describes how window will look wcex.cbSice = sizeof(WINDCLASSEX); //size of the structure wcex.style = CS_HREDRAW | CS_VREDRAW; //class style wcex.lpfnWndProc = (WNDPROC)WndProc; //window procedure callback wcex.cbClsExtra = 0; //extra bytes to allocate for this class wcex.cbWndExtra = 0; //extra bytes to allocate for this instance wcex.hInstance = hInstance; //handle to the application instance wcex.hIcon = LoadCursor(NULL, IDC_ARROW); //default cursor wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); //background color wcex.lpszMenuName = NULL; //resource name for menu wcex.lpszClassName = "DirectXExample"; //class name being created wcex.hIconSM = 0; //handle to the small icon RegisterClassEx(&wcex); //create the window wndHandle = CreateWindow( "DirectXExample", //window class to use "DirectXExample", //title bar text WS_OVERLAPPEDWINDOW, //window style CW_USEDEFAULT, //starting x coordinate CW_USEDEFAULT, //starting y coordinate 640, //pixel width of the window 480 //pixel height of the window NULL, //parent window;NULL for desktop NULL, //menu for the application, null for none hInstance, //handle to application instance NULL); //no values passed to window //make sure window handle created is valid if (!wndHandle) return false; //display window on screen ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; } /************************************************** * LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, * LPARAM lparam) *window procedure **************************************************/ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { //check any available messages from the queue switch (message) { case WM_DESTROY; PostQuitMessage; break; } //always return the message to default window //procedure for further processing return DefWindowProc(hWnd, message, wParam, lParam; }

Share this post


Link to post
Share on other sites
The Visual Studio C++ Express is a great editor but it doesn't include the Windows SDK. <windows.h> and other needed headers are in the SDK:

http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this