Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem with my small window program with opengl graphic in it

Posted on 2001-06-19
5
221 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

829 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