CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 25

Threaded View

  1. #14
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Radiobutton creation

    Okaay.. See my code.. This is for creating those RadioButtons.. This is working perfectly well..

    Code:
    #define ID_RADIO1		        1034
    #define ID_RADIO2		        1035
    #define ID_RADIO3		        1036
    #define ID_RADIO4		        1037
    #define ID_RADIO5		        1038
    #define ID_RADIO6		        1039
    
    
    int i=0;
    HWND hRadio [10];              //Maximum 10 RadioButtons
    while (some condition)
    {
        hRadio[i] = CreateWindowEx(0, L"BUTTON", 0, WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,                   
                                                       26, hi, 140, 20, hReIP, (HMENU)1034+i, hIns, 0);
        SetWindowText(hRadio[i], lpHold); 
        SendMessage(hRadio[i], WM_SETFONT, (WPARAM)hFont, 0);
        hi+=18;
        i++;
    }
    Now, the message handling code.. where Im having the actual problem.. See I need to choose only one radio button at a time and process that RadioButton while pressing a PUSHBUTTON to get the RadioButton's name.

    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;
         }
    }
    But this is handling just 1st radio button which in fact working but if i process same way IDB_RADIO2 and so on it's not working for those buttons. and I need to process radiobutton with a pushbutton.
    Last edited by hypheni; October 23rd, 2009 at 01:32 AM.

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