Dialog windows -- where does the application code go
-
I'm the person who started the string below called "where's main() ???". Ravi was helping me but either has given up on me or gone to bed ;-) So, here's my question: If I create a dialog window and want to run graphics in it continuously, where do I put my code that does the graphics? I'm not using messages, the application is free-running. I would guess I'm not the first person to ever wonder "Gee, I wonder where my application goes?" but none of my 4 books tell me and no one else has been able to tell me. Having just finished my C++ class, this is my first and foremost question -- where does the code go now that I'm no longer running console-only apps? I've spent all day trying to figure this out, including numerous and fruitless web searches. I presume the place where the application code goes is well-defined and well-known, can someone tell me? Thanks. Dave
-
I'm the person who started the string below called "where's main() ???". Ravi was helping me but either has given up on me or gone to bed ;-) So, here's my question: If I create a dialog window and want to run graphics in it continuously, where do I put my code that does the graphics? I'm not using messages, the application is free-running. I would guess I'm not the first person to ever wonder "Gee, I wonder where my application goes?" but none of my 4 books tell me and no one else has been able to tell me. Having just finished my C++ class, this is my first and foremost question -- where does the code go now that I'm no longer running console-only apps? I've spent all day trying to figure this out, including numerous and fruitless web searches. I presume the place where the application code goes is well-defined and well-known, can someone tell me? Thanks. Dave
Well mate, i had a similar problem when i moved from dos based programing to windows type programming.... In windows you have created a dialog app, so you do need to responde to messages to get you job done effectivly, else i can only say that your code will become very inefficient. You cant have a continouse loop waiting for the keypress by the user to terminate the application....like we did in dos programs. the loop is there but it is called as the message loop. you can add your code in the message pump loop, but still again its inefficient. You can setup a timer and respond to the timer every now n then. or you can handle the OnIdle event to do things that you would like to do. but you should not lock up that event,i.e return back as soon as possible. Summury:You need to change the design of your application when making a moveing to windows. hope i helped you someway. regards Prakash. The World is getting smaller and so are the people.
-
Well mate, i had a similar problem when i moved from dos based programing to windows type programming.... In windows you have created a dialog app, so you do need to responde to messages to get you job done effectivly, else i can only say that your code will become very inefficient. You cant have a continouse loop waiting for the keypress by the user to terminate the application....like we did in dos programs. the loop is there but it is called as the message loop. you can add your code in the message pump loop, but still again its inefficient. You can setup a timer and respond to the timer every now n then. or you can handle the OnIdle event to do things that you would like to do. but you should not lock up that event,i.e return back as soon as possible. Summury:You need to change the design of your application when making a moveing to windows. hope i helped you someway. regards Prakash. The World is getting smaller and so are the people.
Prakash, Thank you very much for your suggestions. Sorry it took so long to get back to you but I had to do some quick reading of timers and the OnIdle event. I think one of these will work for me and I appreciate your help. I'm willing to change the design of my application, I just didn't understand the need to until your reply. Thanks again! Dave
-
Prakash, Thank you very much for your suggestions. Sorry it took so long to get back to you but I had to do some quick reading of timers and the OnIdle event. I think one of these will work for me and I appreciate your help. I'm willing to change the design of my application, I just didn't understand the need to until your reply. Thanks again! Dave
No Problem, nice to know that it helped and appreciating it. regards. The World is getting smaller and so are the people.
-
I'm the person who started the string below called "where's main() ???". Ravi was helping me but either has given up on me or gone to bed ;-) So, here's my question: If I create a dialog window and want to run graphics in it continuously, where do I put my code that does the graphics? I'm not using messages, the application is free-running. I would guess I'm not the first person to ever wonder "Gee, I wonder where my application goes?" but none of my 4 books tell me and no one else has been able to tell me. Having just finished my C++ class, this is my first and foremost question -- where does the code go now that I'm no longer running console-only apps? I've spent all day trying to figure this out, including numerous and fruitless web searches. I presume the place where the application code goes is well-defined and well-known, can someone tell me? Thanks. Dave
Links to some articles that may be of some help. There are many more, just explore the articles here on CP:-D http://www.codeproject.com/cpp/mfcprogflow.asp[^] http://www.codeproject.com/dialog/dialogapptute.asp[^] http://www.codeproject.com/dialog/dialogapptute2.asp[^]
[
](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!
-
I'm the person who started the string below called "where's main() ???". Ravi was helping me but either has given up on me or gone to bed ;-) So, here's my question: If I create a dialog window and want to run graphics in it continuously, where do I put my code that does the graphics? I'm not using messages, the application is free-running. I would guess I'm not the first person to ever wonder "Gee, I wonder where my application goes?" but none of my 4 books tell me and no one else has been able to tell me. Having just finished my C++ class, this is my first and foremost question -- where does the code go now that I'm no longer running console-only apps? I've spent all day trying to figure this out, including numerous and fruitless web searches. I presume the place where the application code goes is well-defined and well-known, can someone tell me? Thanks. Dave
The latest book by Charles Petzold is a good starting point for Windows programs. I started with his Windows v3.1 book. It was a wonderful learning experience. I also used a few books by Herbert Schildt. They were fun!
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
I'm the person who started the string below called "where's main() ???". Ravi was helping me but either has given up on me or gone to bed ;-) So, here's my question: If I create a dialog window and want to run graphics in it continuously, where do I put my code that does the graphics? I'm not using messages, the application is free-running. I would guess I'm not the first person to ever wonder "Gee, I wonder where my application goes?" but none of my 4 books tell me and no one else has been able to tell me. Having just finished my C++ class, this is my first and foremost question -- where does the code go now that I'm no longer running console-only apps? I've spent all day trying to figure this out, including numerous and fruitless web searches. I presume the place where the application code goes is well-defined and well-known, can someone tell me? Thanks. Dave
Hi, I'll try to help you out as it kinda seems to me everyone else hasn't really answered your question fully. First off there's two main ways to go about programming Windows. There's the MFC and the Win32 API. MFC is Microsoft's wrapper classes around the Win32 API. MFC in a nutshell is Win32 with the details hidden from you, i.e. you use Microsoft's functions which in turn access the Win32 API. I use MFC, so my knowledge of Win32 is vague, but in Win32 the application starts off in the WinMain() function. In MFC you can't see this, because its hidden behind the scenes. There really isn't a starting point that you can "see" in MFC. Your best bet as to understanding where an MFC app starts is by looking at the file projectname.cpp where the projectname is what you called the project. That's the first file thats used where you see any code. Understanding the Win32 API will help you in using MFC, but its not necessary and from the little bit I've tried of Win32, there's a lot more stuff going on and takes longer to learn than MFC, I think. So I'd recommend starting off with MFC. There's 3 different types of applications that you can make (as you've probably already seen in the wizard). Dialog based, SDI, or MDI. You should start off using the wizard and choosing either Dialog based or SDI to start off with. There's a lot more to explain after that, but I don't want to write a book here unless I know I'm helping. I'd be happy to help you out though. Just send me a message and I'll explain more or if you really want help I could walk you through some examples over instant messenger if you wanted to.
-
I'm the person who started the string below called "where's main() ???". Ravi was helping me but either has given up on me or gone to bed ;-) So, here's my question: If I create a dialog window and want to run graphics in it continuously, where do I put my code that does the graphics? I'm not using messages, the application is free-running. I would guess I'm not the first person to ever wonder "Gee, I wonder where my application goes?" but none of my 4 books tell me and no one else has been able to tell me. Having just finished my C++ class, this is my first and foremost question -- where does the code go now that I'm no longer running console-only apps? I've spent all day trying to figure this out, including numerous and fruitless web searches. I presume the place where the application code goes is well-defined and well-known, can someone tell me? Thanks. Dave
Decided to continue my post since I didn't really mention what you were asking. Anyway I recommend that first you start out by making a simple Dialog based MFC app using the wizard. I think this is the easiest thing to understand and its what I started out learning. You can immediately run the program and it will show you the default dialog that was created. Open up the file projectnameDlg.cpp (projectname is what you called the project). This is where you will be adding code. In a dialog window all the code that handles things displayed to the screen generally is done within the dialog's class. It can be done outside of it, but that's more advanced so I won't get into it. Some main places that your code can go is in OnInitDialog() and in functions for each control. Its kinda hard to tell you how to do things here, so the only thing I can really tell you without walking you through an example, is to double click on the OK button in the resource and it will generate the function for when the button is clicked. This is an example of where you'd put code that you want to execute when the button is pressed. Now for what you want to do, you'd be choosing an SDI application. To me an SDI makes more sense if you understand dialog based although many people will say its the other way around. The way an SDI works is you paint things onto the screen. This is done in the ChildView using the OnPaint() function. That's where you can put code in order to draw things. Generally you won't be doing the drawing directly from OnPaint, but rather you'll be calling other functions you create to do something and then draw things from there. But for a simple example just to learn you can draw a circle directly in the OnPaint() function. Hope this helps. Anyway like I said in my previous post I'm more than willing to walk through some examples with you. Helps me sharpen me skills :). Mike