VC ++MFC Tutorial 3 (English)

zhaozj2021-02-08  242

Lesson 3: Visual C IDE and Workspaces

Windows programming is tricky stuff. Do not let anyone fool you. But microsoft has blessed us with their IDE called Developer's Studio. It will handle all the compiling and linking, provides help, fills in tons of code for you, and gives you that 'Visual' Designing Environment to make cute little dialogs.

There a few things you must learn to use to get anywhere. First and most importantly, USE THE ONLINE HELP. There are so many windows functions, you will find yourself in the help 50% of the time or more for the first few months. IF you have visual c 6.0 you need the msdn for help. Get it. If you have 4.2 or 5.0 you can use the Builtin Help.

Next, the single most important key combination is Ctrl-W. This brings up what is called the 'Class Wizard'. This guy will insert a bunch of code in your project for you. It handles all the code for connecting functions up to the Messages Windows Posts.

You will also find yourself in the resource view a bit. It is used to design the dialogs. You can drop buttons on them and what not. With a couple of clicks here and there you can layout your whole application. Then using the class wizard You Can Have Your Project 50% Finished. All Is Left Is To Fill in The Functions The Class Wizard Made To Handle The Button Click Messages and What Not.

Now you need to know how to start a new program and we can begin with the real code. Go to the File menu and select New. Then go to the 'Projects' tab and select MFC AppWizard. Type in a name for you application and press ok. The only important option for now is the first one. This is the type of application you want to build. The simplest is a 'Dialog based'. Try them all, but try dialog based first. Just select all the defaults afterwards by pressing 'next' and 'ok'. you'll end up with a few files, but lets ignore everything.Go to the resource view and plop some buttons and stuff on the dialog. Just play around. When you feel like it, Build The Project from the 'Build' Menu and Run IT (I Always Just Press Ctrl-F5, IT Builds The Project and Runs IT). Everything Should Build and Run. Wa-la. Application Complete and Running.

One last tip on the IDE. If you right click on a menu bar, a dialog will pop up. You can select 'Customize'. This is very useful. You can build one custom menu with all the buttons you need on it by simply dragging the buttons to and from the menu bar. You can even change the menu layout (like by putting the File, New as a button on the tool bar). One really needed control is under the Build category in the customize dialog. It is the drop list used to select the active configuration Drag that sucker up to your main toolbar and change it's size still it looks good to you I have only one toolbar on my screen and it has the following buttons on it:.. save, save all , Compile, Build, Stop Build, Rebuild All, SET Active Configuration, Find, Find, Show View, Show Output Window, Set Break Point, Remove Break Point, Tile Windows, Find In Help.

转载请注明原文地址:https://www.9cbs.com/read-2784.html

New Post(0)