Attaching to a CWnd pSite does not work |
Post Reply |
Author | |
fredwobus
Newbie Joined: 02 September 2004 Location: Austria Status: Offline Points: 22 |
Post Options
Thanks(0)
Posted: 03 November 2004 at 7:38am |
Hi,
In my application I need a toolbar (with codejock-style flashy look&feel), which isn't docked to a CMainFrm or any other FrameWnd, but simply fixed inside the window of a dialog. The toolbar should be permanently docked to the window just like the toolbar in the CHeroesView of the Common\Advanced sample. I am trying to adapt the DynamicPopups sample to my needs (using Xtreme Toolkit 9.51) I want the undo toolbar to be shown in the CDynamicPopupsView instead of it being docked to the CMainFrm. Modifying the sample, the toolbar is created in CDynamicPopupsView::OnInitialUpdate() and moved into position in CDynamicPopupsView::OnSize() using CalcDockingLayout() - (just like CHeroesView::OnSize from the Advanced Sample). The OnCreateControl method also moved from the CMainFrm class to the CDynamicPopupsView class. The toolbar is created and in the right place, the Add and Remove buttons work, but the "Undo popup" button ID_BUTTON_POPUP does not behave correctly. The OnCreateControl method is not called for the ID_BUTTON_UNDO control, which creates the custom CControlUndo control. Therefore the button pops up a default menu with one disabled entry [Undo] (just like the default in the RC file. Investigating the problem I found the difference in behaviour in CXTPControls::AddMenuItem (XTPControls.cpp:117). That is the place where the pSite is determined to which the WM_XTP_CREATECONTROL message is sent. In my modified application the WM_XTP_CREATECONTROL message is not sent to my CDynamicPopupsView (which has a handler for it creating the custom CControlUndo control), but to some different window, where it does nothing. If you read this far, you can imagine what I am asking - How do I make sure my commandbar gets a valid pSite, which receives its messages such as WM_XTP_CREATECONTROL ???? Note, that I create the toolbar in CDynamicPopupsView::OnInitialUpdate() using the this pointer as the pParentWnd. If you need my example project or any more code or info, let me know. Thanks, Fred |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
I made all same and it works. May be you forget to add ON_XTP_CREATECONTROL() macro to message map?
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
fredwobus
Newbie Joined: 02 September 2004 Location: Austria Status: Offline Points: 22 |
Post Options
Thanks(0)
|
Yes I have a correct message handler for ON_XTP_CREATECONTROL in CDynamicPopupsView.
It only works if the menu is loaded by the OnCreateControl in CMainFrm. Try again and but remove the ON_XTP_CREATECONTROL() macro from the message map in CMainFrm. The button popup in the CDynamicPopupsView window should now show the [Undo] menu. It never shows the menu assembled in CControlUndo::OnCalcDynamicSize, because the CControlUndo class is never instantiated for that popup. The handler CDynamicPopupsView::OnCreateControl is never called for (lpCreateControl->nID == ID_BUTTON_UNDO). Therefore we do not get the chance to insert our own control class. Cheers, Fred Edited by fredwobus |
|
fredwobus
Newbie Joined: 02 September 2004 Location: Austria Status: Offline Points: 22 |
Post Options
Thanks(0)
|
Hi Oleg,
I googled this forum and found some help in the article https://forum.codejock.com/forum_posts.asp?TID=489 "Topic: Paint UI with mix of themes" Although apparently unrelated it does offer a crucial piece of adivice - " try to call pCommadnBars->SetSite() " I now got the DynamicPopups sample to work without the initialisation for the CMainFrm. The commandbars now work within the CDynamicPopupsView like so: The red code is normally done by InitCommandBars() in a FrameWnd. As I donÄt have one here (just a CDialog) that never got called, and the command bar didn't have the correct pSite pointer to send its XTP_xx messages to. void CDynamicPopupsView::OnInitialUpdate() { CFormView::OnInitialUpdate(); CXTPCommandBars* pCommandBars = CXTPCommandBars::CreateCommandBars(); m_pToolBar = new CXTPToolBar(); m_pToolBar->CreateToolBar(WS_VISIBLE|WS_CHILD|CBRS_TOOLTI PS, this); m_pToolBar->LoadToolBar(IDR_TOOLBAR_EXT); m_pToolBar->SetCommandBars(pCommandBars); pCommandBars->SetSite(this); m_pToolBar->GetControls()->Remove(m_pToolBar->GetCo ntrol(0)); CXTPControl* pControl = m_pToolBar->GetControls()->Add(xtpControlButtonPopup, ID_BUTTON_POPUP, _T(""), 0); pControl->SetFlags(xtpFlagManualUpdate); ResizeParentToFit(); m_wndList.AddString(_T("Undo Edit")); m_wndList.AddString(_T("Undo Resize")); } Cheers, Fred. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |