Solved

MDI and TOOLBAR

Posted on 1998-03-10
4
622 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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