Tuesday, July 14, 2009

Need help with dev C compiler, specifically, windows application?

I know there is a probably a better place to ask this, but I don't know where. Anyways, what I need help with is writing a program using the windows application option (where the program starts with all the windows api stuff already there) in C language. I have no idea where to put my code in the large mess of stuff. There isn't even a main function, however there is one called winmain, is that something? I have tried sticking a printf function in different places to try to find where I can put my code with no luck. Does normal output like that not work in window application? Do I need to put a scanf or something to hold the program even though window doesn't dissapear? If you have a link to something that explains this that's fine. Thank you.

Need help with dev C compiler, specifically, windows application?
That won't work in a Windows application. If you want to use PrintF and it's friends, you will have to make a "Console Application." Windows applications don't have a "console.." all output is in the GUI.





Don't misunderstand this: A "Console Applicaiton" runs just fine in Windows. "Windows Application" should really be named "Windows GUI Application." The only difference is that a "Console Application" works in a text window (the "command line" window) whereas a "Windows Application" works exclusively through the GUI.





http://www.winprog.org/tutorial/





^^^ This looks like it will be a good tutorial to work thorugh to step out of the realm of "Console Applications" and into the realm of "Windows Applications."





However: Make sure you REALLY understand C and C++ on the console before you dive into the Win32 API. Doing otherwise may cause headaches, nausea, upset stomach, and perhaps even death.





-----





Windows applications don't use "main()". main() is the "entry point" for text applicaitons. "WinMain()" is the entry point for Windows Applications. There's a good reason for that: when DOS (or Linux, etc) calls your program, they call a C library that calls main(). Did that make sense?





When Windows calls your application, in calls a different C library that calls WinMain(). WinMain() is a function that sets up an EVENT LOOP that looks for things like button presses, mouse movements, keyboard events... all kinds of things.





main() and WinMain() are completely different species of fish. They have completely different purposes in life.


No comments:

Post a Comment