Solved

7 Urgent VC++ questions

Posted on 1997-11-06
4
441 Views
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.

Questions:
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!

wcpp
0
Comment
Question by:wcpp
4 Comments
 

Author Comment

by:wcpp
Comment Utility
Help!! S. O. S.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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++?
0
 
LVL 2

Expert Comment

by:JensUniweb
Comment Utility
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.
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
Comment Utility
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.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now