News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Group control

Started by K_F, December 19, 2013, 07:56:28 PM

Previous topic - Next topic

K_F

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

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

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

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

K_F

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

if all else fails set the size and or position
if the width or height is 0, it's not visible   :P

jj2007

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

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

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

    xor     ecx,ecx
    INVOKE  SetWindowPos,hControl,ecx,ecx,ecx,ecx,ecx,SWP_HIDEWINDOW or SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER

jj2007

Attached an example with two independently working groups of autoradiobuttons.
*dbg*.exe shows all window messages, and WM_PARENTNOTIFY in particular.

rsala

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

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

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.

;==============================================================================
    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

Quote from: MichaelW 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.
See my example.

QuoteThe 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

WS_TABSTOP can also be used with WS_GROUP'ed controls to modify tab behaviour