Hello everybody, I come directly to the point. I want to make a simple game that starts with a DialogBox(using MFC probably?) and then the user can choose between windowed mode and fullscreen(graphics) mode so I could use the OpenGL libraries.The problem is that I can't figure out how to create the fullscreen mode after the user pushes the coresponding button.Do I have to use any API functions or MFC?
Getting the basics done won't be too hard, but handling some more complex actions will be (I'll explain that in a minute). To create a full-screen window, you will need to create a window type that grabs the whole screen instead of the client area. You can look at some of the screen saver examples on this site for that, or look at some of the OpenGL and/or DirectX examples all over the internet.
The tricky part is going to be handling things like Alt-Tab (which means a loss/restore of the screen device and all input devices).
Instead of showing the dialog, you could approach it the way that most games do these days and allow for a command line switch (if you use the DirectX helper classes, this is built in for you). I'm not sure if the OpenGL libraries give that to you for free, but I've seen a number of samples that allow for it, so at the very least, it wouldn't be too difficult to find a solution for it.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
working on a dialog based application, where the entire registry is scaneed for errors, For Registry using SDK functions ( RegOpenKey(), RegEnumKey( ) etc.)
Now what my problem is:
while scanning is going on ( there is a button "STOP" on the dialog)
if user press or click on the STOP button then the the scanning of Registry should be stopped and a messagebox should appear for resume or exit operation.
I think problem would be clear...
So please suggest me the scenario to implement this and better if provide some code snippet for the same.
Start the scanning of the resgistry in a separate thread that runs an "infinite loop". This loop can be finished either when the scan is complete or when a variable is set to false. Something like that (pseudo-code):
// Process next keyif (LastKey == true)
bContinue = false;
This variable can be set through the main thread but you have to make it thread safe (for example use a critical section). If you are new to thread, I suggest you read some documentation about that because it can be difficult for a beginner.
First, I would like to recommend instead a message box, two buttons "Pause" and "Stop" in your main dialog.
Perform the registry scanning in a worker thread. When press "Pause", call SuspendThread dunction in order to suspend registry scanning and change the button caption from "Pause" to "Resume". When the user press "Resume", call ResumeThread to start scanning again.
When the user press "Stop" you can call TerminateThread.
I prefer using a loop that you can fully control instead of killing the thread with terminate thread. The reason is if you want to make some 'clean-up' after the loop (ok, maybe infinite loop was not the right word but I meant a loop that finishes when one of the condition is met).
First when say "maybe infinite loop was not the right" because registry is a finite stuff and sooner or later its scanning have to finish, regardless the user pushes "Stop" or not.
Second, indeed for the sake of good recommendations we have to avoid TerminateThread, which in our case can let a registry key open for reading which can lead in unpredictable, catastrophic effects.
Using SuspendThread() and TerminateThread() is very risky, and not nearly as simple as you've described here. Before a thread suspends itself, it needs to ensure that by being suspended, the calling thread is not affected. If a synchronization object is being held by the thread, it would need to be released. Suspending a thread from another, without taking all of the precautions, is not a good idea because the thread being suspended might be in the middle of something important (e.g., memory allocation). This could result in your application entering a "hung" state. If a thread calls TerminateThread() on itself, there is no chance for cleanup. The thread goes away right then and there.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
i am a new programer in mfc.now i met a problem.I want to draw objects such as line ,rectagle,stroke etc. and need these objects can be resize,move,rotate in interactive mode which means using track handles of interation with mouse.I can realize resize and move with CRectTacker and it works well.But the CRectTracker do not support rotate.Now i want to rotated these objcets. i can draw rotated objects in "GDI+" ,but not in the realtime mode.if someone have realize it , i will thanks for your helping in advance.Please give me some advice.i could not find some topics about this.