Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Toolbar control access

Toolbar control access

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m_mun
    wrote on last edited by
    #1

    Hi all, I have declared CComboBox m_comboBox; in MainFrame class Using it, I have created a combobox on toolbar. But I can't access it from Doc class. I want to write something in combobox after some calculation(by Clicking in another button). Pls help anyone. Thanks

    L 1 Reply Last reply
    0
    • M m_mun

      Hi all, I have declared CComboBox m_comboBox; in MainFrame class Using it, I have created a combobox on toolbar. But I can't access it from Doc class. I want to write something in combobox after some calculation(by Clicking in another button). Pls help anyone. Thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Assuming the CComboBox is a public variable, you can get at it something like this:

      CMyApp* app = (CMyApp*)AfxGetApp();
      CMainFrame* frame = (CMainFrame*)app->m_pMainWnd;

      and then

      int selected_item = frame->m_comboBox.GetCurSel();

      _ 1 Reply Last reply
      0
      • L Lost User

        Assuming the CComboBox is a public variable, you can get at it something like this:

        CMyApp* app = (CMyApp*)AfxGetApp();
        CMainFrame* frame = (CMainFrame*)app->m_pMainWnd;

        and then

        int selected_item = frame->m_comboBox.GetCurSel();

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        LunaticFringe wrote:

        CMyApp* app = (CMyApp*)AfxGetApp(); CMainFrame* frame = (CMainFrame*)app->m_pMainWnd;

        You could also do this - CMainFrame* frame = (CMainFrame*)AfxGetMainWnd();

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        L 1 Reply Last reply
        0
        • _ _Superman_

          LunaticFringe wrote:

          CMyApp* app = (CMyApp*)AfxGetApp(); CMainFrame* frame = (CMainFrame*)app->m_pMainWnd;

          You could also do this - CMainFrame* frame = (CMainFrame*)AfxGetMainWnd();

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Yup. :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups