Counting no of widgets on screen

You can do a widget walk like this to access the individual widgets:

DEFINE VARIABLE hObject AS HANDLE NO-UNDO.

ASSIGN hObject = SESSION:FIRST-CHILD.

DO WHILE VALID-HANDLE ( hObject ):

MESSAGE 'Type: ' hObject:TYPE SKIP 'Name: ' hObject:NAME VIEW-AS ALERT-BOX INFO.
ASSIGN hObject = hObject:NEXT-SIBLING.

END.
Heavy Regards, RealHeavyDude.
 
Yes you can! The code I provided was just a sample on how you can do a widget walk.

You did try it, did you?

Heavy Regards, RealHeavyDude.
 
i tried the same but it is giving only me window and procedure name , nut button and text fields name. can u modify this code with current window name as i have to apply this logic on many windows.
 
Code:
/*******************************************************************/
PROCEDURE scanWidgets :
DEFINE INPUT PARAMETER hw AS HANDLE NO-UNDO.
DEFINE VARIABLE hwidget AS HANDLE NO-UNDO.

ASSIGN hw = hw:FIRST-CHILD NO-ERROR.
IF ERROR-STATUS:ERROR THEN RETURN.

DO WHILE TRUE:
 IF VALID-HANDLE(hw) THEN DO:
    MESSAGE hw:NAME VIEW-AS ALERT-BOX.
    RUN scanWidgets (hw).
    hw = hw:NEXT-SIBLING.
 END.
 ELSE LEAVE.
END.
END PROCEDURE.
/*******************************************************************/
RUN scanWidgets (SESSION:HANDLE).
 
i have created one common procedure as below

getsessionwidget.p

PROCEDURE scanWidgets :
DEFINE INPUT PARAMETER hw AS HANDLE NO-UNDO.
DEFINE VARIABLE hwidget AS HANDLE NO-UNDO.

ASSIGN hw = hw:FIRST-CHILD NO-ERROR.
IF ERROR-STATUS:ERROR THEN RETURN.

DO WHILE TRUE:
IF VALID-HANDLE(hw) THEN DO:
RUN scanWidgets (hw).
hw = hw:NEXT-SIBLING.
END.
ELSE LEAVE.
END.
END PROCEDURE.
/*******************************************************************/
RUN scanWidgets (SESSION:HANDLE).


and calling this procedure from another screen but i am not getting any valid handle
 
Well the first thing to point out is that you're not doing anything with the widgets anyway. It'll just trawl through all the widgets until there are none left.
 
I've just tested the code posted by rstanciu and it returns valid handles and messages which suggests there's something you're not telling us.
 
actually what i am trying do do here is that when any application screen opens from menu bar, first it will check for the conditions and based on the conditions it will enable and disable all the screen widgets. So for that i want one unique program or procedure which i can used in all screen it will satisfy my requirement. The approch that u guys suggested i.e.

hw:FIRST-CHILD NO-ERROR. is not returning any valid handle for sub screens. It is returning valid handle only for main screen. But i want the same to be run for sub screens. So that by using handle programming i can disable or enable screen widgets.

Hope u guys understand my problem.

Please suggest.
 
Back
Top