CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2005
    Posts
    98

    How do I add a variable to a control ?

    After I've designed a dialog with say, a ListBox... How do I connect the resource (display) with the CListBox variable in my main dialog class ?

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: How do I add a variable to a control ?

    I don't quite understand you, can you be more specific?? Possibly posting some minimal yet complete code? [please see my signature below....]
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: How do I add a variable to a control ?

    Take a look here. It's similar.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Feb 2005
    Posts
    98

    Re: How do I add a variable to a control ?

    The code is too complex to paste, but here is the problem:

    I created a dialog Project. In the main dialog I placed a ListBox control.
    I want to add a varaiable to the control so I can update the information displayed in it. I tried using the class wizard, which creates the control variable. But I can't access the variable from within my main dialog even though it is a member of that dialog.

    I was thinking that if I declare the CListBox m_listBox in the public section of the main dialog, and then attach is to the visual control, it might work. At least, it would help me understand it a little more if it doesn't work.

    Understand now ?

  5. #5
    Join Date
    Feb 2005
    Posts
    98

    Re: How do I add a variable to a control ?

    Yeah, that's what I was looking for. I've done it before but couldn't remember. What DDX function is used for a CListBox ? DDX_Text isn't the right one...

  6. #6
    Join Date
    Feb 2005
    Posts
    98

    Re: How do I add a variable to a control ?

    Nevermind... Found it. DDX_Control. :-)

  7. #7
    Join Date
    Feb 2005
    Posts
    98

    Re: How do I add a variable to a control ?

    I'm still having the same problem...

    Code:
    CDialog {
    ...
    
    public:
    
    CListBox m_ListBox;
    
        static BOOL CALLBACK GetWndName(HWND hWnd, LPARAM lParam){
    
            m_ListBox.AddString("HEY!");
        
         return TRUE;
      }
    ...
    }
    So I can't access the ListBox in that function. They are both declared in the public section of the same dialog. What's the deal?

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