Jump to content
  • Advertisement
Sign in to follow this  
vegolord

problem with win32 and directx

This topic is 3474 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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!