Author Topic: Group control  (Read 13724 times)

K_F

  • Member
  • *****
  • Posts: 1372
  • Anybody out there?
Group control
« on: December 19, 2013, 07:56:28 PM »
Having a moment   :idea:

With a visual project.. what type of control is the GROUP box ?
I'm trying to make it invisible when not used...

I've tried ShowWindow, but that doesn't seem to work...
Would it be a SetWindowLong property setting ?

Cannot seem to find any info on this... maybe I'm looking in the wrong place
 :icon_eek:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

dedndave

  • Member
  • *****
  • Posts: 8789
  • Still using Abacus 2.0
    • DednDave
Re: Group control
« Reply #1 on: December 19, 2013, 08:13:06 PM »
i don't think it's really a control - it's a style assigned to a group of controls
BS_GROUPBOX, WS_GROUP, WS_TABSTOP

dedndave

  • Member
  • *****
  • Posts: 8789
  • Still using Abacus 2.0
    • DednDave
Re: Group control
« Reply #2 on: December 19, 2013, 08:20:55 PM »
my mistake   :P

http://msdn.microsoft.com/en-us/library/windows/desktop/aa511459.aspx

it appears to be a .NET form

http://msdn.microsoft.com/en-us/library/windows/desktop/dd318098%28v=vs.85%29.aspx

but, essentially a button class

Quote
The window class name for a group box is "BUTTON".
so, i guess you make a button with BS_GROUPBOX style

K_F

  • Member
  • *****
  • Posts: 1372
  • Anybody out there?
Re: Group control
« Reply #3 on: December 19, 2013, 10:31:56 PM »
Thanks.. 'I can see clearly now.. the rain has gone'  :icon_mrgreen:
It looks like I must swop the WS_VISIBLE style in and out.. I'll try this.
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

dedndave

  • Member
  • *****
  • Posts: 8789
  • Still using Abacus 2.0
    • DednDave
Re: Group control
« Reply #4 on: December 19, 2013, 11:01:36 PM »
if all else fails set the size and or position
if the width or height is 0, it's not visible   :P

jj2007

  • Member
  • *****
  • Posts: 8439
  • Assembler is fun ;-)
    • MasmBasic
Re: Group control
« Reply #5 on: December 19, 2013, 11:02:27 PM »
It draws a frame around other controls. If I remember well, it serves also to delimit the scope of autoradiobuttons. For example, you may have two sets of BS_AUTORADIOBUTTON controls - there must be a way to decide which two buttons are active.

K_F

  • Member
  • *****
  • Posts: 1372
  • Anybody out there?
Re: Group control
« Reply #6 on: December 19, 2013, 11:31:00 PM »
It must have something to do the the Group Style... I've checked my handles, and message parameters... all looks OK
Yet it still fails on ShowWindow and SetWindowLong... ??
 :icon_exclaim:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

K_F

  • Member
  • *****
  • Posts: 1372
  • Anybody out there?
Re: Group control
« Reply #7 on: December 20, 2013, 02:40:46 AM »
Not to worry.. I'm onto it....
My handles are now being zero'ed where I've yet to find out :-)
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

dedndave

  • Member
  • *****
  • Posts: 8789
  • Still using Abacus 2.0
    • DednDave
Re: Group control
« Reply #8 on: December 20, 2013, 03:28:14 AM »
Code: [Select]
    xor     ecx,ecx
    INVOKE  SetWindowPos,hControl,ecx,ecx,ecx,ecx,ecx,SWP_HIDEWINDOW or SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER

jj2007

  • Member
  • *****
  • Posts: 8439
  • Assembler is fun ;-)
    • MasmBasic
Re: Group control
« Reply #9 on: December 20, 2013, 04:53:32 AM »
Attached an example with two independently working groups of autoradiobuttons.
*dbg*.exe shows all window messages, and WM_PARENTNOTIFY in particular.

rsala

  • Moderator
  • Member
  • *****
  • Posts: 266
    • Easy Code
Re: Group control
« Reply #10 on: December 21, 2013, 07:17:07 AM »
Hi K_F,

First of all you have to get the Group's handle with the GetWindowItem method. For example, if the Window name is Window1 and the Group name is Group1, the code would be the following (hWnd is the handle of the window where the Group is in):

    Invoke GetWindowItem, hWnd, IDC_WINDOW1_GROUP1

After that call , the Group's handle is in Eax register. Then you can hide the group by using the ShowWindow API call:

    Invoke ShowWindow, Eax, SW_HIDE

Or by using the SetVisible method:

    Invoke SetVisible, Eax, FALSE

I attach a simple example for you to see how to Show / Hide a Group control.

Regards,

Ramon
EC coder

jj2007

  • Member
  • *****
  • Posts: 8439
  • Assembler is fun ;-)
    • MasmBasic
Re: Group control
« Reply #11 on: December 21, 2013, 07:27:00 AM »
Ramon,

The interesting question here seems how to get two groups of controls (here: BS_AUTORADIOBUTTON) working independently, as shown in this screenshot of the app posted above.

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Group control
« Reply #12 on: December 21, 2013, 10:32:53 AM »
There are apparently two methods of grouping radio buttons into functional sets. One is to make each button in the set a child of a group box. The other is to apply the WS_GROUP style to the first button in the set, so the set will extend up to, but not including, the next button in the tab order that has the WS_GROUP style.
Code: [Select]
;==============================================================================
    include \masm32\include\masm32rt.inc
;==============================================================================
    .data
        state           dd 0
    .code
;==============================================================================
DlgProc proc hwndDlg:dword, uMsg:dword, wParam:dword, lParam:dword
    SWITCH uMsg
      CASE WM_COMMAND
        SWITCH wParam
          CASE IDCANCEL
            invoke EndDialog, hwndDlg, 0
        ENDSW
      CASE WM_CLOSE
        invoke EndDialog, hwndDlg, 0
    ENDSW
    xor eax, eax
    ret
DlgProc endp
;==============================================================================
start:
;==============================================================================
    Dialog "Test", "MS Sans Serif",10, \
           WS_OVERLAPPED or WS_SYSMENU or DS_CENTER, \
           4,0,0,200,150,1024
    DlgRadio "AutoRadioButton1",WS_TABSTOP or WS_GROUP,65,30,70,10,100
    DlgRadio "AutoRadioButton2",WS_TABSTOP,65,50,70,10,200
    DlgRadio "AutoRadioButton3",WS_TABSTOP or WS_GROUP,65,80,70,10,300
    DlgRadio "AutoRadioButton4",WS_TABSTOP,65,100,70,10,400
    invoke GetModuleHandle, NULL
    CallModalDialog eax,0,DlgProc,NULL
    exit
;==============================================================================
end start
Well Microsoft, here’s another nice mess you’ve gotten us into.

jj2007

  • Member
  • *****
  • Posts: 8439
  • Assembler is fun ;-)
    • MasmBasic
Re: Group control
« Reply #13 on: December 21, 2013, 12:02:06 PM »
There are apparently two methods of grouping radio buttons into functional sets. One is to make each button in the set a child of a group box.
See my example.

Quote
The other is to apply the WS_GROUP style to the first button in the set, so the set will extend up to, but not including, the next button in the tab order that has the WS_GROUP style.

Good to know :t
It doesn't paint the group rectangle, though, but apparently that is exactly what the OP wanted.

dedndave

  • Member
  • *****
  • Posts: 8789
  • Still using Abacus 2.0
    • DednDave
Re: Group control
« Reply #14 on: December 21, 2013, 08:46:52 PM »
WS_TABSTOP can also be used with WS_GROUP'ed controls to modify tab behaviour