Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #11215 > unrolled thread

List of buttons (controls) in window

Started by"Grzegorz R." <ramotny64@gmail.com>
First post2017-12-06 00:41 -0800
Last post2017-12-10 11:32 +0100
Articles 9 — 4 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  List of buttons (controls) in window "Grzegorz R." <ramotny64@gmail.com> - 2017-12-06 00:41 -0800
    Re: List of buttons (controls) in window Franz Rachbauer <office@rachbauer.org> - 2017-12-06 10:53 +0100
      Re: List of buttons (controls) in window "Grzegorz R." <ramotny64@gmail.com> - 2017-12-06 02:30 -0800
        Re: List of buttons (controls) in window Franz Rachbauer <office@rachbauer.org> - 2017-12-06 14:19 +0100
      Re: List of buttons (controls) in window "Jamal" <noooospam@example.com> - 2017-12-06 10:13 -0500
        Re: List of buttons (controls) in window Franz Rachbauer <office@rachbauer.org> - 2017-12-06 17:47 +0100
          Re: List of buttons (controls) in window "Grzegorz R." <ramotny64@gmail.com> - 2017-12-06 12:29 -0800
            Re: List of buttons (controls) in window Franz Rachbauer <office@rachbauer.org> - 2017-12-07 09:34 +0100
            Re: List of buttons (controls) in window "Karl-Heinz" <invalid@invalid.invalid> - 2017-12-10 11:32 +0100

#11215 — List of buttons (controls) in window

From"Grzegorz R." <ramotny64@gmail.com>
Date2017-12-06 00:41 -0800
SubjectList of buttons (controls) in window
Message-ID<011e8257-ff1b-4eb6-a7c1-14462895ecdf@googlegroups.com>
Hello Friends

I need to enable/disable and/or make readonly true/false some controls on my window but there is a lot of them and listing explicitly requires a lot of writing/coding.

I can easily change state of SINGLELINEEDITs with:

CLASS MyEdit INHERIT SINGLELINEEDIT
...
METHOD ChgState(lFlag) CLASS MyEdit
	SELF:ReadOnly:=lFlag
RETURN NIL
...
// TestWin has SINGLEEDITLINES that inherit from MyEdit

METHOD SetState(lFlag) CLASS TestWin
	LOCAL I AS DWORD
	FOR I:=1 UPTO ALen(SELF:aControls)
		IF IsMethod(SELF:aControls[I],#CHGSTATE)
			SELF:aControls[I]:ChgState(lControlsState)
		ENDIF
	NEXT	
RETURN NIL

However aControls does not include pushbuttons (and maybe other controls).

How can I do the same ie. get list of existing pushbuttons (and other controls not included in aControls) in window and process them in loop?
Or maybe another way exist to change state (enable/disable) a bunch of different types of controls?

Best regards
Gregory

[toc] | [next] | [standalone]


#11216

FromFranz Rachbauer <office@rachbauer.org>
Date2017-12-06 10:53 +0100
Message-ID<p08emc$1abb$1@gioia.aioe.org>
In reply to#11215
Hi Gregory,
I use the following to get the controls I need:

METHOD GetControls() CLASS RedimDataWindow
LOCAL aControls     AS ARRAY
LOCAL oC            AS VObject
LOCAL hWnd          AS PTR

hWnd        := GetWindow( SELF:oSurface:Handle(), GW_CHILD )
aControls   := {}
WHILE hWnd != NULL_PTR
	oC      := GetObjectByHandle( hWnd )
	IF IsInstanceOfUsual( oC, #BUTTON )
		AAdd( aControls, oC )
	ENDIF
	hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
ENDDO
RETURN aControls

Then I have an array of Buttons which I can hide/disable like
aControls[nVal]:Hide()

Regards, Franz

Am 06.12.2017 um 09:41 schrieb Grzegorz R.:
> Hello Friends
> 
> I need to enable/disable and/or make readonly true/false some controls on my window but there is a lot of them and listing explicitly requires a lot of writing/coding.
> 
> I can easily change state of SINGLELINEEDITs with:
> 
> CLASS MyEdit INHERIT SINGLELINEEDIT
> ...
> METHOD ChgState(lFlag) CLASS MyEdit
> 	SELF:ReadOnly:=lFlag
> RETURN NIL
> ...
> // TestWin has SINGLEEDITLINES that inherit from MyEdit
> 
> METHOD SetState(lFlag) CLASS TestWin
> 	LOCAL I AS DWORD
> 	FOR I:=1 UPTO ALen(SELF:aControls)
> 		IF IsMethod(SELF:aControls[I],#CHGSTATE)
> 			SELF:aControls[I]:ChgState(lControlsState)
> 		ENDIF
> 	NEXT	
> RETURN NIL
> 
> However aControls does not include pushbuttons (and maybe other controls).
> 
> How can I do the same ie. get list of existing pushbuttons (and other controls not included in aControls) in window and process them in loop?
> Or maybe another way exist to change state (enable/disable) a bunch of different types of controls?
> 
> Best regards
> Gregory
> 
> 

[toc] | [prev] | [next] | [standalone]


#11218

From"Grzegorz R." <ramotny64@gmail.com>
Date2017-12-06 02:30 -0800
Message-ID<f84a0c09-153d-430d-9b77-e16523f45ca7@googlegroups.com>
In reply to#11216
W dniu środa, 6 grudnia 2017 10:53:18 UTC+1 użytkownik Franz Rachbauer napisał:
> Hi Gregory,
> I use the following to get the controls I need:
> 
> METHOD GetControls() CLASS RedimDataWindow
> LOCAL aControls     AS ARRAY
> LOCAL oC            AS VObject
> LOCAL hWnd          AS PTR
> 
> hWnd        := GetWindow( SELF:oSurface:Handle(), GW_CHILD )
> aControls   := {}
> WHILE hWnd != NULL_PTR
> 	oC      := GetObjectByHandle( hWnd )
> 	IF IsInstanceOfUsual( oC, #BUTTON )
> 		AAdd( aControls, oC )
> 	ENDIF
> 	hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
> ENDDO
> RETURN aControls
> 
> Then I have an array of Buttons which I can hide/disable like
> aControls[nVal]:Hide()
> 
> Regards, Franz
> 
> Am 06.12.2017 um 09:41 schrieb Grzegorz R.:
> > Hello Friends
> > 
> > I need to enable/disable and/or make readonly true/false some controls on my window but there is a lot of them and listing explicitly requires a lot of writing/coding.
> > 
> > I can easily change state of SINGLELINEEDITs with:
> > 
> > CLASS MyEdit INHERIT SINGLELINEEDIT
> > ...
> > METHOD ChgState(lFlag) CLASS MyEdit
> > 	SELF:ReadOnly:=lFlag
> > RETURN NIL
> > ...
> > // TestWin has SINGLEEDITLINES that inherit from MyEdit
> > 
> > METHOD SetState(lFlag) CLASS TestWin
> > 	LOCAL I AS DWORD
> > 	FOR I:=1 UPTO ALen(SELF:aControls)
> > 		IF IsMethod(SELF:aControls[I],#CHGSTATE)
> > 			SELF:aControls[I]:ChgState(lControlsState)
> > 		ENDIF
> > 	NEXT	
> > RETURN NIL
> > 
> > However aControls does not include pushbuttons (and maybe other controls).
> > 
> > How can I do the same ie. get list of existing pushbuttons (and other controls not included in aControls) in window and process them in loop?
> > Or maybe another way exist to change state (enable/disable) a bunch of different types of controls?
> > 
> > Best regards
> > Gregory
> > 
> >

Hi Franz,
thanks for quick reply - I'll surely try it. I was afraid it will be deeper than regular VO.
Are there any other controls beside #BUTTONS that can be identified this way? Link to MS page is enough... (searching IsInstanceOfUsual failed)...

Best regards
Gregory

[toc] | [prev] | [next] | [standalone]


#11220

FromFranz Rachbauer <office@rachbauer.org>
Date2017-12-06 14:19 +0100
Message-ID<p08qpb$1qnm$1@gioia.aioe.org>
In reply to#11218
Hi Gregory,
IsInstanceOfUsual() => Function in VO.
I think you can use IsInstanceOfUsual() for all Control Classes, e.g. 
#BASELISTBOX, #EDIT, and so on.
Regards, Franz

Am 06.12.2017 um 11:30 schrieb Grzegorz R.:
> W dniu środa, 6 grudnia 2017 10:53:18 UTC+1 użytkownik Franz Rachbauer napisał:
>> Hi Gregory,
>> I use the following to get the controls I need:
>>
>> METHOD GetControls() CLASS RedimDataWindow
>> LOCAL aControls     AS ARRAY
>> LOCAL oC            AS VObject
>> LOCAL hWnd          AS PTR
>>
>> hWnd        := GetWindow( SELF:oSurface:Handle(), GW_CHILD )
>> aControls   := {}
>> WHILE hWnd != NULL_PTR
>> 	oC      := GetObjectByHandle( hWnd )
>> 	IF IsInstanceOfUsual( oC, #BUTTON )
>> 		AAdd( aControls, oC )
>> 	ENDIF
>> 	hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
>> ENDDO
>> RETURN aControls
>>
>> Then I have an array of Buttons which I can hide/disable like
>> aControls[nVal]:Hide()
>>
>> Regards, Franz
>>
>> Am 06.12.2017 um 09:41 schrieb Grzegorz R.:
>>> Hello Friends
>>>
>>> I need to enable/disable and/or make readonly true/false some controls on my window but there is a lot of them and listing explicitly requires a lot of writing/coding.
>>>
>>> I can easily change state of SINGLELINEEDITs with:
>>>
>>> CLASS MyEdit INHERIT SINGLELINEEDIT
>>> ...
>>> METHOD ChgState(lFlag) CLASS MyEdit
>>> 	SELF:ReadOnly:=lFlag
>>> RETURN NIL
>>> ...
>>> // TestWin has SINGLEEDITLINES that inherit from MyEdit
>>>
>>> METHOD SetState(lFlag) CLASS TestWin
>>> 	LOCAL I AS DWORD
>>> 	FOR I:=1 UPTO ALen(SELF:aControls)
>>> 		IF IsMethod(SELF:aControls[I],#CHGSTATE)
>>> 			SELF:aControls[I]:ChgState(lControlsState)
>>> 		ENDIF
>>> 	NEXT	
>>> RETURN NIL
>>>
>>> However aControls does not include pushbuttons (and maybe other controls).
>>>
>>> How can I do the same ie. get list of existing pushbuttons (and other controls not included in aControls) in window and process them in loop?
>>> Or maybe another way exist to change state (enable/disable) a bunch of different types of controls?
>>>
>>> Best regards
>>> Gregory
>>>
>>>
> 
> Hi Franz,
> thanks for quick reply - I'll surely try it. I was afraid it will be deeper than regular VO.
> Are there any other controls beside #BUTTONS that can be identified this way? Link to MS page is enough... (searching IsInstanceOfUsual failed)...
> 
> Best regards
> Gregory
> 

[toc] | [prev] | [next] | [standalone]


#11221

From"Jamal" <noooospam@example.com>
Date2017-12-06 10:13 -0500
Message-ID<p091e0$v39$1@news.albasani.net>
In reply to#11216
Hi Franz,

Instead of hard coding the type of controls. I think your method (for fun; 
not tested) can be changed to a function like:


FUNCTION GetDataWindowControls(oOwner as OBJECT, symClassType AS SYMBOL) AS 
ARRAY PASCAL
LOCAL aControls     AS ARRAY
LOCAL oC            AS VObject
LOCAL hWnd          AS PTR

hWnd        := GetWindow( oOwner :oSurface:Handle(), GW_CHILD )
aControls   := {}

WHILE hWnd != NULL_PTR
      oC      := GetObjectByHandle( hWnd )
      IF IsInstanceOfUsual( oC, symClassType )
            AAdd( aControls, oC )
       ENDIF

       hWnd    := GetWindow( hWnd, GW_HWNDNEXT )

ENDDO

RETURN aControls

Then it call as:

aButtons := GetDataWindowControls(SELF, #BUTTON)
aSingleLineEdits :=  GetDataWindowControls(SELF, #SINGLELINEEDIT)

FUNCTION HideControls(oOwner as OBJECT, aControls AS OBJECT, lHide as LOGIC) 
AS VOID PASCAL
LOCAL dwLength := ALen(aControls) as DWORD
LOCAL j as DWORD

FOR j = 1 upto dwLength
        if lHide
            oOwner:aControls[j].Hide()
         else
            oOwner:aControls[j].Show()
        endif
NEXT

RETURN

Samples:

HideControls(self, aButtons, true)

HideControls(SELF, GetDataWindowControls(SELF, #BUTTON), TRUE)         // 
one call

etc

Jamal


"Franz Rachbauer"  wrote in message news:p08emc$1abb$1@gioia.aioe.org...

Hi Gregory,
I use the following to get the controls I need:

METHOD GetControls() CLASS RedimDataWindow
LOCAL aControls     AS ARRAY
LOCAL oC            AS VObject
LOCAL hWnd          AS PTR

hWnd        := GetWindow( SELF:oSurface:Handle(), GW_CHILD )
aControls   := {}
WHILE hWnd != NULL_PTR
oC      := GetObjectByHandle( hWnd )
IF IsInstanceOfUsual( oC, #BUTTON )
AAdd( aControls, oC )
ENDIF
hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
ENDDO
RETURN aControls

Then I have an array of Buttons which I can hide/disable like
aControls[nVal]:Hide()

Regards, Franz

Am 06.12.2017 um 09:41 schrieb Grzegorz R.:
> Hello Friends
>
> I need to enable/disable and/or make readonly true/false some controls on 
> my window but there is a lot of them and listing explicitly requires a lot 
> of writing/coding.
>
> I can easily change state of SINGLELINEEDITs with:
>
> CLASS MyEdit INHERIT SINGLELINEEDIT
> ...
> METHOD ChgState(lFlag) CLASS MyEdit
> SELF:ReadOnly:=lFlag
> RETURN NIL
> ...
> // TestWin has SINGLEEDITLINES that inherit from MyEdit
>
> METHOD SetState(lFlag) CLASS TestWin
> LOCAL I AS DWORD
> FOR I:=1 UPTO ALen(SELF:aControls)
> IF IsMethod(SELF:aControls[I],#CHGSTATE)
> SELF:aControls[I]:ChgState(lControlsState)
> ENDIF
> NEXT RETURN NIL
>
> However aControls does not include pushbuttons (and maybe other controls).
>
> How can I do the same ie. get list of existing pushbuttons (and other 
> controls not included in aControls) in window and process them in loop?
> Or maybe another way exist to change state (enable/disable) a bunch of 
> different types of controls?
>
> Best regards
> Gregory
>
> 

[toc] | [prev] | [next] | [standalone]


#11222

FromFranz Rachbauer <office@rachbauer.org>
Date2017-12-06 17:47 +0100
Message-ID<p096us$cer$1@gioia.aioe.org>
In reply to#11221
Hi Jamal,
this is a variable way to show/hide controls on any window. I think 
Gregory will be delighted. My method only was a cut excerpt of an 
extensive base class I often use.

Thanks, Franz

Am 06.12.2017 um 16:13 schrieb Jamal:
> Hi Franz,
> 
> Instead of hard coding the type of controls. I think your method (for 
> fun; not tested) can be changed to a function like:
> 
> 
> FUNCTION GetDataWindowControls(oOwner as OBJECT, symClassType AS SYMBOL) 
> AS ARRAY PASCAL
> LOCAL aControls     AS ARRAY
> LOCAL oC            AS VObject
> LOCAL hWnd          AS PTR
> 
> hWnd        := GetWindow( oOwner :oSurface:Handle(), GW_CHILD )
> aControls   := {}
> 
> WHILE hWnd != NULL_PTR
>       oC      := GetObjectByHandle( hWnd )
>       IF IsInstanceOfUsual( oC, symClassType )
>             AAdd( aControls, oC )
>        ENDIF
> 
>        hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
> 
> ENDDO
> 
> RETURN aControls
> 
> Then it call as:
> 
> aButtons := GetDataWindowControls(SELF, #BUTTON)
> aSingleLineEdits :=  GetDataWindowControls(SELF, #SINGLELINEEDIT)
> 
> FUNCTION HideControls(oOwner as OBJECT, aControls AS OBJECT, lHide as 
> LOGIC) AS VOID PASCAL
> LOCAL dwLength := ALen(aControls) as DWORD
> LOCAL j as DWORD
> 
> FOR j = 1 upto dwLength
>         if lHide
>             oOwner:aControls[j].Hide()
>          else
>             oOwner:aControls[j].Show()
>         endif
> NEXT
> 
> RETURN
> 
> Samples:
> 
> HideControls(self, aButtons, true)
> 
> HideControls(SELF, GetDataWindowControls(SELF, #BUTTON), TRUE)         
> // one call
> 
> etc
> 
> Jamal
> 
> 
> "Franz Rachbauer"  wrote in message news:p08emc$1abb$1@gioia.aioe.org...
> 
> Hi Gregory,
> I use the following to get the controls I need:
> 
> METHOD GetControls() CLASS RedimDataWindow
> LOCAL aControls     AS ARRAY
> LOCAL oC            AS VObject
> LOCAL hWnd          AS PTR
> 
> hWnd        := GetWindow( SELF:oSurface:Handle(), GW_CHILD )
> aControls   := {}
> WHILE hWnd != NULL_PTR
> oC      := GetObjectByHandle( hWnd )
> IF IsInstanceOfUsual( oC, #BUTTON )
> AAdd( aControls, oC )
> ENDIF
> hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
> ENDDO
> RETURN aControls
> 
> Then I have an array of Buttons which I can hide/disable like
> aControls[nVal]:Hide()
> 
> Regards, Franz
> 
> Am 06.12.2017 um 09:41 schrieb Grzegorz R.:
>> Hello Friends
>>
>> I need to enable/disable and/or make readonly true/false some controls 
>> on my window but there is a lot of them and listing explicitly 
>> requires a lot of writing/coding.
>>
>> I can easily change state of SINGLELINEEDITs with:
>>
>> CLASS MyEdit INHERIT SINGLELINEEDIT
>> ...
>> METHOD ChgState(lFlag) CLASS MyEdit
>> SELF:ReadOnly:=lFlag
>> RETURN NIL
>> ...
>> // TestWin has SINGLEEDITLINES that inherit from MyEdit
>>
>> METHOD SetState(lFlag) CLASS TestWin
>> LOCAL I AS DWORD
>> FOR I:=1 UPTO ALen(SELF:aControls)
>> IF IsMethod(SELF:aControls[I],#CHGSTATE)
>> SELF:aControls[I]:ChgState(lControlsState)
>> ENDIF
>> NEXT RETURN NIL
>>
>> However aControls does not include pushbuttons (and maybe other 
>> controls).
>>
>> How can I do the same ie. get list of existing pushbuttons (and other 
>> controls not included in aControls) in window and process them in loop?
>> Or maybe another way exist to change state (enable/disable) a bunch of 
>> different types of controls?
>>
>> Best regards
>> Gregory
>>
>>

[toc] | [prev] | [next] | [standalone]


#11223

From"Grzegorz R." <ramotny64@gmail.com>
Date2017-12-06 12:29 -0800
Message-ID<42182560-82c2-4e81-86b0-8b5864a32f12@googlegroups.com>
In reply to#11222
W dniu środa, 6 grudnia 2017 17:47:28 UTC+1 użytkownik Franz Rachbauer napisał:
> Hi Jamal,
> this is a variable way to show/hide controls on any window. I think 
> Gregory will be delighted. My method only was a cut excerpt of an 
> extensive base class I often use.
> 
> Thanks, Franz
> 
> Am 06.12.2017 um 16:13 schrieb Jamal:
> > Hi Franz,
> > 
> > Instead of hard coding the type of controls. I think your method (for 
> > fun; not tested) can be changed to a function like:
> > 
> > 
> > FUNCTION GetDataWindowControls(oOwner as OBJECT, symClassType AS SYMBOL) 
> > AS ARRAY PASCAL
> > LOCAL aControls     AS ARRAY
> > LOCAL oC            AS VObject
> > LOCAL hWnd          AS PTR
> > 
> > hWnd        := GetWindow( oOwner :oSurface:Handle(), GW_CHILD )
> > aControls   := {}
> > 
> > WHILE hWnd != NULL_PTR
> >       oC      := GetObjectByHandle( hWnd )
> >       IF IsInstanceOfUsual( oC, symClassType )
> >             AAdd( aControls, oC )
> >        ENDIF
> > 
> >        hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
> > 
> > ENDDO
> > 
> > RETURN aControls
> > 
> > Then it call as:
> > 
> > aButtons := GetDataWindowControls(SELF, #BUTTON)
> > aSingleLineEdits :=  GetDataWindowControls(SELF, #SINGLELINEEDIT)
> > 
> > FUNCTION HideControls(oOwner as OBJECT, aControls AS OBJECT, lHide as 
> > LOGIC) AS VOID PASCAL
> > LOCAL dwLength := ALen(aControls) as DWORD
> > LOCAL j as DWORD
> > 
> > FOR j = 1 upto dwLength
> >         if lHide
> >             oOwner:aControls[j].Hide()
> >          else
> >             oOwner:aControls[j].Show()
> >         endif
> > NEXT
> > 
> > RETURN
> > 
> > Samples:
> > 
> > HideControls(self, aButtons, true)
> > 
> > HideControls(SELF, GetDataWindowControls(SELF, #BUTTON), TRUE)         
> > // one call
> > 
> > etc
> > 
> > Jamal
> > 
> > 
> > "Franz Rachbauer"  wrote in message
> > 
> > Hi Gregory,
> > I use the following to get the controls I need:
> > 
> > METHOD GetControls() CLASS RedimDataWindow
> > LOCAL aControls     AS ARRAY
> > LOCAL oC            AS VObject
> > LOCAL hWnd          AS PTR
> > 
> > hWnd        := GetWindow( SELF:oSurface:Handle(), GW_CHILD )
> > aControls   := {}
> > WHILE hWnd != NULL_PTR
> > oC      := GetObjectByHandle( hWnd )
> > IF IsInstanceOfUsual( oC, #BUTTON )
> > AAdd( aControls, oC )
> > ENDIF
> > hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
> > ENDDO
> > RETURN aControls
> > 
> > Then I have an array of Buttons which I can hide/disable like
> > aControls[nVal]:Hide()
> > 
> > Regards, Franz
> > 
> > Am 06.12.2017 um 09:41 schrieb Grzegorz R.:
> >> Hello Friends
> >>
> >> I need to enable/disable and/or make readonly true/false some controls 
> >> on my window but there is a lot of them and listing explicitly 
> >> requires a lot of writing/coding.
> >>
> >> I can easily change state of SINGLELINEEDITs with:
> >>
> >> CLASS MyEdit INHERIT SINGLELINEEDIT
> >> ...
> >> METHOD ChgState(lFlag) CLASS MyEdit
> >> SELF:ReadOnly:=lFlag
> >> RETURN NIL
> >> ...
> >> // TestWin has SINGLEEDITLINES that inherit from MyEdit
> >>
> >> METHOD SetState(lFlag) CLASS TestWin
> >> LOCAL I AS DWORD
> >> FOR I:=1 UPTO ALen(SELF:aControls)
> >> IF IsMethod(SELF:aControls[I],#CHGSTATE)
> >> SELF:aControls[I]:ChgState(lControlsState)
> >> ENDIF
> >> NEXT RETURN NIL
> >>
> >> However aControls does not include pushbuttons (and maybe other 
> >> controls).
> >>
> >> How can I do the same ie. get list of existing pushbuttons (and other 
> >> controls not included in aControls) in window and process them in loop?
> >> Or maybe another way exist to change state (enable/disable) a bunch of 
> >> different types of controls?
> >>
> >> Best regards
> >> Gregory
> >>
> >>

So guys...
news are two - one bad and one good:

Jamal idea of 

  GetWindow(oOwner:oSurface:Handle(), GW_CHILD )

gives error "No exported variable oSurface" when used in FUNCTION(WinObject,SymControl).

Exacly the same set of commands used in METHOD(SymControl) with

  GetWindow( SELF:oSurface:Handle(), GW_CHILD )

works ok.

So I stick with Method - it works as I wanted and the only thing I have to do is to inherit each window that should use this mechanism from base class that has GetWindowControls method.

Anyway - many many thanks :)

Best regards
Gregory

[toc] | [prev] | [next] | [standalone]


#11224

FromFranz Rachbauer <office@rachbauer.org>
Date2017-12-07 09:34 +0100
Message-ID<p0aue8$h14$1@gioia.aioe.org>
In reply to#11223
Hi Gregory,
I think the problem is
FUNCTION GetDataWindowControls(oOwner as OBJECT, ...), because oSurface 
only is a protected of DataWindow not of Object so
FUNCTION GetDataWindowControls(oOwner as DataWindow, ...) should work.

Another way should be that GetWindow(self:oSurface:Handle(), GW_CHILD) 
is directly passed as parameter to GetDataWindowControls instead of self.

Regards, Franz

Am 06.12.2017 um 21:29 schrieb Grzegorz R.:
> W dniu środa, 6 grudnia 2017 17:47:28 UTC+1 użytkownik Franz Rachbauer napisał:
>> Hi Jamal,
>> this is a variable way to show/hide controls on any window. I think
>> Gregory will be delighted. My method only was a cut excerpt of an
>> extensive base class I often use.
>>
>> Thanks, Franz
>>
>> Am 06.12.2017 um 16:13 schrieb Jamal:
>>> Hi Franz,
>>>
>>> Instead of hard coding the type of controls. I think your method (for
>>> fun; not tested) can be changed to a function like:
>>>
>>>
>>> FUNCTION GetDataWindowControls(oOwner as OBJECT, symClassType AS SYMBOL)
>>> AS ARRAY PASCAL
>>> LOCAL aControls     AS ARRAY
>>> LOCAL oC            AS VObject
>>> LOCAL hWnd          AS PTR
>>>
>>> hWnd        := GetWindow( oOwner :oSurface:Handle(), GW_CHILD )
>>> aControls   := {}
>>>
>>> WHILE hWnd != NULL_PTR
>>>        oC      := GetObjectByHandle( hWnd )
>>>        IF IsInstanceOfUsual( oC, symClassType )
>>>              AAdd( aControls, oC )
>>>         ENDIF
>>>
>>>         hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
>>>
>>> ENDDO
>>>
>>> RETURN aControls
>>>
>>> Then it call as:
>>>
>>> aButtons := GetDataWindowControls(SELF, #BUTTON)
>>> aSingleLineEdits :=  GetDataWindowControls(SELF, #SINGLELINEEDIT)
>>>
>>> FUNCTION HideControls(oOwner as OBJECT, aControls AS OBJECT, lHide as
>>> LOGIC) AS VOID PASCAL
>>> LOCAL dwLength := ALen(aControls) as DWORD
>>> LOCAL j as DWORD
>>>
>>> FOR j = 1 upto dwLength
>>>          if lHide
>>>              oOwner:aControls[j].Hide()
>>>           else
>>>              oOwner:aControls[j].Show()
>>>          endif
>>> NEXT
>>>
>>> RETURN
>>>
>>> Samples:
>>>
>>> HideControls(self, aButtons, true)
>>>
>>> HideControls(SELF, GetDataWindowControls(SELF, #BUTTON), TRUE)
>>> // one call
>>>
>>> etc
>>>
>>> Jamal
>>>
>>>
>>> "Franz Rachbauer"  wrote in message
>>>
>>> Hi Gregory,
>>> I use the following to get the controls I need:
>>>
>>> METHOD GetControls() CLASS RedimDataWindow
>>> LOCAL aControls     AS ARRAY
>>> LOCAL oC            AS VObject
>>> LOCAL hWnd          AS PTR
>>>
>>> hWnd        := GetWindow( SELF:oSurface:Handle(), GW_CHILD )
>>> aControls   := {}
>>> WHILE hWnd != NULL_PTR
>>> oC      := GetObjectByHandle( hWnd )
>>> IF IsInstanceOfUsual( oC, #BUTTON )
>>> AAdd( aControls, oC )
>>> ENDIF
>>> hWnd    := GetWindow( hWnd, GW_HWNDNEXT )
>>> ENDDO
>>> RETURN aControls
>>>
>>> Then I have an array of Buttons which I can hide/disable like
>>> aControls[nVal]:Hide()
>>>
>>> Regards, Franz
>>>
>>> Am 06.12.2017 um 09:41 schrieb Grzegorz R.:
>>>> Hello Friends
>>>>
>>>> I need to enable/disable and/or make readonly true/false some controls
>>>> on my window but there is a lot of them and listing explicitly
>>>> requires a lot of writing/coding.
>>>>
>>>> I can easily change state of SINGLELINEEDITs with:
>>>>
>>>> CLASS MyEdit INHERIT SINGLELINEEDIT
>>>> ...
>>>> METHOD ChgState(lFlag) CLASS MyEdit
>>>> SELF:ReadOnly:=lFlag
>>>> RETURN NIL
>>>> ...
>>>> // TestWin has SINGLEEDITLINES that inherit from MyEdit
>>>>
>>>> METHOD SetState(lFlag) CLASS TestWin
>>>> LOCAL I AS DWORD
>>>> FOR I:=1 UPTO ALen(SELF:aControls)
>>>> IF IsMethod(SELF:aControls[I],#CHGSTATE)
>>>> SELF:aControls[I]:ChgState(lControlsState)
>>>> ENDIF
>>>> NEXT RETURN NIL
>>>>
>>>> However aControls does not include pushbuttons (and maybe other
>>>> controls).
>>>>
>>>> How can I do the same ie. get list of existing pushbuttons (and other
>>>> controls not included in aControls) in window and process them in loop?
>>>> Or maybe another way exist to change state (enable/disable) a bunch of
>>>> different types of controls?
>>>>
>>>> Best regards
>>>> Gregory
>>>>
>>>>
> 
> So guys...
> news are two - one bad and one good:
> 
> Jamal idea of
> 
>    GetWindow(oOwner:oSurface:Handle(), GW_CHILD )
> 
> gives error "No exported variable oSurface" when used in FUNCTION(WinObject,SymControl).
> 
> Exacly the same set of commands used in METHOD(SymControl) with
> 
>    GetWindow( SELF:oSurface:Handle(), GW_CHILD )
> 
> works ok.
> 
> So I stick with Method - it works as I wanted and the only thing I have to do is to inherit each window that should use this mechanism from base class that has GetWindowControls method.
> 
> Anyway - many many thanks :)
> 
> Best regards
> Gregory
> 

[toc] | [prev] | [next] | [standalone]


#11229

From"Karl-Heinz" <invalid@invalid.invalid>
Date2017-12-10 11:32 +0100
Message-ID<f94gr3F88a4U1@mid.individual.net>
In reply to#11223
Hi Grzegorz,

> So guys...
> news are two - one bad and one good:
>
> Jamal idea of
>
>  GetWindow(oOwner:oSurface:Handle(), GW_CHILD )
>
>gives error "No exported variable oSurface" when used in
>FUNCTION(WinObject,SymControl).
>

1. The buildin Datawindow Method :__GetFormSurface() gives you access to the
protect var oSurface.

2. There´s also a Method named :GetAllChildren(), which is part of the
Window class. The method returns an array that contains *all* controls that
are placed on a Window.

regards
Karl-Heinz 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web