?
Solved

Toolbar at the middle of a Dialog window

Posted on 2003-03-09
3
Medium Priority
?
245 Views
Last Modified: 2013-11-20
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
Comment
Question by:ef33
[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 9

Accepted Solution

by:
BeyondWu earned 400 total points
ID: 8099816
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
 

Author Comment

by:ef33
ID: 8114895
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
 

Author Comment

by:ef33
ID: 8114899
Thanks anyway
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

762 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