problem with win32 and directx
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
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
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
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.
"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.
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;
}
#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.
Quote:Original post by vegolordThat line doesn't appear in the snippet you posted, you must've changed something.
this is the code when i get the error
" return (int)msg.wParam; "
Try to change this Code:
To this:
You have to pass the name of your window class to CreateWindow(), you've been passing an totally unrelated string to it.
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
Popular Topics
Advertisement