Show/hide toolbars on the fly 
Author Message
 Show/hide toolbars on the fly

I need to show/hide toolbars on the fly depending on the type of document.
Given the right type of document, I 'll show the toolbar only if the user
has selected it to be shown.
For e.g., in Developer Studio, a palette toolbar comes up (provided if the
user has selected it) when the active document is a dialog, and it's gone
when the active document is a source file.

There are two methods that a user can select whether a toolbar to be shown
or not. By either
1) checking/unchecking a menu item or
2) clicking the 'x' button of a floating toolbar.
I have to save these states so that I can later use them to determine
whether to show the toolbar or not.

Saving the states of method 1 is easy.  Method 2 is where the problem lies -
I can't seem to find a way to trap the message given by clicking the 'x'
button.

How do you folks do it?  Any opinion is appreciated!
Wendy



Mon, 04 Dec 2000 03:00:00 GMT  
 Show/hide toolbars on the fly

    I saw this message a few days ago, and one response mentioned the
WM_SYSCOMMAND message. That is what happens when you press the 'x' button on any
window. But I don't believe that will echo back up to the main app. So I think
you must derive from CToolBar, add a handler for WM_SYSCOMMAND, and then echo it
back to the main app. The mainframe is most likely the parent, so you could
probably just do a GetParent()->PostMessage(<custom message>,...), or
GetParent->PostMessage(WM_COMMAND, <custom command>,...).  - Doug S.

Quote:

> I need to show/hide toolbars on the fly depending on the type of document.
> Given the right type of document, I 'll show the toolbar only if the user
> has selected it to be shown.
> For e.g., in Developer Studio, a palette toolbar comes up (provided if the
> user has selected it) when the active document is a dialog, and it's gone
> when the active document is a source file.

> There are two methods that a user can select whether a toolbar to be shown
> or not. By either
> 1) checking/unchecking a menu item or
> 2) clicking the 'x' button of a floating toolbar.
> I have to save these states so that I can later use them to determine
> whether to show the toolbar or not.

> Saving the states of method 1 is easy.  Method 2 is where the problem lies -
> I can't seem to find a way to trap the message given by clicking the 'x'
> button.

> How do you folks do it?  Any opinion is appreciated!
> Wendy



Mon, 04 Dec 2000 03:00:00 GMT  
 Show/hide toolbars on the fly

Not quite... The parent of a controlbar is CDockBar.  The parent frame of a
controlbar is CMainFrame when it's docked, and it is CMiniDockFrame when
it's floated. A derivative of CControlBar would never receive any
WM_SYSCOMMAND.

I never received any response mentioning WM_SYSCOMMAND.  The only one reply
I get is to override CalcFixedLayout which does not work.  I have more
success with CControlBar::OnWindowPosChanging().  It works most time, but
not all the time.  That's why I'm posting this again.

Wendy

Quote:

>    I saw this message a few days ago, and one response mentioned the
>WM_SYSCOMMAND message. That is what happens when you press the 'x' button
on any
>window. But I don't believe that will echo back up to the main app. So I
think
>you must derive from CToolBar, add a handler for WM_SYSCOMMAND, and then
echo it
>back to the main app. The mainframe is most likely the parent, so you could
>probably just do a GetParent()->PostMessage(<custom message>,...), or
>GetParent->PostMessage(WM_COMMAND, <custom command>,...).  - Doug S.


>> I need to show/hide toolbars on the fly depending on the type of
document.
>> Given the right type of document, I 'll show the toolbar only if the user
>> has selected it to be shown.
>> For e.g., in Developer Studio, a palette toolbar comes up (provided if
the
>> user has selected it) when the active document is a dialog, and it's gone
>> when the active document is a source file.

>> There are two methods that a user can select whether a toolbar to be
shown
>> or not. By either
>> 1) checking/unchecking a menu item or
>> 2) clicking the 'x' button of a floating toolbar.
>> I have to save these states so that I can later use them to determine
>> whether to show the toolbar or not.

>> Saving the states of method 1 is easy.  Method 2 is where the problem
lies -
>> I can't seem to find a way to trap the message given by clicking the 'x'
>> button.

>> How do you folks do it?  Any opinion is appreciated!
>> Wendy



Mon, 04 Dec 2000 03:00:00 GMT  
 Show/hide toolbars on the fly

Can't you call CFrameWnd::SaveBarState whenever a document is deactivated
and CFrameWnd::LoadBarState whenever one is activated?
Do you really need to trap the message as it happens?

Quote:

>I need to show/hide toolbars on the fly depending on the type of document.
>Given the right type of document, I 'll show the toolbar only if the user
>has selected it to be shown.
>For e.g., in Developer Studio, a palette toolbar comes up (provided if the
>user has selected it) when the active document is a dialog, and it's gone
>when the active document is a source file.

>There are two methods that a user can select whether a toolbar to be shown
>or not. By either
>1) checking/unchecking a menu item or
>2) clicking the 'x' button of a floating toolbar.
>I have to save these states so that I can later use them to determine
>whether to show the toolbar or not.

>Saving the states of method 1 is easy.  Method 2 is where the problem
lies -
>I can't seem to find a way to trap the message given by clicking the 'x'
>button.

>How do you folks do it?  Any opinion is appreciated!
>Wendy



Tue, 05 Dec 2000 03:00:00 GMT  
 Show/hide toolbars on the fly

    I was looking at a response from Pete Albano, thursday 12.54. I would say to
just override CMiniFrameWnd, and catch the WM_SYSCOMMAND there, but I don't know
how you would then tell the CControlBar to use your derivation rather than the
original!Sorry. - Doug S.

Quote:

> Not quite... The parent of a controlbar is CDockBar.  The parent frame of a
> controlbar is CMainFrame when it's docked, and it is CMiniDockFrame when
> it's floated. A derivative of CControlBar would never receive any
> WM_SYSCOMMAND.

> I never received any response mentioning WM_SYSCOMMAND.  The only one reply
> I get is to override CalcFixedLayout which does not work.  I have more
> success with CControlBar::OnWindowPosChanging().  It works most time, but
> not all the time.  That's why I'm posting this again.

> Wendy


> >    I saw this message a few days ago, and one response mentioned the
> >WM_SYSCOMMAND message. That is what happens when you press the 'x' button
> on any
> >window. But I don't believe that will echo back up to the main app. So I
> think
> >you must derive from CToolBar, add a handler for WM_SYSCOMMAND, and then
> echo it
> >back to the main app. The mainframe is most likely the parent, so you could
> >probably just do a GetParent()->PostMessage(<custom message>,...), or
> >GetParent->PostMessage(WM_COMMAND, <custom command>,...).  - Doug S.


> >> I need to show/hide toolbars on the fly depending on the type of
> document.
> >> Given the right type of document, I 'll show the toolbar only if the user
> >> has selected it to be shown.
> >> For e.g., in Developer Studio, a palette toolbar comes up (provided if
> the
> >> user has selected it) when the active document is a dialog, and it's gone
> >> when the active document is a source file.

> >> There are two methods that a user can select whether a toolbar to be
> shown
> >> or not. By either
> >> 1) checking/unchecking a menu item or
> >> 2) clicking the 'x' button of a floating toolbar.
> >> I have to save these states so that I can later use them to determine
> >> whether to show the toolbar or not.

> >> Saving the states of method 1 is easy.  Method 2 is where the problem
> lies -
> >> I can't seem to find a way to trap the message given by clicking the 'x'
> >> button.

> >> How do you folks do it?  Any opinion is appreciated!
> >> Wendy



Tue, 05 Dec 2000 03:00:00 GMT  
 Show/hide toolbars on the fly

For heaven's sake, trim your cross-postings.

public.vc.database ?????

Quote:

>I need to show/hide toolbars on the fly depending on the type of document.
>Given the right type of document, I 'll show the toolbar only if the user
>has selected it to be shown.
>For e.g., in Developer Studio, a palette toolbar comes up (provided if the
>user has selected it) when the active document is a dialog, and it's gone
>when the active document is a source file.

>There are two methods that a user can select whether a toolbar to be shown
>or not. By either
>1) checking/unchecking a menu item or
>2) clicking the 'x' button of a floating toolbar.
>I have to save these states so that I can later use them to determine
>whether to show the toolbar or not.

>Saving the states of method 1 is easy.  Method 2 is where the problem lies -
>I can't seem to find a way to trap the message given by clicking the 'x'
>button.

>How do you folks do it?  Any opinion is appreciated!
>Wendy

Don Grasberger
(remove --- from address to e-mail)


Tue, 05 Dec 2000 03:00:00 GMT  
 Show/hide toolbars on the fly

Yael,

I need to.  Because when a bar goes from dock to float, the current view is
deactived (hence SaveBarState to visible).  Now, when I close the bar, the
view is reactivated and it'll load the last saved bar state which was
visible eventhough I just closed the bar.

Wendy

Quote:

>Can't you call CFrameWnd::SaveBarState whenever a document is deactivated
>and CFrameWnd::LoadBarState whenever one is activated?
>Do you really need to trap the message as it happens?


>>I need to show/hide toolbars on the fly depending on the type of document.
>>Given the right type of document, I 'll show the toolbar only if the user
>>has selected it to be shown.
>>For e.g., in Developer Studio, a palette toolbar comes up (provided if the
>>user has selected it) when the active document is a dialog, and it's gone
>>when the active document is a source file.

>>There are two methods that a user can select whether a toolbar to be shown
>>or not. By either
>>1) checking/unchecking a menu item or
>>2) clicking the 'x' button of a floating toolbar.
>>I have to save these states so that I can later use them to determine
>>whether to show the toolbar or not.

>>Saving the states of method 1 is easy.  Method 2 is where the problem
>lies -
>>I can't seem to find a way to trap the message given by clicking the 'x'
>>button.

>>How do you folks do it?  Any opinion is appreciated!
>>Wendy



Tue, 05 Dec 2000 03:00:00 GMT  
 Show/hide toolbars on the fly

Doug,

It's actually a bit more complicated than that.  CMiniDockFrame is not
created by me, overriding it would have no meaning.  I might be able to use
a pointer class to extend CMiniDockFrame, and try to catch WM_SYSCOMMAND in
my overrided OnCommand().

Quote:

>    I was looking at a response from Pete Albano, thursday 12.54. I would
say to
>just override CMiniFrameWnd, and catch the WM_SYSCOMMAND there, but I don't
know
>how you would then tell the CControlBar to use your derivation rather than
the
>original!Sorry. - Doug S.


>> Not quite... The parent of a controlbar is CDockBar.  The parent frame of
a
>> controlbar is CMainFrame when it's docked, and it is CMiniDockFrame when
>> it's floated. A derivative of CControlBar would never receive any
>> WM_SYSCOMMAND.

>> I never received any response mentioning WM_SYSCOMMAND.  The only one
reply
>> I get is to override CalcFixedLayout which does not work.  I have more
>> success with CControlBar::OnWindowPosChanging().  It works most time, but
>> not all the time.  That's why I'm posting this again.

>> Wendy




- Show quoted text -

Quote:
>> >    I saw this message a few days ago, and one response mentioned the
>> >WM_SYSCOMMAND message. That is what happens when you press the 'x'
button
>> on any
>> >window. But I don't believe that will echo back up to the main app. So I
>> think
>> >you must derive from CToolBar, add a handler for WM_SYSCOMMAND, and then
>> echo it
>> >back to the main app. The mainframe is most likely the parent, so you
could
>> >probably just do a GetParent()->PostMessage(<custom message>,...), or
>> >GetParent->PostMessage(WM_COMMAND, <custom command>,...).  - Doug S.


>> >> I need to show/hide toolbars on the fly depending on the type of
>> document.
>> >> Given the right type of document, I 'll show the toolbar only if the
user
>> >> has selected it to be shown.
>> >> For e.g., in Developer Studio, a palette toolbar comes up (provided if
>> the
>> >> user has selected it) when the active document is a dialog, and it's
gone
>> >> when the active document is a source file.

>> >> There are two methods that a user can select whether a toolbar to be
>> shown
>> >> or not. By either
>> >> 1) checking/unchecking a menu item or
>> >> 2) clicking the 'x' button of a floating toolbar.
>> >> I have to save these states so that I can later use them to determine
>> >> whether to show the toolbar or not.

>> >> Saving the states of method 1 is easy.  Method 2 is where the problem
>> lies -
>> >> I can't seem to find a way to trap the message given by clicking the
'x'
>> >> button.

>> >> How do you folks do it?  Any opinion is appreciated!
>> >> Wendy



Tue, 05 Dec 2000 03:00:00 GMT  
 Show/hide toolbars on the fly

Let yr toolbar be GeneralToolbar and the event of selection a menu
item is OnViewToolBarSmall() ... So:

void CMainFrame::OnViewToolbarGeneralSmall()
{
if (GeneralSToolbar.IsWindowVisible())
        {      
        IsGeneralSToolbarVisible=FALSE;
        ShowControlBar(&GeneralSToolbar, FALSE,FALSE );
        }
else
        {
        IsGeneralSToolbarVisible=TRUE;
        ShowControlBar(&GeneralSToolbar, TRUE,FALSE );
        }

Quote:
}

void CMainFrame::OnUpdateViewToolbarGeneralSmall(CCmdUI* pCmdUI)
{
        pCmdUI->SetCheck(GeneralSToolbar.IsWindowVisible());

Quote:
}

/////////////
Ahmed Abbas
\\\\\\\\\\\\\
Quote:
>Can't you call CFrameWnd::SaveBarState whenever a document is deactivated
>and CFrameWnd::LoadBarState whenever one is activated?
>Do you really need to trap the message as it happens?


>>I need to show/hide toolbars on the fly depending on the type of document.
>>Given the right type of document, I 'll show the toolbar only if the user
>>has selected it to be shown.
>>For e.g., in Developer Studio, a palette toolbar comes up (provided if the
>>user has selected it) when the active document is a dialog, and it's gone
>>when the active document is a source file.

>>There are two methods that a user can select whether a toolbar to be shown
>>or not. By either
>>1) checking/unchecking a menu item or
>>2) clicking the 'x' button of a floating toolbar.
>>I have to save these states so that I can later use them to determine
>>whether to show the toolbar or not.

>>Saving the states of method 1 is easy.  Method 2 is where the problem
>lies -
>>I can't seem to find a way to trap the message given by clicking the 'x'
>>button.

>>How do you folks do it?  Any opinion is appreciated!
>>Wendy



Thu, 14 Dec 2000 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Show/hide toolbars on the fly

2. Show/hide toolbars on the fly

3. Show/hide toolbars on the fly

4. Show/hide toolbars on the fly

5. How to Hide/Show 2nd ToolBar?

6. Showing/hiding toolbars.

7. How to show/hide a toolbar

8. Show / hide multiple toolbars

9. Hide / show toolbar?

10. dynamically show/hide toolbar button text

11. How Can I Show/Hide ToolBar Text!!

12. Help Showing/Hiding new toolbars

 

 
Powered by phpBB® Forum Software