CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2021
    Posts
    12

    A CMFCDropDownToolBar Question

    I created a CMFCDropDownToolBar embedded in a CMFCToolBar VIA dummy resource button as explained in CMFCDropDownToolBar Class microsoft document,everything works great, but what I want to do is create another dropdown toolbar embedded in the CMFCDropDownToolBar, is this possible??? I would like the same appearance look of the same toolbar/buttons as the 3rd choice of commands, I tried using the same process this time embedding a CMFCDropDownToolBar in a CMFCDropDownToolBar , it compiled but I got a debug assertion at the line using replacebutton


    THIS WORKS
    Code:
    CMFCToolBar m_wndTB;
    CMFCDropDownToolBar m_wndTBM;
    
    
    afx_msg LRESULT CMainFrame::OnResetToolbar(WPARAM wParam, LPARAM lParam)
    {.
    .
    .
     m_wndTB.ReplaceButton(IDB_DUMMY_TBAR, CMFCDropDownToolbarButton(_T("Add TB"), &m_wndTBM));
    }
    
    void CMainFrame::OnViewCustomize()
    {.
    .
    .
    
    pDlgCust->AddButton(_T("Build"), CMFCDropDownToolbarButton(_T("Add Resource"), &m_wndTBM));
    }

    ReplaceButton THROWS A DEBUG ASSERTION
    Code:
    CMFCDropDownToolBar m_wndTBMode,m_wndTB2;
    
    
    afx_msg LRESULT CMainFrame::OnResetToolbar(WPARAM wParam, LPARAM lParam)
    {.
    .
    .
     m_wndTB2.ReplaceButton(IDB_DUMMY_TBAR2, CMFCDropDownToolbarButton(_T("Add TBMode"), &m_wndTBMode));
    }
    
    void CMainFrame::OnViewCustomize()
    {.
    .
    .
    
    pDlgCust->AddButton(_T("Build"), CMFCDropDownToolbarButton(_T("Add Resource"), &m_wndTBMode));
    }

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: A CMFCDropDownToolBar Question

    Use debugger to step in the code to see where exactly and why the assertion fails.
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2021
    Posts
    12

    Re: A CMFCDropDownToolBar Question

    Quote Originally Posted by VictorN View Post
    Use debugger to step in the code to see where exactly and why the assertion fails.

    It's happening inside the mfc140ud.dll file created by microsoft
    so i'm going to assume that the method i'm trying is not allowed
    Name:  Screenshot 2021-08-10 17.59.31.jpg
Views: 285
Size:  34.1 KB

    i'm fairly good at finding errors in my code but through other files not created by me that's another story
    can you traverse through dll files to see code?

    and my other alternative is programmatically placing a CMFCToolbBar hosting a CMFCDropDownToolBar at the cursor position
    it seems to be that CMFCToolBars are placed in a pane placed by the framework at the beginning along the border chosen and from there the user can move it and position is stored via the registry

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: A CMFCDropDownToolBar Question

    You can do the following:
    1.Look at the Call Stack window, click at the line with mfc140ud.dll. If it is disabled then first try to load external code (see https://docs.microsoft.com/en-us/vis...r?view=vs-2019, https://docs.microsoft.com/en-us/vis...e?view=vs-2019)

    Or
    2. Just open the source file (...\ATCMFC\Src\MFC\afxdropdowntoolbar.cpp from your Visual Studio folder) and find what is on and around the line 554.
    Victor Nijegorodov

  5. #5
    Join Date
    Aug 2021
    Posts
    12

    Re: A CMFCDropDownToolBar Question

    thank you for your quick reply,i found the file in a search on my computer and the toolbar requesting the first button is coming back NULL
    Attachment 36006
    now to figure out why

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: A CMFCDropDownToolBar Question

    Quote Originally Posted by jstoll View Post
    It's happening inside the mfc140ud.dll file created by microsoft
    so i'm going to assume that the method i'm trying is not allowed
    Name:  Screenshot 2021-08-10 17.59.31.jpg
Views: 285
Size:  34.1 KB

    i'm fairly good at finding errors in my code but through other files not created by me that's another story
    can you traverse through dll files to see code?

    and my other alternative is programmatically placing a CMFCToolbBar hosting a CMFCDropDownToolBar at the cursor position
    it seems to be that CMFCToolBars are placed in a pane placed by the framework at the beginning along the border chosen and from there the user can move it and position is stored via the registry
    Please, don't delete the posts having some important info, particularly the posts on which there already exists the answers!
    Victor Nijegorodov

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: A CMFCDropDownToolBar Question

    Quote Originally Posted by jstoll View Post
    thank you for your quick reply,i found the file in a search on my computer and the toolbar requesting the first button is coming back NULL
    Attachment 36006
    now to figure out why
    But does this second toolbar contain any buttons? And did you load it before replacing the button?
    Victor Nijegorodov

  8. #8
    Join Date
    Aug 2021
    Posts
    12

    Re: A CMFCDropDownToolBar Question

    sorry about the deletion, after i posted the reply i found the file and i didn't want to waste anybody's time not realizing it was answered

  9. #9
    Join Date
    Aug 2021
    Posts
    12

    Re: A CMFCDropDownToolBar Question

    yes but the button i'm testing for the dropdown was an actual button,i replaced the id with a dummy one to connect the dropdownbar, i decided to press ignore after the assertion and the program actually contued on,the icon, one of the 2 buttons appeared as a dropdown control but i'm in another dilemma now I don't think it's going to work, as you press the button down to drop the toolbar and select, the actions are release and the button chosen will be placed in the que but after looking at it it's like having to controls on one button which is like bonnie and clyde pissed off at each other,so the only options i have is creatng a 1 button toolbar and adding the dropdown toolbar or a 2 button popup toolbar and programmatically placing them,can this be done with the mfc toolbars

  10. #10
    Join Date
    Aug 2021
    Posts
    12

    Re: A CMFCDropDownToolBar Question

    I tried using FloatPane() and Initially it does pretty close to want i want,it places the toolbar near the button i press, theres a couple problems though
    1: when the toolbar is in floating mode there's a title bar with a close button how do i get rid of it?
    2: when the program initially starts, the floating window programmatically is placed where i want it via the postion of the mousepos, but if i move the toolbar the floating toolbar stays where it last was, if i move the floating toolbar it stays where it is,i used DM_UNKNOWN

    DM_UNKNOWN: The framework uses this option when the docking method is unknown. The pane does not store its most recent floating position. You can also use this option to programmatically dock a pane when you do not have to store the recent floating position.

    virtual BOOL FloatPane( CRect rectFloat, AFX_DOCK_METHOD dockMethod=DM_UNKNOWN, bool bShow=true); Parameters. rectFloat [in] Specifies the screen coordinates where the floating pane appears.

    Code:
    void CMainFrame::PositionCylMethodsTB(CPoint mousePos)
    {
    	CRect size (mousePos.x, mousePos.y, mousePos.x+40, mousePos.y+40);
    	
    	m_wndTBCylMode.SetPaneStyle(CBRS_ORIENT_HORZ | CBRS_FLOATING| CBRS_BORDER_3D| CBRS_NOALIGN);
    	
    	m_wndTBCylMode.FloatPane(
    			 size,
    			DM_UNKNOWN,
    			TRUE);
    	
    	m_wndTBCylMode.SetWindowText(NULL);
    	
    	m_wndTBCylMode.ShowPane(
    		TRUE,
    		FALSE,
    		TRUE);
    
    }
    i used SetWindowPos() to place the window after the window was placed and it doesn't change the position
    how can i make this work please?thanks

  11. #11
    Join Date
    Aug 2021
    Posts
    12

    Re: A CMFCDropDownToolBar Question

    thanks VictorN for the additional help on debugging, much appreciated

  12. #12
    Join Date
    Aug 2021
    Posts
    12

    Re: A CMFCDropDownToolBar Question

    m_wndTBCylMode.SetPermament(TRUE); gets rid of the x(close) button still trying to get rid of the title bar
    Name:  Screenshot 2021-08-17 17.46.10a.png
Views: 293
Size:  5.3 KB
    Last edited by jstoll; August 17th, 2021 at 04:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured