Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MDI and TOOLBAR

Posted on 1998-03-10
4
Medium Priority
?
641 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 300 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

963 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