• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

Toolbar at the middle of a Dialog window

Hi !

I try to create a toolbar at the middle of my dilaog window (as as matter of fact it supposed to replace a button). I wrote something like this (IDC_STATIC_FOR_TOOLBAR ia a static control at the middel of dilaog):

     CWnd* pStatic=GetDlgItem(IDC_STATIC_FOR_TOOLBAR);
     RECT StaticRect;
     pStatic->GetWindowRect(&StaticRect);
     ScreenToClient(&StaticRect);

        m_ToolBar = new CToolBarCtrl;
     m_ToolBar->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT, StaticRect, this, 0);

        //Setup image list

My problem is that the toolbar allways appears at the left-up corner of a dilaog (0,0). How I put it at some other place of my dilaog ?
Maybe be I need to evaluate the actual size of my toolbar, but how I do it ?

Thakns
0
ef33
Asked:
ef33
  • 2
1 Solution
 
BeyondWuCommented:
yes, the toolbar always locates the left-top or bottom of parent-window, to do this, you need to appoint another parent for your toolbar, for example the static. But I always create a new window(derived from CWnd) as the parent of this toolbar, because all the message has been send to the new parent, you need to handle the command in the new parent window.
m_ToolBar->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT, StaticRect, pStatic, 0);
0
 
ef33Author Commented:
Hi !

The problem solution was to add CCS_NOPARENTALIGN style to toolbar Crate method. In such a case I had no problem to pass a dialog window as a parent.
0
 
ef33Author Commented:
Thanks anyway
0

Featured Post

Industry Leaders: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now