Solved

MDI and TOOLBAR

Posted on 1998-03-10
4
620 Views
Last Modified: 2013-12-03
I am using WIN32 API to create a Window application that have MDI and Toolbar.
The MDI application work fine with the toolbar except that the ToolBar seems to be draw on the client area eventhough I created the toolbar in the frame window. When the app create a child window, the top portion of the child window is covered by the toolbar.

Does anybody have any suggestion how to fix this?
 
0
Comment
Question by:klt
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1411882
If you look at how MFC fixes this problem, you'll see that the toolbar is a child of the frame. The MDI client window has been resized to match the area not taken by the toolbar. All MDI children are children of the MDI client window, so if the MDI client has been resized to not overlap with the toolbar, then neither will the MDI children.
0
 

Author Comment

by:klt
ID: 1411883
Thanks Thui,

I know the theory. However, My application initially created the toolbar and the MDI Client overlap to each other. How can I change my code so that they will not overlap to each other? Is that anything I need to set in order to make them not overlap to each other initially? Can you give me a little more detail how to fix it or point me to some sample code with MDI and Toolbar? I could not find any sample code with MDI and Toolbar in MSDN though.

Following code show how I create the Toobar:

case WM_CREATE:

           hWndToolbar = CreateToolbarEx(
                                   hWnd,                        // parent
                                   WS_CHILD| WS_BORDER| WS_VISIBLE |
                                   TBSTYLE_TOOLTIPS, // window style
                                   IDR_TOOLBAR,           // toolbar id
                                   8,                               // number of bitmaps
                                   ghInstance,                 // mod instance
                                   IDB_TOOLBAR,      // resource ID for bitmap
                                  (LPCTBBUTTON)&tbButtons,  
                                   5,                        
                                  16,16,                    
                                  16,16,                    
                                  sizeof(TBBUTTON));  

                 if (hWndToolbar == NULL )
                     {
                        MessageBox (NULL, "Tool not created!", NULL, MB_OK );
                        return 0;
                     }

Thanks again!
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1411884
Trap WM_SIZE in the MDI frame and given the size of the frame, reposition and resize your MDI client and toolbar so they do not overlap. Calculate the new rectangles for the toolbar and client based on the frame's new size.



0
 

Author Comment

by:klt
ID: 1411885
Thanks!
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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

12 Experts available now in Live!

Get 1:1 Help Now