|
[C++ Win32] Basic Windows Form [TuT]
|
|
05-26-2010, 09:49 AM
Post: #1
|
|||
|
|||
|
[C++ Win32] Basic Windows Form [TuT]
TUT 1: A Simple Window.
-Start- Hello, and welcome to my tutorial on how to make a Basic Window, also know as a GUI. First of all to make a Win32 Windows Application, you must create a project. Follow these first steps: 1. Open Visual Studio 2. File > New > Project 3. Select Win32 4. Click "Win32 Console Application", Enter Name and click "ok". 5. Click "Next" 6. Application type: Select "Windows Application" 7. Additional Options: Select "Empty Project" 8. Right Click "Source Files" in the Solution Explorer 9. Add > New Item 10. Then add a "C++ File (.cpp)" Enter Name and click "ok" Now you should have a blank .cpp you can edit. (Simple eh?) Alright, now for the code. In console like you should all know, it starts off with int main(). Well in Windows Application its: Code: int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nShowCmd)Heres the code for a Basic 300x300 Window. Code: #define WIN32_LEAN_AND_MEAN /*excludes APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets.*/The program works as the following. Main: 1. Create Class with settings 2. Registers it 3. Creates Window with Class Settings and styles in CreateWindowEX() 4. Send MSG to CallBack where it will be processed. CallBack (msg loop): 1. Receive the MSG 2. Process the received MSG. wParam and lParam contain extra information about whats going on.(Can be NULL) I.E. Win Form with a button, you click the button, it sends a MSG to WM_COMMAND, there you can catch it with a switch (wParam) and modifie what happens when a user clicks a button. Press F5(Debug), and you should get this: ![]() Hope you enjoyed my tutorial. And please, do not leach. Your's Truly, - BlueMelon Note: I'm re-writing most of my tuts, so stay tuned for more! Also, PM me with requests. Don't forget to say thanks!, Keep the thread Alive as this may help ALOT of people! ![]() |
|||
|
05-26-2010, 05:59 PM
Post: #2
|
|||
|
|||
|
RE: [C++ Win32] Basic Windows Form [TuT]
When you select Console application and try to make a simple GUI from that, you need to write a lot of code and to feel how it works. But in object orientated drag & drop programming languages form is already there.
But the difference is that in this case you have better understanding. Very good tut ! There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
05-27-2010, 05:05 AM
Post: #3
|
|||
|
|||
RE: [C++ Win32] Basic Windows Form [TuT]
(05-26-2010 05:59 PM)drdebcol Wrote: When you select Console application and try to make a simple GUI from that, you need to write a lot of code and to feel how it works. But in object orientated drag & drop programming languages form is already there. Drag&Drag requires .net framework, might as well use Vb.net. This is Win32 C++ Coding =D ![]() |
|||
|
« Next Oldest | Next Newest »
|




![[Image: vq49q8.png]](http://i44.tinypic.com/vq49q8.png)
![[Image: 30ifbbd.png]](http://i46.tinypic.com/30ifbbd.png)


