Obtaining the file name of a widget

tracy huffam

New Member
Hi All

I have a program configured as follows.


- Container window with a smart folder - with 5 pages (eg. "wMain.w")
- each page containing a smart frame (eg. fTab1.w,fTab2.w etc...)
- each smart frame containing one or more widgets.


The Scenario:


The menu object calls wmain.w.

I have a system wide trigger fired by a hot key eg "F12" . This trigger is coded into the menu object.

When "F12" is pressed while the user is working within wMain.w the trigger is fired.
eg.
on "F12" anywhere do:

/* at this point i need to capture 3 things:
1. The program name(wMain.w) - done using "Program-name()" function.
2. The name of the smart object containing the currently selected widget e.g "wTab1.w". (i dont know how to do this)
3. The selected widget name (done by accesing the "self" handle)
*/

end.


The question is:

Is there a simple way to establish the program name (eg wTab1.w) that contains the currently selected widget. (Specifically when this widget is on a smart object which is placed onto a container.) Preferably this can be done simply in my trigger code (within the menu object) without any further programming effort in any other programs. (Great if there was a "widget:file-name" type attribute!!)

Thanks in advance for any help.

Regards
Tracy Huffam
 
Not simple, not tested and I'm speculating a bit here, but...

1. edit windowmn.i to define and set a variable for PROGRAM-NAME (cProgram-Name)
2. also in windowmn.i, code a procedure that returns that variable.
Code:
PROCEDURE p-get-program-name:
  def output param op-Program-Name no-undo.
  assign op-Program-Name = cProgram-Name.
END PROCEDURE.
3. On f12
Code:
assign hContainer = this-procedure.
do while cProgram eq ""
and valid-handle(hContainer):
  run p-get-program-name in hContainer (output cProgram) no-error.
  {get containerSource hContainer hContainer}.
end.
message cProgram.
 
This should work (assuming you dont use frame private data for anything else):

in main-block of smart.i:
<pre>
FRAME {&FRAME-NAME}:PRIVATE-DATA = THIS-PROCEDURE:FILE-NAME.
</pre>
in main-block of window (wMain.w):
<pre>
ON "F12" ANYWHERE
DO:
DEFINE VARIABLE h$parent AS WIDGET-HANDLE NO-UNDO.

ASSIGN h$parent = SELF:PARENT.

FIND-PARENT:
DO WHILE VALID-HANDLE(h$parent):
IF CAN-QUERY(h$parent,"TYPE") = YES THEN
DO:
IF h$parent:TYPE <> "FRAME" THEN
ASSIGN h$parent = h$parent:PARENT.
ELSE
LEAVE FIND-PARENT.
END.
ELSE
ASSIGN h$parent = h$parent:PARENT.
END.
IF VALID-HANDLE(h$parent) THEN
MESSAGE h$parent:PRIVATE-DATA
VIEW-AS ALERT-BOX.
END.
</pre>
Hope it helps :-)
 
Back
Top