problem with win32 and directx

Started by
9 comments, last by vegolord 15 years, 1 month ago
hi to everybody im having a problem with the compilation(directx)....everything goes ok but the windows shows up for less than a secondon and i cant see anything...... im new with the directx programming can somebody help me thanks
Advertisement
What debugging have you done? Can you share your analysis and telemetary?

You're checking all HRESULT's? Can you execute the code without any Direct3D? What do the debug runtimes say? Can you step-through your code and determine exactly where it fails? What is the state of the application when it does?


hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

when i try to compile i have this error:

"Run-Time Check Failure #3 - The variable 'msg' is being used without being initialized."

this is the code when i get the error

" return (int)msg.wParam; "

and if i do " return 0 instead of return (int)msg.wParam" the windows appears for less than a second.

Do you even have a message loop?
this is the win32 without directx;


#include <windows.h>
/* Message handler prototype */
LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage,WPARAM wParam, LPARAM lParam);


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpCmdLine, int nShowCmd)
{
/* “The Window Class” */
TCHAR wintext[]= TEXT("my first");
TCHAR wintitle[]=TEXT("my windows");

WNDCLASS kWndClass;

MSG kMessage;

kWndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
kWndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
kWndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);

kWndClass.hInstance = hInstance;
kWndClass.lpfnWndProc = WndProc;
kWndClass.lpszClassName = TEXT("01 Basic Window");

kWndClass.lpszMenuName = NULL;

kWndClass.cbClsExtra = NULL;
kWndClass.cbWndExtra = NULL;
kWndClass.style = NULL;

if (!RegisterClass (&kWndClass))
{
return -1;
}

HWND hWindow;
hWindow = CreateWindow (wintext,
wintitle,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,
0,
320,
320,
NULL, NULL, hInstance, NULL);

ShowWindow(hWindow,nShowCmd);
UpdateWindow(hWindow);

return kMessage.wParam;


while (GetMessage (&kMessage, hWindow, 0, 0))
{
TranslateMessage (&kMessage);
DispatchMessage (&kMessage);
}

return 0;
}


LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage,WPARAM wParam, LPARAM lParam)
{
switch (iMessage)
{

case WM_CLOSE:
PostQuitMessage (0);
break;

default:
return DefWindowProc (hWindow, iMessage, wParam, lParam);
}
return 0;
}
Quote:Original post by vegolord
return kMessage.wParam;

This line seems to be the problem. The return statement will make your programm leave the main() function and it will end. Therefore you aren't even entering the messageloop and your window will show up only for a very short period. Try deleting this line and see if it works now.

i removed it but the debug is still running and nothing happens
Quote:Original post by vegolord
this is the code when i get the error

" return (int)msg.wParam; "
That line doesn't appear in the snippet you posted, you must've changed something.
the line is:

return kMessage.wParam;
Try to change this Code:

Quote:Original post by vegolord
HWND hWindow;
hWindow = CreateWindow (wintext,
wintitle,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,
0,
320,
320,
NULL, NULL, hInstance, NULL);

ShowWindow(hWindow,nShowCmd);
UpdateWindow(hWindow);

return kMessage.wParam;


To this:

HWND hWindow;hWindow = CreateWindow(kWndClass.lpszClassName,wintitle,WS_OVERLAPPEDWINDOW | WS_VISIBLE,0,0,320,320,NULL, NULL, hInstance, NULL);if(!ShowWindow(hWindow, SW_SHOW)){	return -1;}UpdateWindow(hWindow);


You have to pass the name of your window class to CreateWindow(), you've been passing an totally unrelated string to it.

This topic is closed to new replies.

Advertisement