Solved

non-wrapping toolbars like DevStudio (urgent)

Posted on 1998-01-01
3
347 Views
Last Modified: 2013-11-20
I need an answer to the following question urgently and so pls answer me ASAP. (Thanks for ur hlp :))

I want my application to have non-wrapping toolbars (like DeveStudio has).

In DOCKTOOL sample supplied by Microsoft if you resize mainframe window toolbars get aligned into seperate lines (ie get stacked).
But if you resize the mainframe window of all Microsoft packaged Apps (like Word, DevStudio) toolbars do not get wrapped down.

How to acheive this?

Regards,
devenkat@cyberspace.org
D.Venkatesan Pillai
Software engineer, AUTODESK Inc., SanFransisco, CA -94903
0
Comment
Question by:dvenkat
[X]
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
  • 2
3 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1313368
When frame is resized or control bars visibility is toggled on/off frame window calls its virtuall function RecalcLayout which in turn calls RepositionBars. This CWnd member function brodcasts MFC private messge WM_SIZEPARENT define in afxpriv.h passing pointer to AFX_SIZEPARENTPARAMS MFC structure as LPARAM. This structure contains frame expected size and allows control bars to adjuxt this size and reposition themselves. If you want to overwrite standard behaviour you should handle this message and implement your own adjustment.
0
 

Author Comment

by:dvenkat
ID: 1313369
I tried your (galkin's) IDEA on DOCKTOOL samples(suppled by MicroSoft), but apart from startup time later on FRAME RESIZING event the MsgHandler for my specialised CTOOLBAR class (CTOOLBARSPEC) was never getting called.

stp-by-step what I did follows :

//////////////////Step 0 ///////////////////////////
///////////////////////////////////////////////////

modify CMainFrame class ToolBar varibales to my own TOOLBAR varible (it is called "CToolBarSpec")

(lines in "mainframe.h" Class CMainFrame)
      CToolBarSpec    m_wndMainBar;  
      CToolBarSpec    m_wndResourceBar;
      CToolBarSpec      m_wndDebugBar;
      CToolBarSpec    m_wndBrowseBar;



//////////////////Step 1 ///////////////////////////
///////////////////////////////////////////////////

Specialise CTOOLBAR class to proved WM_PARENTSIZE handler by introducing a specialied class called CTOOLBARSPEC in "mainframe.h"

#include "afxpriv.h"

class CToolBarSpec : public CToolBar
{
      DECLARE_DYNAMIC(CToolBarSpec);

public :
      BOOL      mDynamicHide; //A falg to indicate if the toolbar                               //was  hidden dynamically to                               //acheive DevStudio style DockBar
      CToolBarSpec()
      {
            mDynamicHide = FALSE;
      };

public :
      virtual ~CToolBarSpec()
      {

      };

protected:
      //{{AFX_MSG(CTollBarSpec)
      afx_msg LRESULT OnParentSize(WPARAM w, LPARAM l);
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};



//////////////////Step 2 ///////////////////////////
///////////////////////////////////////////////////

Write an implementation for OnParentSize which actually compares its own framesize (Controlbars') with parent's FrameSize, and if it is about to go out of parent frame it hides dynamiccalyy.
In the same way if it is about to be visible to shows up again.

I added the following line in "mainframe.cpp"
(for specializing WM_PARENTSIZE msg handler.. of CControlBar )


IMPLEMENT_DYNAMIC(CToolBarSpec, CToolBar)

BEGIN_MESSAGE_MAP(CToolBarSpec, CToolBar)
      ON_MESSAGE(WM_SIZEPARENT, OnParentSize)
END_MESSAGE_MAP()



LRESULT CToolBarSpec::OnParentSize(WPARAM wParam, LPARAM lParam)
{
      TRACE("......................OnParent SIZE called \n");

      /****
      // special struct for WM_SIZEPARENT
      struct AFX_SIZEPARENTPARAMS
      {
            HDWP hDWP;       // handle for DeferWindowPos
            RECT rect;       // parent client rectangle (trim as appropriate)
            SIZE sizeTotal;  // total size on each side as layout proceeds
            BOOL bStretch;   // should stretch to fill all space
      };
      ***/
      AFX_SIZEPARENTPARAMS * psSizeParent = (AFX_SIZEPARENTPARAMS *) lParam;

      RECT frameRect = psSizeParent->rect;
      RECT ToolbarRect;

      //(left,top)******************
      //                  *                *
      //                  *                *
      //                  ******************(right, bottom)

      GetWindowRect(&ToolbarRect);

      //Horizantally docked toolbars (hiding)
      if ( ToolbarRect.left + 10 >=  frameRect.right ) //Horizantal Toolbar about to hide
      {
            if (IsWindowVisible() && !mDynamicHide) //by default visible && not dynamically hidden
            {
                  TRACE("......................Horizantal toolbar hidden \n");
                  psSizeParent->hDWP = NULL;
                  mDynamicHide = TRUE;
                  ShowWindow(SW_HIDE);
            }
      }

      //Vertically docked toolbars (hiding)
      if ( ToolbarRect.top + 10 >=  frameRect.bottom ) //Horizantal Toolbar about to hide
      {
            if (IsWindowVisible() && !mDynamicHide) //by default visible && not dynamically hidden
            {
                  TRACE("......................VERTICAL toolbar hidden \n");

                  psSizeParent->hDWP = NULL;
                  mDynamicHide = TRUE;
                  ShowWindow(SW_HIDE);
            }
      }


      //Horizantally docked toolbars (showing)
      if ( ToolbarRect.left + 10 >=  frameRect.right ) //Horizantal Toolbar about to Show itself up
      {
            if (!IsWindowVisible() && mDynamicHide) //not visible && dynamically hidden
            {
                  mDynamicHide = FALSE;
                  ShowWindow(SW_SHOW);
            }
      }

      //Vertically docked toolbars (Showing)
      if ( ToolbarRect.top + 10 >=  frameRect.bottom ) //Horizantal Toolbar about to Show itself
      {
            if (!IsWindowVisible() && mDynamicHide) //not visible && dynamically hidden
            {
                  mDynamicHide = FALSE;
                  ShowWindow(SW_SHOW);
            }
      }

      return 0;
};



//////////////////Step 3 ///////////////////////////
///////////////////////////////////////////////////
Compile.  Set a break point in CTOOLBARSPEC::OnParentSize()
function.

And start the program in debugger :

Only during startup (the first time of showing ) of MainFrame window this function is getting called. (ie MSG reaches CTOOLBARSPEC class msg handler).

LATER ON WHEN YOU RESIZE THE PARENT WINDOW IT is NNNNNNOOOOOOOOOOOOOOOOOOOOTTTTTTTTTTTTTTTT getting Called...

Pls help.................


0
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1313370
First of all it is very strange that WM_SIZEPARENT message handler in your toll bar class is never called. your code seems correct. Try to set breakpoint in your parent frame derived class WM_SIZE message handler and step into CFrameWnd::OnSize. You will see that this function simply calls RecalcLayout() if frame is not minimized. RecalcLayout virtual function after some preprocessing calls CWnd::RepositionBars. This function in turn also after some preprocessing sends WM_SIZEPARENT message to all toolbars and view to be filled frame's client area. The reason tool bar doesn't receive this message may be in the fact your toolbar IDs do not lie between AFX_IDW_CONTROLBAR_FIRST and AFX_IDW_CONTROLBAR_LAST. In this case this message is not sent to control bar.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

705 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