· Build your program with the F7 function key. if you have any errors, double click to take
you to the line of code and check carefully for missing brackets, semicolons, miss typing,
etc. and build again. Run you program with red exclamation mark icon OR execute from
the Build Menu.
· To add a menu item, use the menu editor. Click the resources tab in the Workspace
window, click the + beside menu, then double click IDR_MAINFRAME. Click on the File
menu to open and grab the box at the bottom (use Insert key to add a box if necessary)
and drag it up to between Print Preview and Print Setup menu items. Double click to
open the Menu Item Properties box, place the caption Print Welcome in the caption box
and close the box. This gives the new menu item the ID ID_FILE_PRINTWELCOME.
· Use the ClassWizard (found under the View menu) to connect the new menu item to an
event handler. Make sure xxWelcomeView is the class selected in the Class name box.
Find and select ID_FILE_PRINTWELCOME in the Objects Ids list, then double click
Command in the Messages box. This brings up a message box suggesting the name for
the event handler of OnFilePrintWelcome(). Click OK to accept it.
· When the user clicks our new menu item, we will display “Welcome to menus” centered
on the bottom of the screen. To do this we need to declare and initialise a variable
called StringData to store the string. Open the file xxWelcomeDoc.h and add the code in
bold font to declare the string object.
public:
virtual ~CShwelcomeDoc();
CString StringData;
· Then open xxWelcomeDoc.cpp and initialize the string object in the document’s
constructor.
// xxWelcomeDoc construction/destruction
xxWelcomeDoc:: xxWelcomeDoc ()
{
welcome_string = "Welcome to Visual C++";
enjoy_string = "Enjoy!";
StringData = "";
// TODO: add one-time construction code here
}
No comments:
Post a Comment