473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Radio button in groupbox is not generating WM_COMMAND

1,059 1GB
Hi,
Here a code part that create a group box and radio button
Expand|Select|Wrap|Line Numbers
  1. hGroup=CreateWindowEx(0,L"BUTTON",L"Choose Connection type", WS_CHILD|WS_VISIBLE|BS_GROUPBOX|WS_GROUP,30,180,300,85,hWnd,(HMENU)10006,hInstance, NULL);
  2. CreateWindowEx(0,L"BUTTON",L"Direct Connection",WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON, 10,17,280,30,hGroup,(HMENU) 10010,hInstance ,NULL);
  3. CreateWindowEx(0,L"BUTTON",L"XML Connection",WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON, 10,47,280,30,hGroup,(HMENU) 10011,hInstance,NULL);
  4.  
here is the part in WM_COMMAND..
Expand|Select|Wrap|Line Numbers
  1. case WM_COMMAND:
  2. wmId    = LOWORD(wParam);
  3. wmEvent = HIWORD(wParam);
  4. // Parse the menu selections:
  5. switch (wmId)
  6.   {
  7.    case 10010:
  8.     setRadiocehck(hGroup,GetDlgItem(hGroup,10010));
  9.         break;
  10.    case 10011:
  11.     setRadiocehck(hGroup,GetDlgItem(hGroup,10011));
  12.     break;  
  13.    }
  14.  
and this WM_COMMAND is related with hGroup window's Mother window i.e. main window in my program.

The problem is on click action 10010 or 10011 never get called.
I have realized one possible reason. The reason is the WndProc is related with main window it only process its child window but not grand child (:)) Radiobuttons are not main windows child. in that case what would be the best solution to toggle between radio buttons.

Please let me know.
Best regards,
Johny
Jul 16 '10 #1
3 6160
johny10151981
1,059 1GB
Well, got an sad answer there is no solution for it. :(
The reason is GROUPBOX is a static control. It wont generate any WM_COMMAND anyway
Jul 19 '10 #2
It most certainly can be done, here is sample code:

Expand|Select|Wrap|Line Numbers
  1. // Global
  2. WNDPROC GroupBoxProc;
  3.  
  4. LONG CALLBACK GroupRelay(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
  5.     if(msg == WM_COMMAND || msg == WM_NOTIFY){
  6.         return SendMessage(GetParent(hwnd), msg, wParam, lParam);
  7.     }
  8.  
  9.     return CallWindowProc(GroupBoxProc, hwnd, msg, wParam, lParam);
  10. }
  11.  
  12. //    WM_CREATE
  13.  
  14.     grpMailbox = CreateWindowEx(
  15.             WS_EX_CONTROLPARENT,
  16.             "BUTTON",
  17.             "Mailbox settings",
  18.             WS_CHILD | WS_VISIBLE | BS_GROUPBOX | WS_CLIPCHILDREN,
  19.             12, 12,
  20.             371, 131,
  21.             hwnd,
  22.             (HMENU)(GRPMAILBOX),
  23.             hInst,
  24.             NULL);
  25.  
  26.     GroupBoxProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(grpMailbox, GWLP_WNDPROC));
  27.     SetWindowLongPtr(grpMailbox, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(GroupRelay));
  28.  
This will relay all WM_COMMAND and WM_NOTIFY messages to the parent and pass the rest to the box as normal.

This code is directly from my working code, so it is verified working (Under XP SP3, but it should work in all others)

Note: Just in case you're not familiar, this is C++, in C replace reinterpret_cast<X> with (X)
Jul 26 '10 #3
johny10151981
1,059 1GB
OK
I will try this:)
thank you :)
Jul 27 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Woody Splawn | last post by:
I have a field in a database called Language. This field may contain a E for english or an S for spanish. I would like to use this field in conjunction with two radio buttons. I know how to drag...
3
by: SamSpade | last post by:
FOR WINDOWS FORMS I've been setting all Radio buttons in a group to Checked=False except the clicked one which I set to True. I just noticed the GroupName property and if I understand the doc...
2
by: Patrick | last post by:
Hello - I'm working on a VB program that uses two radio button collections - one of State, the other of Capitols. If the state is selected in collection1, then the appropriate capitol is selected...
10
by: Scuba Rob | last post by:
I am having problems on getting the radio button to work with my.settings correctly. I want the program to check to see which one was last saved to use at startup. The closest I have come is that I...
2
by: K Forester | last post by:
Hi, I am a complete beginner and need help with a form. There are 2 group boxes, each containing 3 radio buttons on my form. I'd like to write a subroutine in a module that checks to be sure that...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
2
by: Peted | last post by:
Hi Im using c# express edition 2005 I have an MDI form, where i load multiple child forms from a dll i create, using reflection and late binding The child forms have multiple radio...
8
by: photoboy | last post by:
I have racked by brain long enough on this, so now I need the help of someone who knows what they are doing. Here is what I am trying to achieve: First, I have two radio buttons (both unchecked)...
4
by: Tony | last post by:
Hello! If I have three radio buttons and place these on a form without using any GroupBox I can only select one at a time. I have always thought that the purpose to use GroupBox is to force...
5
by: Gotejjeken | last post by:
I have a form with four radio buttons and I want to store the value of the selected radio button (it's a poll and need to capture and record the user's response). I'm dynamically generating...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.