CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Binding Data to Silverlight 4.0 Controls Using ASP.NET MVC Framework 2.0
  • ADO.NET Data Services in the .NET Framework
  • Visual C++ Programming: What's new for MFC library in VC++ 2010?
  • Microsoft Visual Studio LightSwitch and What It Can Do For You

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Reply
     
    Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
      #1    
    Old August 12th, 2004, 12:07 PM
    harshaperla's Avatar
    harshaperla harshaperla is offline
    Junior Member
     
    Join Date: Mar 2004
    Location: Bangalore,karnataka,India
    Posts: 13
    harshaperla is an unknown quantity at this point (<10)
    Question array of buttons in VC++

    i tried making an array of buttons when programming using class vizard. i did it using image button and also using direct coding. in VB it is possible bu copying the buttons. i have written a common message handler for btton's On click operation. but i need to reffer it by common name. is it possible?
    Reply With Quote
      #2    
    Old August 13th, 2004, 01:48 AM
    atif_husain atif_husain is offline
    Junior Member
     
    Join Date: Jun 2004
    Posts: 7
    atif_husain is an unknown quantity at this point (<10)
    Re: Array of buttons in VC++

    I don;t understand what you mean by common names but it is very easy if you keep a member integer vairable in your button class and in the OnClick handler put a check on that integer variable you can determine which button was clicked....
    Reply With Quote
      #3    
    Old August 13th, 2004, 02:58 AM
    cilu's Avatar
    cilu cilu is offline
    Moderator/Reviewer/MS MVP
    Power Poster
     
    Join Date: Oct 2002
    Location: Timisoara, Romania
    Posts: 13,910
    cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)
    What exactly are you trying to do? You want to have several buttons having the same handler? You can use ON_COMMAND_RANGE macro to map a range of command IDs to the same handler.
    __________________
    Marius Bancila
    Home Page | Blog
    My CodeGuru articles

    My latest articles: Visual Studio 2010 series: VC++, C++ compiler, MFC

    Try my VSBuildStatus add-in for Visual Studio 2005, 2008 & 2010 (v1.2.0).
    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

    Please answer my multi-core and concurrency questionnaire.
    Reply With Quote
      #4    
    Old August 14th, 2004, 05:47 AM
    harshaperla's Avatar
    harshaperla harshaperla is offline
    Junior Member
     
    Join Date: Mar 2004
    Location: Bangalore,karnataka,India
    Posts: 13
    harshaperla is an unknown quantity at this point (<10)
    Arrow I need to control set of buttons in aloop

    I have written a common handler for the set of buttons. But, i need to address them like

    m_Button[i][j].SetWindowText("XXXX");
    in a loop. i did it by changing the declaration of button as CButton m_Button[5][5];
    but after that i could not go to class-wizard.
    __________________
    Harsha Perla
    http://electrosofts.com
    Reply With Quote
      #5    
    Old August 14th, 2004, 07:10 AM
    cilu's Avatar
    cilu cilu is offline
    Moderator/Reviewer/MS MVP
    Power Poster
     
    Join Date: Oct 2002
    Location: Timisoara, Romania
    Posts: 13,910
    cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)cilu has a reputation beyond repute (3000+)
    Here an example for an array of 2 buttons.

    In the header declare:
    Code:
    typedef CButton CMyButton[2];
    and use it in AFX_DATA
    Code:
    //{{AFX_DATA(CGeneralTestDlgDlg)
    enum { IDD = IDD_GENERALTESTDLG_DIALOG };
    CMyButton  m_button;
    //}}AFX_DATA
    In the source file write the DoDataExchange like this:
    Code:
    void CGeneralTestDlgDlg::DoDataExchange(CDataExchange* pDX)
    {
      CButton &but1 = m_button[0];
      CButton &but2 = m_button[1];
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CGeneralTestDlgDlg)
      DDX_Control(pDX, IDC_BUTTON2, but1);
      DDX_Control(pDX, IDC_BUTTON1, but2);
      //}}AFX_DATA_MAP
    }
    Now you will be able to use the class wizzard and have buttons array.
    __________________
    Marius Bancila
    Home Page | Blog
    My CodeGuru articles

    My latest articles: Visual Studio 2010 series: VC++, C++ compiler, MFC

    Try my VSBuildStatus add-in for Visual Studio 2005, 2008 & 2010 (v1.2.0).
    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

    Please answer my multi-core and concurrency questionnaire.
    Reply With Quote
      #6    
    Old August 24th, 2004, 01:32 PM
    harshaperla's Avatar
    harshaperla harshaperla is offline
    Junior Member
     
    Join Date: Mar 2004
    Location: Bangalore,karnataka,India
    Posts: 13
    harshaperla is an unknown quantity at this point (<10)
    Lightbulb Re: array of buttons in VC++

    got the solution:
    result is there as a article here: Implementation of Array of Buttons: The Shuffle Game:
    __________________
    Harsha Perla
    http://electrosofts.com
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 09:03 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.