Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Message when activated Collapse All
Subject Author Date
Wilhelm Falkner Aug 29, 2006 - 11:10 AM

Hi,
I have a MDI-Application with some CExtControlBar. Inside these I use CExtResizableDialog classes. I have to know, when such dialog is activated. I tried OnActivate(...), but this message is never fired. What have I done wrong? Is there another message??

TIA
Willi

Suhai Gyorgy Aug 30, 2006 - 2:17 AM

When overriding OnActivate, did you have the ON_WM_ACTIVATE() line in your dialog’s Message Map? That’s the only thing I can think of why it wouldn’t work (you have to have that line to catch the message in OnActivate).

Or maybe you can try catching WM_SETFOCUS with OnSetFocus method. But it’s just a guess really. This time you need the have ON_WM_SETFOCUS in the message map.

Wilhelm Falkner Aug 30, 2006 - 2:30 AM

I have in my message map both ON_WM_ACTIVATE() and ON_WM_ACTIVATEAPP(), but the message is never fired. And: also in Spy++ I do not see this message. In another Modal CDialog I get the message. I tried to get the message in CExtControlBar, no success. I would need this message, it is replacing an old CTabControl messages TCN_SELCHANGE and TCN_SELCHANGING.

Technical Support Aug 31, 2006 - 9:31 AM

The WM_ACTIVATE standard Windows message is used only with popup windows and has little to do with your task. The WM_ACTIVATEAPP standard Windows message allows you to catch the event when some app is activated. It is not what you need. You should translate the WM_SETFOCUS and WM_KILLFOCUS standard Windows messages in the PreTranslateMessage() virtual method of your main frame window and analyze if the focused window is inside the particular dialog using the ::IsChild() Win32 API.

Wilhelm Falkner Aug 31, 2006 - 11:13 AM

Sounds easy, but neither in MainFrame, nor in the ChildFrame I get the message WM_SETFOCUS. PreTranslateMessage is set up Ok, because I got lot of other messages, but never WM_SETFOCUS. What can be wrong?
TIA
Willi

Technical Support Sep 3, 2006 - 11:42 AM

We are sorry for giving you the wrong advice. Please create a CExtControlBar-derived class and override the CExtControlBar::OnUpdateCmdUI() virtual method in it:

void CYourControlBar::OnUpdateCmdUI( CFrameWnd * pTarget, BOOL bDisableIfNoHandler )
{
bool bControlBarWasActive = IsBarWindowActive();
    CExtControlBar::OnUpdateCmdUI( pTarget, bDisableIfNoHandler );
bool bControlBarIsNowActive = IsBarWindowActive();
    if( bControlBarWasActive != bControlBarIsNowActive )
    {
        . . .
    }
}

Wilhelm Falkner Sep 4, 2006 - 4:43 AM

Works perfect! Lot of thanks for your work and fast reply
Willi

Wilhelm Falkner Sep 3, 2006 - 7:40 AM

Another question, but in same area: The CExtControlBar are grouped into TabbedContainer. How can I activate each by programm?
TIA
Willi

Technical Support Sep 3, 2006 - 1:27 PM

You should invoke the control bar’s activation command in the main frame window to activate the bar in any state:

CFrameWnd * pMainFrame = . . .
CExtControlBar * pBar = . . .
    pMainFrame->SendMessage( WM_COMMAND, WPARAM( pBar->GetDlgCtrlID() ) );


Wilhelm Falkner Sep 4, 2006 - 4:52 AM

Seems that I miss some code. The bars do not switch. I send the message to the mainframe, also to the childframe, but no reaction. What have I done wrong? Do I need some messagehandler?
Another question: I use SetWindowText to write some text to the titlebar of the bar. Works good. But also the text in the TabbedContainer is modified, and there I would need an static text. How can I manage, the the titlebar is updated, but not the tabs?
TIA
Willi

Technical Support Sep 4, 2006 - 11:59 AM

We guess you forgot to add the following main frame’s message map entries for each of your control bars:

    ON_COMMAND_EX( ID_SOME_CONTROL_BAR, OnBarCheck )
    ON_UPDATE_COMMAND_UI( ID_SOME_CONTROL_BAR, OnUpdateControlBarMenu )
The command should be sent to the main frame window only.

You can control all the text strings related to the control bar. You should use your own CExtControlBar-derived class and override the CExtControlBar::OnGetBarCaptionText() virtual method. This method is declared as follows:
    virtual void OnGetBarCaptionText(
        e_bar_caption_text_t eBCT,
        CExtSafeString & strCaptionText
        ) const;
The e_bar_caption_text_t enumeration is declared locally in scope of the CExtControlBar class:
    enum e_bar_caption_text_t
    {
        __EBCT_SINGLE_CAPTION_DOCKED = 0,
        __EBCT_SINGLE_CAPTION_FLOATING = 1,
    #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
        __EBCT_TAB_GROUP_CAPTION_DOCKED = 2,
        __EBCT_TAB_GROUP_CAPTION_FLOATING = 3,
        __EBCT_TAB_ITEM_CAPTION = 4,
        __EBCT_AUTOHIDE_ITEM_CAPTION = 5,
        __EBCT_AUTOHIDE_SLIDER_CAPTION = 6,
    #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    #if (!defined __EXT_MFC_NO_DYNAMIC_BAR_SITE)
        __EBCT_DOCUMENT_CONTAINER_CAPTION = 7
    #endif // (!defined __EXT_MFC_NO_DYNAMIC_BAR_SITE)
    };
So, you can display different strings in the control bar caption in the docked state (__EBCT_SINGLE_CAPTION_DOCKED), control bar caption in the floating state (__EBCT_SINGLE_CAPTION_FLOATING), tabbed group caption in the docked state __EBCT_TAB_GROUP_CAPTION_DOCKED), tabbed group caption in the floating state (__EBCT_TAB_GROUP_CAPTION_FLOATING), tab item text (__EBCT_TAB_ITEM_CAPTION), auto hide area tab item text (__EBCT_AUTOHIDE_ITEM_CAPTION), auto hide slider window caption displayed from the auto hide tabs (__EBCT_AUTOHIDE_SLIDER_CAPTION) and, for of dynamic control bars, caption in the document mode (__EBCT_DOCUMENT_CONTAINER_CAPTION).

Wilhelm Falkner Sep 4, 2006 - 12:53 PM

Question with CaptureText now works very good, thanks for your help!
I think, I have explaind wrong, what I mean with "activate Bar". The code you suggested, switch teh bar On and Off. What I would need is, bring it to top window, make it the active window. I try to explain in other word: when using a CTabControl I would use the function SetCurSel(...).
TIA
Willi

Suhai Gyorgy Sep 5, 2006 - 2:54 AM

Seems like it’s CExtControlBar::DoFrameBarCheckCmd method what you need. Many Samples show usage of this, let’s just take BitmapEditor for instance.

After adding message map entries mentioned above, override default OnBarCheck and OnUpdateControlBarMenu:

void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
{
//	CFrameWnd::OnUpdateControlBarMenu( pCmdUI );
	CExtControlBar::DoFrameBarCheckUpdate(
		this,
		pCmdUI,
		false
		);
}

BOOL CMainFrame::OnBarCheck(UINT nID)
{
//	return CFrameWnd::OnBarCheck( nID );
	return
		CExtControlBar::DoFrameBarCheckCmd(
			this,
			nID,
			false
			);
}

Help says the following about the last parameter of DoFrameCheckCmd:
"Check mark mode (for resizable control bars only). If this mode is set to true, the show/hide command turns on or turns off visibility of the resizable bar. If false, the method shows the invisible bar wherever it is and sets focus on it."

Same goes for last parameter of DoFrameBarCheckUpdate. So if you override those methods like shown above, it’ll work as required.

Wilhelm Falkner Sep 5, 2006 - 4:07 AM

Overwriting the functions will not help, because than I|m not able to switch On/Off. But calling DoFrameBarCheckCmd direct solve the problem.
Thanks
Willi