Need some help(Newbie)with dx7a

Started by
4 comments, last by Jaxks 24 years, 1 month ago
I have a DirectDraw7A problem here is a source i tried to fix it but I can´t get the program run because everytime when I run it ddraw.dll falls.Is it because I haven´t done yet exit commands.I use VC6 Introductory with DX7ASDK // kursori.cpp : Defines the entry point for the application. // #include "stdafx.h" // GLOBAALIT LPDIRECTDRAW7 lpdd7=NULL; LPDIRECTINPUT7 lpdi7=NULL; //Funktiot BOOL InitDirectX(HWND *hwnd,HINSTANCE *hInstance) { HRESULT DxResult; DxResult=DirectDrawCreateEx(NULL,(VOID **)lpdd7,IID_IDirectDraw7,NULL); if(DxResult!=DD_OK) { MessageBox(*hwnd,"Ei voi initalisoida DirectDrawia",NULL,MB_OK); } DxResult=lpdd7->SetCooperativeLevel(*hwnd,DDSCL_EXCLUSIVE/DDSCL_FULLSCREEN); if(FAILED(DxResult)) return(FALSE); DxResult=lpdd7->SetDisplayMode(800,600,8,0,NULL); if(FAILED(DxResult)) return(FALSE); DxResult=DirectInputCreateEx(*hInstance,DIRECTINPUT_VERSION,IID_IDirectInput7,(VOID **)lpdi7,NULL); if(DxResult!=DI_OK) { MessageBox(*hwnd,"Ei voi initiliasoida DirectInputia",NULL,MB_OK); } return(1); } LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { PAINTSTRUCT ps; HDC hdc; switch(msg) { case WM_CREATE: { return(0); }break; case WM_QUIT: { PostQuitMessage(0); return(0); }break; case WM_PAINT: { hdc=BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); return(0); }break; default:break; } return (DefWindowProc( hwnd, msg,wparam,lparam)); } BOOL InitWindowsStuf(HINSTANCE *hinst,HWND *hwnd,int *show) { WNDCLASS wc; wc.cbClsExtra=NULL; wc.cbWndExtra=NULL; wc.hbrBackground=static_cast(GetStockObject(BLACK_BRUSH)); wc.hCursor=LoadCursor(*hinst,IDC_ARROW); wc.hIcon=LoadIcon(*hinst,IDI_APPLICATION); wc.hInstance=*hinst; wc.lpfnWndProc= WindowProc; wc.lpszClassName="DX Application"; wc.lpszMenuName=NULL; wc.style=CS_HREDRAW/CS_VREDRAW; if(!RegisterClass(&wc)) return(0); if(*hwnd!=CreateWindowEx(NULL,"DX Application","Demo",WS_VISIBLE/WS_POPUP,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,*hinst,NULL)) return(0); return(1); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG msg; InitWindowsStuf(&hInstance,&hwnd,&nCmdShow); InitDirectX(&hwnd,&hInstance); while(1) { if(PeekMessage(&msg,hwnd,0,0,PM_REMOVE)) { if(msg.message==WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } } lpdd7->Release(); lpdi7->Release(); return msg.wParam; }
Advertisement
where is your program having trouble, exactly? There are a few places where things look a bit odd, but that could just be your method of passing your hInstance and hWnd's as pointers. (The dereferencing looks foreign to me, I guess.)

--majority of my original message deleted 'cause I can't read =)--

good luck!



*oof*

Edited by - Oofnish on 3/13/00 1:41:03 PM
*oof*
I red your post Oofinish as I said I can start the program progran even Set´s display mode but then comes error box
program has done illegal operation(BLAA BLAA) expection in module ddraw.dll.BTW passsing Window handle and instance as pointers worked in normal windowsprogram but I try to to what you said and Code(If you mean by referance)is my self done with both SdK helps(DX & win);
Yeah I get step forward now isn´t dll error my screen turns blue.I´m gonna switch off dinput.I also changed InitDirectx funtion and now it has now pointer parameters
Looking at the code as posted...

Problem #1:

In the lines where you create a window and Set DDraw''s Cooperative level, there''s a ''/'' where there should be a "/". Is GameDev''s message board translating that wrong? If your code as it stands on your machine actually has ''/'' in these lines:

DxResult=lpdd7->SetCooperativeLevel(*hwnd,DDSCL_EXCLUSIVE/DDSCL_FULLSCREEN);

if(*hwnd!=CreateWindowEx(NULL,"DX Application","Demo",WS_VISIBLE/WS_POPUP,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,*hinst,NULL))

Change it to ''/''! You are dividing the options rather than combining them, which is perfectly C-legal (compiler won''t complain) but not at all what you want. The CreateWindow will fail if the code is as it appears here, and everything else will cascade-fail or just do Something Bad.

Problem #2:

DxResult=DirectDrawCreateEx(NULL,(VOID **)lpdd7,IID_IDirectDraw7,NULL);

Should be:

DxResult=DirectDrawCreateEx(NULL,(VOID **)&lpdd7,IID_IDirectDraw7,NULL);

Problem #3:

Same as problem #2, but for DirectInput rather than ddraw.

Messageboard translates marks wrong I´ll when i get home thanks from all your help

This topic is closed to new replies.

Advertisement