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. CLabelControl problem

CLabelControl problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
2 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.
  • M Offline
    M Offline
    manju 3
    wrote on last edited by
    #1

    Hi all, Cant we hide a CLabelControl after declaring a variable..??? I am getting a run time error for this.

    Test.h
    CLabelControl m_Test;

    Test.cpp
    DDX_Control(pDX, IDC_LABEL_TEST, m_Test);

    BOOL CExampleDlg::OnInitDialog()
    {
    CLabelControl* lTest;
    lTest=(CLabelControl*)GetDlgItem(IDC_LABEL_TEST);
    lTest->ShowWindow(SW_HIDE);
    return true;
    }

    If i comment
    //CLabelControl m_Test; in Test.h
    //DDX_Control(pDX, IDC_LABEL_TEST, m_Test); in Test.pp

    Then it runs without any error.

    Can anyone have any idea Thanks in Advance Sharan

    K 1 Reply Last reply
    0
    • M manju 3

      Hi all, Cant we hide a CLabelControl after declaring a variable..??? I am getting a run time error for this.

      Test.h
      CLabelControl m_Test;

      Test.cpp
      DDX_Control(pDX, IDC_LABEL_TEST, m_Test);

      BOOL CExampleDlg::OnInitDialog()
      {
      CLabelControl* lTest;
      lTest=(CLabelControl*)GetDlgItem(IDC_LABEL_TEST);
      lTest->ShowWindow(SW_HIDE);
      return true;
      }

      If i comment
      //CLabelControl m_Test; in Test.h
      //DDX_Control(pDX, IDC_LABEL_TEST, m_Test); in Test.pp

      Then it runs without any error.

      Can anyone have any idea Thanks in Advance Sharan

      K Offline
      K Offline
      krmed
      wrote on last edited by
      #2

      Your label control does not exist at the point you are trying to hide it. You need to call CDialog::OnInitDialog in your OnInitDialog method before the control exists.

      BOOL CExampleDlg::OnInitDialog()
      {
      CDialog::OnInitDialog();
      CLabelControl* lTest;
      lTest=(CLabelControl*)GetDlgItem(IDC_LABEL_TEST);
      lTest->ShowWindow(SW_HIDE);
      return true;
      }

      Hope that helps.

      Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

      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