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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Dynamic controls

Dynamic controls

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 2 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.
  • R Offline
    R Offline
    richiebabes
    wrote on last edited by
    #1

    I have a property page that is used multiple times in a wizard with slight variations each time. Therefore for each instance of the page I want to show/not show various controls. How do I do that? I thought I could just make a control variable and then do something like m_nListBox1.SetVisible or something or other. How do I dynamically make controls visible and invisible? I am missing something obvious and it must be because I got up far too early this morning.

    Y 1 Reply Last reply
    0
    • R richiebabes

      I have a property page that is used multiple times in a wizard with slight variations each time. Therefore for each instance of the page I want to show/not show various controls. How do I do that? I thought I could just make a control variable and then do something like m_nListBox1.SetVisible or something or other. How do I dynamically make controls visible and invisible? I am missing something obvious and it must be because I got up far too early this morning.

      Y Offline
      Y Offline
      Yawar Maajed
      wrote on last edited by
      #2

      use CWnd::ShowWindow function to show or hide them.

      R 1 Reply Last reply
      0
      • Y Yawar Maajed

        use CWnd::ShowWindow function to show or hide them.

        R Offline
        R Offline
        richiebabes
        wrote on last edited by
        #3

        Tried this in OnInitDialog and OnSetActive. Causes and assertion both times.

        Y 1 Reply Last reply
        0
        • R richiebabes

          Tried this in OnInitDialog and OnSetActive. Causes and assertion both times.

          Y Offline
          Y Offline
          Yawar Maajed
          wrote on last edited by
          #4

          ShowWindow is THE API to use to show and hide windows, if your window does not exist yet, the function will assert. Try making sure that the window you are calling this function on is valid before you call this function. an exmaple of this would be Page::OnInitDialog(); { BOOL ret = CPropertyPage::OnInitDialog(); CWnd *pWnd = GetDlgItem(IDC_MY_WINDOW); if (!pWnd || !::IsWindow(pWnd->GetSafeHwnd()) { ASSERT(FALSE); } else pWnd->ShowWindow(SW_HIDE); // or whatever you want to do with it. } Did you use classwizard to generate control variables for your window objects? /yawar

          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