Solved

non-wrapping toolbars like DevStudio (urgent)

Posted on 1998-01-01
3
334 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

19 Experts available now in Live!

Get 1:1 Help Now