Sign in to follow this  

DirectX

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Trying my first DX program. Just creating a window. I'm using VC++. Everything compiles but when I try to run the executable i get an error from windows: The instruction at "0x77e12660" referenced memory at "-xcccccccc". The memory could not be "read". Click on OK to terminate the program Click on CANCEL to debug the program ************************************************ //Here's the source code // Code taken from "Beginning DirectX9: Chapter 2 #include <windows.h> HINSTANCE hInst; HWND wndHandle; bool initWindow( HINSTANCE hInstance); LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { if (!initWindow( hInstance)) return false; MSG msg; ZeroMemory (&msg, sizeof(msg)); while (msg.message!=WM_QUIT ) { while (GetMessage(&msg, wndHandle, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; } bool initWindow( HINSTANCE hInstance ) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.hIconSm = 0; RegisterClassEx(&wcex); wndHandle = CreateWindow( "DirectXExample", "DirectXExample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL); if(!wndHandle) return false; ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; } LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); }

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You haven't initialised the lpszClassName member of the WNDCLASSEX structure - it needs to be set to the same class name that you use to create the window with in the CreteWindow() call.

Share this post


Link to post
Share on other sites

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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