CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Radiobutton creation

    my aim is to select a radiobutton and then push a pushbutton. that pushbutton will retrieve the selected radiobutton's text..

  2. #17
    Join Date
    Jun 2008
    Posts
    592

    Re: Radiobutton creation

    Are you having trouble with knowing when you pressed the push button?
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  3. #18
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Radiobutton creation

    see.. i want to select a radiobutton and retrieve that radio's name by a messagebox by pressing a pushbutton..

  4. #19
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Radiobutton creation

    Quote Originally Posted by hypheni View Post
    ...
    Code:
    case WM_COMMAND:
    {
         switch(LOWORD(wParam))
         {
             case ID_RADIO1:
                 if ( HIWORD(wParam) == BN_CLICKED)
                 {
                     WCHAR text[100];
                     SendMessage((HWND)hRadio, WM_GETTEXT, 100, (LPARAM)text);
                     MessageBox(0,text,0,0);
                 }
            break;
         }
    }
    What does this "undefined" hRadio mean?
    Victor Nijegorodov

  5. #20
    Join Date
    Jun 2008
    Posts
    592

    Re: Radiobutton creation

    So I suppose that means yes? It is the same for any type of button

    Code:
    case WM_COMMAND:
    {
         switch(LOWORD(wParam))
         {
             case ID_PUSHBUTTON:
                 if ( HIWORD(wParam) == BN_CLICKED)
                 {
                     WCHAR text[100];
                     SendMessage((HWND)hRadio, WM_GETTEXT, 100, (LPARAM)text);
                     MessageBox(0,text,0,0);
                 }
            break;
         }
    }
    is that what you wanted?
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  6. #21
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Radiobutton creation

    Quote Originally Posted by hypheni View Post
    see.. i want to select a radiobutton and retrieve that radio's name by a messagebox by pressing a pushbutton..
    1. Which "radiobutton" from these ten do you want to "select?"
    2. How do you want to "select": using CheckRadioButton API or...?
    3. Please, don't post code with undefined identificators
    Victor Nijegorodov

  7. #22
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Radiobutton creation

    @..Victor N.

    HWND hRadio[10] is declared globally... and SendMessage() can not cast to HWND to HWND_ thats wht (HWND)hRadio.

    @..Joeman

    Ya this I need.. But in..
    SendMessage((HWND)hRadio, WM_GETTEXT, 100, (LPARAM)text);

    hRadio index should be mentioned.. here is the problem. selected radiobutton's index should be mentioned here..
    Last edited by hypheni; October 23rd, 2009 at 02:52 AM.

  8. #23
    Join Date
    Jun 2008
    Posts
    592

    Re: Radiobutton creation

    I suppose you can loop through each radio button and check to see which is checked with IsDlgButtonChecked or SendMessage.. for ex

    Code:
                            
    //loop code
    LRESULT lResult = SendMessage( hRadio[i], BM_GETCHECK, 0, 0 );
    bool Checked = lResult == BST_CHECKED;
    if( Checked ) RadioId = i;
    //end of loop code
    now you have the Id in RadioId
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  9. #24
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Radiobutton creation

    @..VictorN

    i have checked radiobutton 1.. by putting
    CheckRadioButton(hReIP, ID_RADIO1, ID_RADIO10, ID_RADIO1);
    in WM_INITDIALOG.

  10. #25
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Radiobutton creation

    @..Joeman

    I think this code is going to be useful for me. Let me implement it a bit more.. Thanks..

Page 2 of 2 FirstFirst 12

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