We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


7 Urgent VC++ questions

wcpp asked
Medium Priority
Last Modified: 2012-06-27
I am developing a "map" system with VC++ 5.0 under Win95: Using client window to display a map, including streets and crosses and etc. I met some basic problems but don't know how to solve.

Background: This application is a multi-windows one. In the default child window, I embed a CFormView class ( a dialog) to display some parameters to let user to select sth.: which
county and districts etc. After selecting them, click a "View Map" button on this dialog or the same function button in Toolbar, another child window will be created to display the map. I use a CMDIChildWnd Class, say "MapChild" to create the map child windows and within this class, I program some functions: ZoomIn, ZoomOut, Move Map, Center Map and etc.

1. I can't print the map with a printer. The "File->Print" didn't work at all. Then, from the help, I know that only CView Class can use the "File->Print". So I try test the print in CFormView dialog, however, even in the CFormVeiw class, I can't print the dialog with parameters. Only the origial child window created by APP Wizard can be printed. However, it is a blank window-nothing can be seen.
I hope to print the map. Then, I try to create the map child window by a CView class, say "MapChildView". Then, I moved all functions in "MapChild" (Zoomin, zoomout and etc.) to "MapChildView". Then, not only I can't print the map either, I can't make the "zoomin, zoomout etc." work in both "MapChild" and "MapChildView". How to print the map while I can also use those functions"

2. When I maximize the "Map Child Window", the title bar disappeared: I can't see its title, the small icon in the left-top corner, and the minimum & maximum & close button in the right-top corner. In order to access other child windows, I have to use "Windows->Tile(or cascade") to make the map window smaller. Why? How to solve?

3. When I exit the application by "File->exit" or just click the close button in the parent window, the applicaiton is still in RAM, i.e., when I press "Ctrl+Alt+Del" to run the "close program", I can still see the map application name in the task list. So, if I build the application within VC++ complier again, it will display "Can't link map.exe" or "map.exe is in use". Anyway, I can't delete "map.exe" or move it--the application is just like being run, although I can't see the interface and access the program--because I have closed it and exit the applicatoin!
4. How to make the buttons in toolbar as switches? i.e., when I click the button in toolbar once, the button can keep down; click again, it go up. In which class I should implement it and call which function?

5. How to make the command in the the menu be checked or unchecked?

6. I use "pDC->DrawDragRect(lpRect, size, lpRectLast, sizeLast, NULL, NULL ); " to draw move dynamic rectangle ( in Zoomin, select a rectangle to expand), but no rectangle was drawed. How to do that?

7. I want to copy a complicate dialog from another application to this one, but it seems that the dialog in resource file "*.rc" can not be copy as a whole. Now, I can only copy "static" to "static", a "radio" to "radio" and etc. instead of copy a whole dialog to a dialog. You know, that will be tiresome. How can I copy a dialog as a whole?

My job was stuck here. Could you help me? Thank you very much!

Watch Question


Help!! S. O. S.

You might getter faster and better responses posting under the windows programming topic area.  (I posted my first question in the wrong area too.) Also you might get better responses if you break this up into a couple of questions.  Someone that can answer part of this might not be willing to because they know they won't get the points since they can't get answer it all.

I'm afraid I can't help you with your questions because they are all MFC related.  Except when you describe the maximising behaviour of the child window it sounds correct.  When a MDI child window is maximixed, its title bar disappears and the title bar buttons appear on the menu bar of the parent window.  Is that not what is happening in your app?  Have you compared the behavior with another MDI app, like Vissual C++?
I think you have missunderstud how MFC works. Or maybe even how windows works. When you draw in a window you draw in a DC. When drawing on a paper you draw in a DC. MFC uses this and the CView class calls the OnPaint() function to draw both in windows and on paper. And if you window is not derived from CView there is no predefined function to do this for you. Then you have to write your own function that hooks to the menu event, print, and then starts the nesisary print handling functions and then draw in the DC for the printer/paper.
1. MFC's printing support depends on the view to handle OnDraw(). The FormView does NOT handle OnDraw because it relies on the dialog to do all of the painting. You will need to override OnDraw to do the drawing.

2. Again, the problem is the dialog. When you maximize, the default MDI window handler does the right work to make the buttons appear. Since the MDI window handler isn't called due to the dialog, those buttons won't appear.

3. The program is not interpreting WM_CLOSE correctly or the main window isn't getting deleted. You will need to debug your application to find out where the code is stopping.

4 and 5. You will need to look into Command Enabling for the menu choices and buttons. Basically, you need to provide OnUpdateCommandUI for the IDs of the button or menu choice and call CCmdUI->SetCheck() with either TRUE or FALSE depending on whether you want a check (for menu items) or the button down.

6. Don't really know about this one because I haven't used that function. You may want to double check to see if it is supported under Win95. The way I would have done it is to draw the lines myself.

7. The dialogs are stored in the .RC files and the corresponding .rh files. Since the .rh and the .rc files are text files you can use any text editor to copy and paste between them as necessary.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.