Solved

Problem with my small window program with opengl graphic in it

Posted on 2001-06-19
5
196 Views
Last Modified: 2006-11-17
I wrote a windowing class in C++ to create windows.  I'm a newbie to C++ and Windows programming.  The
small program I wrote uses the windowing class to create a window and put an opengl cube in it.

My problem is this: Every once in a while, the program doesn't shutdown properly (remains in task list).
 This could be due to one of 2 things as far as I can tell:

1)  My code sucks
2)  I added the ability to toggle from fullscreen to windowed mode (and vice versa).  Using SetWindowLong,
I give the window a new style.  I'm thinking that maybe this changes the hWnd, so because I can't/don't
update the device context and rendering contexts, when it comes time to shutdown and I call like ReleaseDC(hWnd,
hDC), it might not work properly.

I've been posting this in a few OpenGL forum but they aren't much help.    

I've posted my source at:

http://members.home.net/l-reynolds/myCode.zip

I wrote the code using VC++ 6.

Any help and/or suggestions, code modifications(even unrelated to my current problem) or whatever can
be sent to l-reynolds@home.com as well as posted here.

Thanks in advance...
0
Comment
Question by:Sketchy
  • 3
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 300 total points
ID: 6209098
this solved the problem

case WM_KILLFOCUS:
{
     //WaitMessage();  // comment this one
     return(0);
}

try it out and tell me
0
 

Author Comment

by:Sketchy
ID: 6209124
What sucks is that its really hard to tell when the problem is there or not.  

I thought WaitMessage might be the problem, so I commented it out earlier, and I didn't get any crashes.  So I uncommented it to see if then I would get a crash, but I still didn't.  For the life of me I couldn't get it to crash.

One other thing I noticed is that if you are in windowed mode and you move the mouse onto the title bar, like back and forth over the icons in the top right, then after a while the cube will stutter in its motion (like it lagged or something), just one time.  I thought that was pretty weird.  It should maintain a fluid continuous rotation.    
0
 

Author Comment

by:Sketchy
ID: 6209128
oh BTW why do you think that the waitmessage is the problem?  Is it being called right before the destruction of the window or something?

But if that were the case, wouldn't it happen every time?

 
0
 

Author Comment

by:Sketchy
ID: 6209136
Ok I'm halfa$$ retarded.  The stuttering I mentioned happens because I have the cursor over the MINIMIZE button, and the little textbox is popping up and lagging it for a second.  It has nothing to do with my code problems...
0
 
LVL 22

Expert Comment

by:ambience
ID: 6212838
hmm .... wont your code get stuck at WaitMessage because it executes at KillFocus , the last killfocus(one due to window closing) would cause the app to wait for another message to come , which wouldn't come normaly .... however while debugging there is no such problem which i think is because of minimizing the app and bringing the debugger infront...

i maybe wrong , correct me if i am wrong ...
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now