|
-
Dec 6th, 2002, 08:05 AM
#1
Prob with showing last form after DX * resolved
I've finished running the main loop, and have set:
Call DD.RestoreDisplayMode
Call DD.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL)
Call objPerf.Stop(objSeg, objSegState, 0, 0)
But I'm having problems. My original intention was to get rid of the form for DDraw (it's in fullscreen mode), and load another form (EndOfStory) before I unload everything. Problem is the form for DDraw is still there, minimized to desktop since its not shown in taskbar, and it stays on top of my last form unless I click the last form. I've tried zOrder, Show, Hide, State = vbMinimize, and Refresh (for last form only), nothing works.
What did I do wrong?
Last edited by leinad31; Dec 6th, 2002 at 01:00 PM.
-
Dec 6th, 2002, 08:24 AM
#2
Have you tryed to unload it...or you could try to use FlipToGDISurface() function....look it up in the .doc file....
-
Dec 6th, 2002, 08:25 AM
#3
I think there is an example using it in the SDK, but I'm not sure if it is the DX7 or DX8 SDK....check it out...
-
Dec 6th, 2002, 08:36 AM
#4
I'm not sure what kind of code this is. But it might be C...so if you can read C...look at it...
Code:
void CMainFrame::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
if(!LoadBmp("ufo.bmp",pOff2))
{
TRACE("Load sky.bmp failed in OnPaint().");
return;
}
if(!LoadBmp("sky.bmp",pOff2_2))
{
TRACE("Load ufo.bmp failed in OnPaint().");
return;
}
CRect Rect(0,0,640,480);
if(FAILED(pBack->BltFast(0,0,pOff2_2,&Rect,
DDBLTFAST_NOCOLORKEY|DDBLTFAST_WAIT)))
{
TRACE("BltFast() sky failed in OnPaint().\n");
return;
}
Rect.SetRect(0,0,292,119);
if(FAILED(pBack->BltFast(0,0,pOff2,&Rect,
DDBLTFAST_SRCCOLORKEY|DDBLTFAST_WAIT)))
{
TRACE("BltFast() ufo failed in OnPaint().");
return;
}
if(FAILED( pDD2->FlipToGDISurface()))
{
TRACE("pPri2->FlipToGDISurface() failed. \n");
exit(1);
}
// Do not call CWnd::OnPaint() for painting messages
}
-
Dec 6th, 2002, 08:51 AM
#5
-
Dec 6th, 2002, 12:02 PM
#6
Thanks for the link. Gave me new ideas.
I tried anything else in the sample not in my code. But in the end, the solution was (surprise, surprise!!) setting visible to false.
Now all I have to worry about is the problem between keypreview and unloading forms.
-
Dec 6th, 2002, 12:04 PM
#7
What kind of problem...I can't see what you are meaning...anythng we can help you with....???
-
Dec 6th, 2002, 12:20 PM
#8
Well, as I explained, I'm done with the main form and showing the end of story form. Whenever I try to Unload the main form (keypreview set to true), vb says I have an error in my other form's keypress event (it highlights frmMain.Show) even though I unloaded them first. I saw a code earlier that unloads all forms even if you don't know their name exactly, I want to try that out first. Do you have the code?
-
Dec 6th, 2002, 12:25 PM
#9
I'm not sure...but if you have unloaded the form, and it then recives a keyevent and your code then says
form.show
that will make an error because you can't show a form that is not loaded....can this be the problem or do I not understand what you are mening...
BTW: No I don't have that code, but if you want to end the game, then you can write End
-
Dec 6th, 2002, 12:53 PM
#10
I was hoping to unload the program in the so called proper manner that doesn't leave objects in memory. Oh well, I guess I'll stick with End.
-
Dec 6th, 2002, 01:07 PM
#11
I'm not sure if you are correct there...
Unload statement:
Note When a form is unloaded, only the displayed component is unloaded. The code associated with the form module remains in memory.
End Statement:
Note The End statement stops code execution abruptly, without invoking the Unload, QueryUnload, or Terminate event, or any other Visual Basic code. Code you have placed in the Unload, QueryUnload, and Terminate events offorms andclass modules is not executed. Objects created from class modules are destroyed, files opened using the Open statement are closed, and memory used by your program is freed. Object references held by other programs are invalidated.
...but I can see what you mean by the propper manner....
-
Dec 6th, 2002, 01:34 PM
#12
Sorry, not much into proper terminology. But essentially the keypress/keydown code still runs and that's the problem. I don't want to go into creating a flag since I'm ending the program anyway and nothing critical is being done. Hopefully not much memory is wasted.
-
Dec 6th, 2002, 01:38 PM
#13
Don't be sorry...but can't you use a boolean that becomes false after unloading the form with the form.show line in the keydown event....and in that event use an if test to see if that variable is true before executing the line....I know this ain't a pretty thing to do...but I can't think of a bether idea without looking at all of the code...
-
Dec 7th, 2002, 06:31 AM
#14
BTW, didn't get to post last night. I tried the flag/boolean, but it seems that even if the statement is not executed as long as there is a reference of form.show in the code it crashes. Probably because the memory reference was already destroyed? (I'm guessing here but it seems logical).
I tried the flag at the start of the procedure and when that didn't work just before the statement, which also didn't work. At least I'll try to avoid, as much as possible next time, desiging a program next time that references another form from within a form.
-
Dec 7th, 2002, 06:53 AM
#15
Yes that would probably be the best...when dealing with DX there shouldn't be needed to show more then one form...you can change all the graphics in the form you already have in a new Sub or something...
-
Dec 7th, 2002, 08:30 AM
#16
Originally posted by leinad31
I saw a code earlier that unloads all forms even if you don't know their name exactly, I want to try that out first. Do you have the code?
Look what I tumbeled over...
VB Code:
Dim Fm As Form
For Each Fm In Forms
Unload Fm
Next
Set Fm = Nothing
-
Dec 7th, 2002, 01:54 PM
#17
I'll still run into the memory referencing problem but I think I can use that on instances of the forms so they'll end up as templates. Thanks NoteMe.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|