i would like to share my knowledge , i hope it may be help full to you
C++
Design pattens by GOF
Design patterns
Sockets
winsock
JAVA
Creating Custom package
Util package
Win32 API
MFC
--------------------------------------------------------------------------------------------------------------
An MFC Introduction
Part B - MFC Application Wizard
Note: You might see an additional option: How would you like to use the MFC library?. Please choose, As a Shared DLL (instead of As a statically linked library).
Windows Programming with C++ mfc by Jon Pearce
Directx:
toy making
shading gary simpson
i found some of university's for gaming and graphic
LUNAD University
mit lab
Designing
C++
Design pattens by GOF
Design patterns
Sockets
winsock
JAVA
Creating Custom package
Util package
Win32 API
MFC
--------------------------------------------------------------------------------------------------------------
The MFC Document/View Architecture
The goal of this lab is to be able to:
- Explain the five main parts of the MFC Document/View interface.
- Create a basic doc/view Windows program using the Application Wizard (please see this excellent tutorial for a non-wizard based doc/view approach).
- Handle some simple Window's messages.
Dissecting a Visual C++ Program
A standard Visual C++ program based on the MFC Document/View interface is made up of five main parts:
- The Application Object — our windows program itself
- The Main Frame Window Object — our main window
- The Document Object — handles our data
- The View Object — handles data dispay
- The Document Template
- Combines together the Main Window, the Document, and the View
The Application Object (stored in realtor.h and realtor.cpp) is an instance of the CRealtorApp class and this is what Windows actually runs first (since its InitInstance() method is called from within the built-in, implicit WinMain() function). When this object is started, it places the Main Window on the screen and starts passing Windows messages on from Windows to our main window.
The Main Window Object displays the program itself and this is where we find the menu bar, the title bar of the window, and the tool bar. The main window object is an instance of the CMainFrame class and is responsible for everything that surrounds the area where the action — the drawing, text, and other graphics — goes on in our window. That area is called the client area in a window; for example, the text that you edit in a word processor appears in the word processor's client area. The view object is responsible for handling the client area itself.
The View Object handles the client area — this is where we'll format and display the data in our program, such as the text we're editing if we're creating a word processing program. In fact, the view object is really a window itself that appears on top of the client area. The data we display in the view object is stored in the document object.
The Document Object is where we store the data for our program. You may wonder why we don't store it in the view object — the reason is that we may have a great deal of data, more than will fit into our client area at once. Visual C++ makes it easier for us by allowing us to store all that data in the document object and then handle the display of the data that will fit into the client area in the view object. In fact, we'll see that you can have several different views open in the same document at once, as in an MDI application.
The Document Template, finally, is created in the InitInstance() function of the Application Object and this is how the program connects the other three classes — the document, main frame window, and view classes — to the program itself. If we're creating a SDI application, we'll find the CSingleDocTemplate object in there; if we're creating a MDI application, we'll find the CMultiDocTemplate object instead.
Windows Messages are special codes, along with a minimal amount of data, sent between various objects in Windows to communicate between them. For example, when the user quits our program, Windows sends the application object the WM_QUIT message. When the user resizes our program's window, we get the WM_SIZE message. The application object (of the CRealtorApp class) sends most windows messages on to the main window object (of the CMainFrame class), except for WM_QUIT, which makes the application object finish up and exit.
In fact, there's a great deal of communication that takes place between the various objects in a Visual C++ program. Because such programs are divided up into four main objects, that's to be expected. These objects need to communicate among themselves about their activities. The AfxWinMain() function therefore has a Message Loop that sends these messages around.
Some great links:
Okay, enough introduction, let's get our hands dirty now!
Part B - MFC Application Wizard
Your MFC Project will be a realtor application to keep track of sales listings of homes and to keep track of buyers' requirements and match them to listings.
Part B: MFC AppWizard - Step 1 of 10 We want to create a brand new project so select the File → New menu item. A dialog box like the one shown below should appear. The selected choice, MFC AppWizard (.exe) will generate an object-oriented, MFC based application. In the Project name: edit box type a suitable name for your project. This name will be used extensively throughout the generated files and code, so choose something short, unique, and meaningful. The lab example will use the project name Realtor. As you type a name for your project notice that the Location: edit box changes. This field determines the path to all of the files that are created. Make sure that it is a suitable location, otherwise feel free to edit this box as well. Visual C++ will create any directories that do not exist. Finally, ensure thatWin32 is the platform and press OK. This step launches the AppWizard and displays the first in a series of dialog boxes that allow you to define the parameters of your project.
Step 1, shown below, allows you to select a single or multiple document interface. Multiple document interfaces (MDI's) are programs like Word and Excel that allow you to have more than one document open within the mainframe. Single document interfaces (SDI's) like Notepad and Paint limit you to one open document at a time. Our project is going to allow multiple documents so select Multiple documents. Most of us will probably leave the default language as English, but feel free to experiment. Click on Next > to move to the next step.
Part B: MFC AppWizard - Step 2 of 10 Step 2 allows the user to enable database support. Using Open Data Base Connectivity (ODBC) MFC supports direct access to many popular databases. We will not be using this at this time, so make sure None is selected. Hit the Next > button and move on.
Part B: MFC AppWizard - Step 3 of 10Some of the most exciting features of MFC is support for Object Linking and Embedding (OLE) and ActiveX controls. OLE allows the dynamic interchange of data and functionality between different Window's applications. You can also use OLE at the development level to plug a calendar, calculator, or even an Internet browser into your application. This project will not be OLE aware, so select None and leave the bottom two check boxes blank. Press Next > to continue the process.
Part B: MFC AppWizard - Step 4 of 10 With the proper selections, we can add Docking toolbars, Context-sensitive help, Printing and print-preview support, Status bars, and 3-D controls. As you select and de-select different options, you will see the changes reflected on the sample application. Select Docking toolbars, Initial status bar, and 3D controls and continue by pressing Next >.
Part B: MFC AppWizard - Step 5 of 10Make sure to say Yes, please to comments in your source file during Step 5. This not only adds comments about the code that Visual C++ generates, but inserts helpful TODO comments as well. Look for these TODO comments in the generated files. They will give you an excellent indication of where your specific application code belongs and what it should do. Continue by pressing Next >.
Part B: MFC AppWizard - Step 6 of 10
The final step shows you the classes Visual C++ is going to create for you, the base class(es) they inherit, and the .cpp and .h files it will create. You may edit these default selections at your peril. Unless you have a very good reason to do so, leave this box the way it is. If you are satisfied with the selections you made, you can press Finish and watch the magic, or use the back and next buttons to move through the six steps to make any desired changes. Press Finish in any screen to generate the code for your first wizard based project.
The final step shows you the classes Visual C++ is going to create for you, the base class(es) they inherit, and the .cpp and .h files it will create. You may edit these default selections at your peril. Unless you have a very good reason to do so, leave this box the way it is. If you are satisfied with the selections you made, you can press Finish and watch the magic, or use the back and next buttons to move through the six steps to make any desired changes. Press Finish in any screen to generate the code for your first wizard based project.
Even though you have pressed finish, you have one more chance to change your mind. The below screen summarizes the selections you have made. Cancel returns you to AppWizard while OK passes the point of no return. Visual C++ creates the files, generates the code and opens your project in AppStudio ready for editing or building. After this step is finished look in C:\temp\Realtor\ or wherever you chose to place the code and look at what was generated.
Before we go into a discussion of the various files and their purposes, you may want to compile, link, and execute your program. You can do this by selecting Execute Realtor.exe from the Build menu, pressing F7 on your keyboard, or clicking on the run button.
Have a look at your program. Even though you did not request it Visual C++ put in a minimal menu and even an About your program dialog box under the Help menu item. We will edit those later to make them our own.
Compile, run and test your program. Congratulations, you have successfully written a windows application without entering a single line of code.
Part B: MFC AppWizard - Step 7 of 10 (Adding Some Code, A Message Box)
Every user event causes a message. If our application's Message Map has been coded to intercept this message, we have an opportunity to respond to it. Windows already checks every message intended for our program to see if there is anything we want to do in response. So far, we have simply ignored all messages and let the default procedures take place (click on the various menu items in the main window and see what happens). We will now add some code to the message map and a function or two to respond to some of these messages.
Every user event causes a message. If our application's Message Map has been coded to intercept this message, we have an opportunity to respond to it. Windows already checks every message intended for our program to see if there is anything we want to do in response. So far, we have simply ignored all messages and let the default procedures take place (click on the various menu items in the main window and see what happens). We will now add some code to the message map and a function or two to respond to some of these messages.
The easiest way to change the program is to add code to an existing class function. The PreCreateWindow() function is called just before the main window is created. You could make changes to the default window class and style here. Where can we find this code? Get used to using the Project Workspace window to move around in your code. Blindly searching through twenty or more files is just not that productive. If this window is not visible in the Microsoft Developers Studio select View/Project Workspace, press Alt + 0(zero), or click the Project Workspace Icon on the toolbar.
The three tabs at the bottom of the window represent the different views available to your project. Spend a few minutes exploring the various views and, when ready, select the ClassView tab. Click on the + sign next to Realtor classes and then CRealtorView so that all of the function members are shown. You will notice that the member functions have a purple rectangle beside them. The key signifies that the function member has a protected or private access modifier. You will see a light blue rectangle beside data member variables.
Double-click on PreCreateWindow. The IDE will automatically open RealtorView.cpp and bring you to the appropriate spot in the file. We can modify the windows application. Edit the code in the functionPreCreateWindow() by inserting the bolded line (substituting your team member names for Student1 and Student2) so it appears as follows:
BOOL CRealtorView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
AfxMessageBox("Realtor Project created by Student1 and Student2");
return CView::PreCreateWindow(cs);
}
Compile, run and test your program. Notice that the message box appears before the application's window.
Part B: MFC AppWizard - Step 8 of 10 (A User Keyboard Event)Our program now responds to a message generated by a system event that is automatically generated when the application is executed, immediately before the application window is displayed. Most of the events you will be interested in, however, are caused by the user. Most of those will come from the keyboard or the mouse. We are going to add a function to the CRealtorView class which will respond to the user pressing a key. This is the WM_CHAR message. You are going a use a tool called ClassWizard to do this. ClassWizard is a code generator that will save you hours.
Part B: MFC AppWizard - Step 9 of 10 Before you continue, using the FileView tab, have a good look at RealtorView.cpp and RealtorView.h so that you are able to detect the changes made by ClassWizard. Print a copy of each file so you can compare the two after the folowing changes. Pay particular attention to the Message Map for RealtorView.cpp which currently looks like this:
BEGIN_MESSAGE_MAP(CRealtorView, CView)
//{{AFX_MSG_MAP(CRealtorView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Also look at the last line of RealtorView.cpp and then notice what ClassWizard will add.
When you are ready, launch ClassWizard by selecting View/ClassWizard… from the menu, pressing Ctrl + W, or use the ClassWizard controls on the second toolbar. The following image is the result ofView/Class Wizard… (Ctrl + W). Make sure of the following:
- The Message Map tab is selected
- Class name is CRealtorView
- Object Id is CRealtorView
Once all of these settings are correct, press the Add Function button and notice that a new function has been added to the Member functions output box. Press the Edit Code button and watch the magic. Notice the new function stub added at the end of RealtorView.cpp:
void CRealtorView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CView::OnChar(nChar, nRepCnt, nFlags);
}
Now scroll up to the message map section where the code now looks like this:
BEGIN_MESSAGE_MAP(CRealtorView, CView)
//{{AFX_MSG_MAP(CRealtorView)
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Also, please take note that the following prototype has been added to the class definition in RealtorView.h:
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
Modify the code in the function OnChar so that when the user presses a key the character of that key will be displayed in a MessageBox.
void CRealtorView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CString cszString = nChar;
MessageBox(cszString, "Inside OnChar", MB_OK);
CView::OnChar(nChar, nRepCnt, nFlags);
}
We have already seen the use of another MessageBox function called AfxMessageBox(). This function, MessageBox() takes 3 parameters; 2 character strings (or CStrings) and a special key word. The first string will be the message contained in the body of the message box. (If you have used Windows, then you have seen a message box at least once if not hundreds of times.) The second string is placed in the title barof the message box. The special keyword forces the OK button to be placed on the message box. The actual creation, displaying, and processing of the keyword is done by Windows.
Compile, run, and test your program. Go back and look at the message map and the header file. Hopefully, you can now understand why the Wizard is the way to go. You can concentrate on the logic of a problem and not have to be overly concerned with the "grunt" work.
Part B: MFC AppWizard - Step 10 of 10 (A User Mouse Event)Now try to insert a left button down message box function. We will use the MessageBox() method and intercept the WM_LBUTTONDOWN message. Follow a similar procedure as used above for the WM_CHARmessage. For the code for this member function, use the MessageBox function to display a message such as "Left clicked at X=??, Y=??" where X and Y are the coordinates of the location of the click on the screen. See CPoint and CString classes in Help. Also, the last parameter of MessageBox is a list of keyword function option flags. We would like to include an OK button and place the exclamation icon in the box. There are several different options you can request. Check out the MessageBox() function in Help to see the other options.
void CRealtorView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString cTheString; // create a string
// Format is a method of CString. It allows you to
// create a string from a set of variables according
// to their datatypes
cTheString.Format("Left clicked at X=%d, Y=%d", point.x, point.y);
// outputs the contents of the cTheString using
// the MessageBox() function
MessageBox(cTheString, "Sample Message Box", MB_OK | MB_ICONEXCLAMATION);
CView::OnLButtonDown(nFlags, point);
}
Compile, run and test your program.
Part C - Resources: Menus, Bitmaps, Icons, StringTable
The goal of this part is to be able to:
- Add and modify the following resources - toolbars, tool tips, context sensitive help, icons, accelerators and popup menus.
Part C: Resources - Step 1 of 7 (Modify the Menu)Continue with your Realtor application. Let's add a completely new menu item (popup control) to the menu called Modify containing two sub-menu items called Houses and Buyers (these menu items will be used to activate the dialog boxes created in later labs). The Hot Keys (or accelerators) for these menu items will be Ctrl + H and Ctrl + B, respectively. We will want to insert it between View and Window on the main menu because, traditionally, Window and Help are the last two popups on the main level. Repeat each step for the second menu item Buyers as we go through the steps for Houses.
Select the ResourceView tab in the Project Workspace window. Click on the + sign next to Realtor resources and then the Menu resource. We want to modify the specific menu for project Realtor so double-click the menu resource IDR_REALTOTYPE. This action will cause your current menu to be displayed in the right hand editor window. The box to the right of the Help popup is blank. It is the one we will be editing. To place it between View and Window, click the left mouse button and hold it down. Drag the mouse to the spot you wish to move your new menu item to and let the button go. The menu should look like similar to the diagram:
Start typing the letters &Modify. The ampersand symbol (&) in all Window's resources (and, indeed, many computer languages) places an underline under the letter immediately following it as you will see. As you start to type, the property box for this control will automatically appear. You could also double-click on the blank square to invoke its property box.
Finish typing &Modify and, after ensuring the Popup check box is checked and the others are all blank, close the Menu Items Property box. You will notice a new blank rectangle appears immediately below the word Modify. Double-click that rectangle to invoke its property box. Fill it in as shown in the following so your properties box will resemble the diagram below.
- ID: ID_MODIFY_HOUSES - This resource identifier will be used throughout the program to indicate when a user selects this menu item
- Caption: &Houses\tCtrl + H - This string will appear with the 'H' underlined because of the ampersand and the Ctrl + H portion will be right justified in the drop down because of the formatting character '\t'. Ctrl + H will be the eventual accelerator for this menu item. Here it is simply a text string with no inherent effect.
- Prompt: Modify the collection of houses\nModify Houses - the first part of this string will appear in the status bar whenever the user moves the mouse to the menu item or toolbar button. The part following the '\n' will appear in the tool tip if a button is created for it.
Repeat this step for the other item, Modify/Buyers. Once you have completed both menu items, you can compile, run and test your program to make sure you have done it right. You will notice that your menu option is active but all the menu items under the option are grayed out. These will become active after we place code in your application to implement them.
Part C: Resources - Step 2 of 7 (Add new Accelerator Keys)Select IDR_MAINFRAME from the Accelerator folder and press Enter. A table of all the existing accelerators will be displayed. To add one of your own, double-click the empty rectangle at the bottom of the list or right click anywhere in the edit window and choose New accelerator from the menu that pops up. Select the appropriate identifier from the ID list box as shown in the properties figure. Make sure the Ctrl andVirtkey boxes are checked, then enter an 'H' in the edit box labeled Key:. Press Enter to close the box and check the accelerator list. It will automatically be sorted alphabetically by accelerator key, so look up and down to find it. Repeat for the other menu item accelerator (Modify/Buyers).
Note: You shouldn't type in the =32 in the ID: drop-down box above!
You're done! Compile and run your program (there is really nothing to test). You will see that the menu and accelerators have no functionality. Our new menu items may look pretty, but we haven't associated them with a specific task yet.
Part C: Resources - Step 3 of 7 (Add new Toolbar Buttons)A toolbar is really a two part resource, the toolbar itself, and the bitmaps that appear on the buttons. The bitmaps are all taken from a single bitmap, which is logically split into 16x15 pixel squares. The Resource Editor hides some of the complexity from you and makes it look like you are only working with individual bitmaps.
Select the ResourceView tab from Project Workspace and expand the toolbar item. Double-click the IDR_MAINFRAME identifier to launch the toolbar editor. You should see your toolbar with an empty button in the last position. Click on it and draw a house on it or something else to your liking. Next, drag the button to whatever position you desire and then double-click it to bring up its property box.
In the ID section you must give it the same identifier as the associated menu item. For the house button, that would be ID_MODIFY_HOUSES. You can scroll down and select it from the list if you click on the down arrow. Do not type a new prompt; the resource editor will find the correct one when you close the box or tab to the next field. Once again, repeat this for the other button, Modify/Buyers.
To rearrange the buttons, click on the button that has to be moved, hold down the mouse button, drag it to its new location, and then release the mouse button. To create a separator space: click, hold, drag to the right, and drop the first button of the new group. Compile and run it to make sure everything's still okay.
Part C: Resources - Step 4 of 7 (Add code to implement menu items)We need to add some code to our .cpp files to implement the functionality of our menu items. Once again, Class Wizard will help us do that.
Menu items are small windows of their own, commonly referred to as controls. Edit boxes, list boxes, toolbar buttons, radio buttons, and push buttons are also different types of controls. Every click on a control is anevent. Every event causes at least one message. All control events generate at least a WM_COMMAND message. The identifier of the control is sent along with the message.
The only thing we can do with a menu item or button is click it, or press Enter when it has the focus (You can tell if a control has the focus when it, or its title bar, is highlighted). It therefore makes sense to respond to the WM_COMMAND message from menu items and push buttons. We linked the toolbar button and the menu item to the identical identifier (e.g. ID_MODIFY_HOUSES and ID_MODIFY_BUYERS), so it follows that clicking either one would generate identical messages. That means we only have to implement one piece of code to make a menu item and its associated toolbar button cause the same action to take place.
A consideration involved in writing message handlers (a generic term for functions that respond directly to Windows messages) is: Where do we place them? Think about what they do and what they affect. Saveseems to belong to the document (and would be placed in CRealtorDoc), whereas Print seems more appropriate in CRealtorView since printing allows us a view of the data. But where does Modify/Housesbelong? At this point we have no real idea what our functions will be doing. This would never happen when developing a real application so it is not a real problem. Remember, however, that message handlers should be associated with a class that makes sense.
Our ability to make things happen on the screen is fairly limited thus far, and we have no data yet, so let's just add a message box to each menu item so that we can see if they work. The AppWizard created 5 major classes for our program. They were CChildFrame, CMainFrame, CRealtorApp, CRealtorDoc, and CRealtorView. The View class is generally used to display our data in a child window. You know we are able to open many child windows. (Just choose File → Open and pick a file, any file. All this does is return a filename to our program, and we then would open the file and handle the data appropriately.)
When we open a file, new Document and View objects are created. The user can therefore manipulate each child window independently. You may have noticed that a different menu appears when we have child windows open. (Close all child windows to notice the difference.) We want our new code to affect each and every data file independently so our code will be attached to the Document. The code will affect the data for whichever child window has the focus.
To be able to notice the independence of each window, we will code Modify/Houses to display a message box. Launch ClassWizard and make sure you have selected CRealtorDoc as the class name. In theObject ID's: list box, find ID_MODIFY_HOUSES and select it. You will notice that the available messages for a menu item are COMMAND and UPDATE_COMMAND_UI. Select COMMAND, then the Add Functionbutton. This will cause a small dialog box to appear containing the name of the function ClassWizard will create. Select OK then press the Edit Code button. This will take you directly to the CRealtorDocimplementation file, where a new function header exists. Insert the following code in the function, then run and compile your program.
void CRealtorDoc::OnModifyHouses()
{
// TODO: Add your command handler code here
AfxMessageBox("Modify collection of Houses",MB_OK | MB_ICONEXCLAMATION);
}
Add a message box (similar to above) as responses to Modify/Buyers menu item using the wizard. Compile and test that your new menu items have been inserted correctly.
Part C: Resources - Step 5 of 7 (Create an Icon)We will now cover the creation of icons and strings in the StringTable. The icons will be implemented in this lesson while the strings will be used later.
Icons can be used as application icons (seen on the desktop or the upper left corner of the application when open) as well as for document icons (associated with .??? ending files and seen in the file manager and also seen in the upper left corner of the application when a document is opened). To create an icon, choose Insert/Resource, and then Icon/New. This will display the icon development window. This window is split; left, the actual icon and right, the zoomed icon. You will notice also that the tool and color palettes are displayed.
Draw a dollar sign or something similar for the first icon. To bring up the Properites, double click the drawing area (but not on the bitmap itself). You can create a more descriptive label and designate the filename. Since we will be creating two icons to replace the default application and document icons, changing the label will not be necessary. However, you will want to change the filename. The new icon files will be placed in the res directory and called app_icon.ico and doc_icon.ico.
We will need to create two icons. These icons will replace the default icons supplied when the Realtor application was created by the AppWizard. Unfortunately, we can not just edit the existing icons. Once you have created you icon, save it. Create a second icon (I'd suggest an outline of a house or similar) for use by your document windows in an MDI application. Once you have saved the second icon, close all resource windows you have opened.
The next step to implementing your new icons in the Realtor application is to physically alter the source code in your resource .rc file. Using File/Open, open your Realtor.rc in Text mode (use Open As: TEXT at the bottom of the Open window). Scroll through the source code until you find the //////Icon section. There you should find the following references:
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\Realtor.ico"
IDR_REALTOTYPE ICON DISCARDABLE "res\\RealtorDoc.ico"
IDI_ICON1 ICON DISCARDABLE "res\\app_icon.ico"
IDI_ICON2 ICON DISCARDABLE "res\\doc_icon.ico"
You will change the MAINFRAME filename from Realtor to app_icon and the REALTOTYPE filename from RealtorDoc to doc_icon. After you have made the changes, you can delete the two temporary icon lines IDI_ICON1 and IDI_ICON2. We will not need these references any more because you can do any maintenance to the icons using MAINFRAME and REALTOTYPE. Save and close the resource file. If you compile and run your project, you should now see the new icons.
Part C: Resources - Step 6 of 7 (Create a StringTable entry)StringTable entries are used to store standard messages that may be need to be displayed to the user (such as "Are you sure you want to edit the house collection?"). Creating an entry for the StringTable is very similar to creating an entry for the accelerator table. Open the StringTable resource via your resource information window. Scroll to the bottom of the string table resource. There you will find a dotted rectangle. Double click the rectangle. This will display the Properties dialog . There are two entries: the string label and the string contents. The string label (IDS_CONFIRM_HOUSE_EDIT) will be used by the LoadString() member function of a CString instance to identify the desired string. The contents associated with the label would be loaded in the CString instance. To edit an existing string, double click the string and make your changes.
Also create the following additional three strings (we will use the last two later):
- IDS_CONFIRM_BUYER_EDIT → "Are you sure you want to edit the buyer collection?\nPress YES to confirm"
- IDS_CONFIRM_HOUSE_DELETE → "Are you sure you want to delete the house?\nPress YES to confirm"
- IDS_CONFIRM_BUYER_DELETE → "Are you sure you want to delete the buyer?\nPress YES to confirm"
Implementing a load from the StringTable requires three statements: instantiation of a CString instance, using the CString class LoadString() member function, and then using the instance in, say, a MessageBox. Change your code for the Modify/Houses option to use the new StringTable entry as shown below.
void CRealtorDoc::OnModifyHouses()
{
// TODO: Add your command handler code here
CString ctheString;
ctheString.LoadString(IDS_CONFIRM_HOUSE_EDIT);
if (AfxMessageBox(ctheString, MB_YESNO | MB_ICONQUESTION) == IDYES)
AfxMessageBox("You pressed Yes", MB_OK);
else
AfxMessageBox("You pressed No", MB_OK);
}
Part C: Resources - Step 7 of 7
Change your code for the Modify/Buyers option similarly. Compile, run, and test your Realtor application.
Finally, here's the hierarchy of the various MFC classes:
Windows Programming with C++ mfc by Jon Pearce
Programming Visual C++ by David Kruglinski
--------------------------------------------------------------------------------------------------------------Directx:
toy making
shading gary simpson
i found some of university's for gaming and graphic
LUNAD University
mit lab
Designing