7 Urgent VC++ questions

Posted on 1997-11-06
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!

Question by:wcpp
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 1172632
Help!! S. O. S.
LVL 22

Expert Comment

ID: 1172633
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++?

Expert Comment

ID: 1172634
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.
LVL 15

Accepted Solution

Tommy Hui earned 200 total points
ID: 1172635
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.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 147
White board coding practice 3 98
Issues with C++ Class 19 119
print bytes of an integer 6 48
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question