Frame Parent Child Attributes

critchsj

New Member
Hi I have a window with two frames the first frame Is default frame and first child of the window the second frame does not appear to be a sibling or a child of the first frame although it is located within the frame, I cant seem to get the handle of this frame dynamically i.e. first-child or next sibling, hardcoding the cframename:handle is also kicking up a message of unknown variable, anyone who may of experienced something like this before let me know.
Thanks
Simon
GUI 9.1d
 
Just check the names/types/handles of the parents. That way, you can see if they both belong to the same widget or if they belong to something else.

If you don't view the frames first, they don't have parents. Try the following code, then comment out the view frame statements and watch it error as the parent does not exist.

Are you trying to get the parent without first viewing the frames?

def var h_f1p as widget-handle.
def var h_f2p as widget-handle.
def var window1 as widget-handle no-undo.
def frame f1 with side-labels 1 down three-d.
def frame f2 with side-labels 1 down three-d.
create window window1.
window1:name = "window1".
current-window = window1.
view window1.
view frame f1 in window window1.
view frame f2 in window window1.

h_f1p = frame f1:parent.
h_f2p = frame f2:parent.
message string(h_f1p) h_f1p:name h_f1p:type skip
string(h_f2p) h_f2p:name h_f2p:type
view-as alert-box.

 
The following code is my problem i get the first-child of the main window which is default frame. It then gets the children of that frame and steps through using next sibling, i grab the next frame which i assume is a child of the window and therefore a sibling of default frame but no, i get a question mark when messaging handle. How can I identify the relationship of the second frame to the first frame which is firt-child of the main window, hope i am making some sense here

see code

DEFINE INPUT PARAMETER widthMultiplier AS DECIMAL NO-UNDO.
DEFINE INPUT PARAMETER heightMultiplier AS DECIMAL NO-UNDO.
DEFINE VARIABLE h AS HANDLE NO-UNDO.
DEFINE VARIABLE h2 AS HANDLE NO-UNDO.
DEFINE VARIABLE f AS HANDLE NO-UNDO.

h = {&WINDOW-NAME}:HANDLE.

f = {&WINDOW-NAME}:HANDLE.
MESSAGE f VIEW-AS ALERT-BOX.
h = h:FIRST-CHILD.
main:
DO WHILE VALID-HANDLE (h):
MESSAGE h:TYPE VIEW-AS ALERT-BOX.
IF h:TYPE = "FRAME" THEN
DO:
h:SCROLLABLE = TRUE.
IF h:WIDTH-PIXELS * widthMultiplier <= 200 OR h:HEIGHT-PIXELS * heightMultiplier <= 200 THEN
DO:
ASSIGN ckeepframeSize = "YES" .
LEAVE main.
END.
ASSIGN cKeepFrameSize = "NO".

h:X = h:X * widthMultiplier NO-ERROR.
h:Y = h:Y * heightMultiplier NO-ERROR.
h:WIDTH-PIXELS = h:WIDTH-PIXELS * widthMultiplier NO-ERROR.
h:HEIGHT-PIXELS = h:HEIGHT-PIXELS * heightMultiplier NO-ERROR.
h:VIRTUAL-WIDTH-PIXELS = h:WIDTH-PIXELS.
h:VIRTUAL-HEIGHT-PIXELS = h:HEIGHT-PIXELS.
h:SCROLLABLE = FALSE.
h2 = h:FIRST-CHILD.
h2 = h2:FIRST-CHILD.
INNER_blk:
DO WHILE VALID-HANDLE (h2):
IF CAN-QUERY (h2, "PRIVATE-DATA") THEN DO:
IF h2:PRIVATE-DATA = "frame" THEN
MESSAGE h2:PRIVATE-DATA VIEW-AS ALERT-BOX.
h2:WIDTH-PIXELS = h2:WIDTH-PIXELS * widthMultiplier NO-ERROR.
h2:HEIGHT-PIXELS = h2:HEIGHT-PIXELS * heightMultiplier NO-ERROR.
h2:X = h2:X * widthMultiplier NO-ERROR.
h2:Y = h2:Y * heightMultiplier NO-ERROR.
END.
h2 = h2:NEXT-SIBLING.
END.
h = h:NEXT-SIBLING.
MESSAGE "type 2 " h:TYPE VIEW-AS ALERT-BOX.
END.
END.

also the widget pool lists default frame as first child i.e
/* Name of first Frame and/or Browse and/or first Query */
&Scoped-define FRAME-NAME DEFAULT-FRAME

but the second frame is simply defined , i could really do with finding its relationship to window or default-frame so i can re-size these frames dynamically , have a number of forms to do. OR possibly how to set the second frame as sibling to default frame.

thanks for response anyway feedback is welcome

Simon
 
That seems to work, I've got two frames defined f1 and f2, I put your code into a procedure and ran it. It gave me both frames.

You might be hitting the leave main command and leaving early.

To check on frames, try this before main:

DO WHILE VALID-HANDLE (h):
MESSAGE "h" h h:name h:TYPE h:next-sibling VIEW-AS ALERT-BOX.
h = h:NEXT-SIBLING.
end.

This shows that there is a next-sibling and should show all of the frames.

But, you have to view the frames to make them children of the current-window, or view in window ... to make them children of another window.

 
Back
Top