Page 1 of 1

Possible, to send a value from mdi-child to main-window ?

Posted: Sat Apr 26, 2008 11:31 am
by ukoenig
Hello,

I have a little problem :

Image

With one Button in the office-bar (Main-window), i want to know the position inside a folder of a child.
To define a PUBLIC-var at start, doesn't help

Is it possible to use just 1 Button to start a action in relation
of the folder-position ?

Regards

Uwe :lol:

Posted: Sat Apr 26, 2008 3:51 pm
by James Bott
Have you tried oFolder:nOption?

James

Message from Child to Main-Window

Posted: Sat Apr 26, 2008 4:58 pm
by ukoenig
Hello James,

The problem is, i want to start a action in the main-window.
In the main window, i define a var < nPROGPOS = 1 >.
In the Child, the var gets the value from the folder :

ON CHANGE Optionget( nOption, nOldoption)
nPROGPOS := nOption

A Test in the Child => nPROGPOS has the value from the folder-pos.
Inside the child, everything is ok.

But when i press the button in the Main-Window
nPROGPOS is allways 1.

I need the nOption-value in the office-bar.
When it is impossible to do it this way, i have to create a button
in each folder for the needed action.

It seems, nPROGPOS in the Main-window is different to the one
in the Child.
I checked : Public, static, private, by reference
No chance at all.

Regards

Uwe :lol:

Posted: Sat Apr 26, 2008 9:35 pm
by James Bott
Uwe,

Use a static inside a function. You can set it in the child window and retreive it from anywhere.

James

Code: Select all

function setOption(nNewOption)
   local nReply
   static nOldOption:=1
   nReply:= nOldOption
   if nNewOption != nil
      nOldOption:= nNewOption
   endif
return nReply

Message from MDI-Folder to Main-Window

Posted: Sun Apr 27, 2008 9:33 am
by ukoenig
Hello James,

I added the Function to the program and it works fine now.
Thank you very much.

Code: Select all


STATIC nOption

FUNCTION MAIN() 
LOCAL  oWnd, oBar, oBtn1, oBtn2

DEFINE WINDOW oWnd TITLE "Test"  MDI MENU TMenu():New() 

DEFINE BUTTONBAR oBar 3DLOOK OF oWnd BUTTONSIZE 70,80 2007 RIGHT

// Folder
DEFINE BUTTON oBtn1 OF oBar ;
ACTION ( BRW_DESIGN(oWnd) ) ;
              RESOURCE "notes_5" PROMPT "Visual" + CRLF + "Tools"

// Action-Button for Folder-Tabs
// ---------------------------------------
DEFINE BUTTON oBtn2 OF oBar ;
ACTION ( SHOW_POS( setOption(nOption) ) ;   //  Get the Folder-Tab-Position
RESOURCE "magic_5" PROMPT "Show " + CRLF + "Design"

ACTIVATE WINDOW oWnd MAXIMIZED

// --------------------------------

FUNCTION BRW_DESIGN(oWnd)
LOCAL oDlg1, oFld, oProg

DEFINE DIALOG oDlg1  RESOURCE "BRWDESIGN"  OF oWnd

REDEFINE FOLDER oFld ID 300 OF oDlg1 FONT oProgFont  ;
PROMPTS "  &Colors  ", "  &Lines & Grids  ", "  &Fonts & Bitmaps  ", "  &Dialog-Titles  ", ;
                   "  &Windows & Dialog  "," &Gif-Test"  ;
DIALOGS "Browse1", "Browse2", "Browse3", "Browse4", "Browse5", "Browse6"  ;
ON CHANGE( MsgAlert( oFld:nOption ) ) // activ Option

ACTIVATE DIALOG oDlg1 CENTERED NOWAIT

RETURN( NIL )

// ------------------------------

FUNCTION SetOption(nNewOption) 
local nReply 
static nOldOption:=1 
nReply:= nOldOption 
IF nNewOption != nil 
         nOldOption:= nNewOption 
ENDIF 
RETURN nReply

// -------------------------------

FUNCTION SHOW_POS(nPosition)

// Options in Relation to Folder-Tabs
// ---------------------------------------------
MsgAlert( "Folder-Pos : " + str(nPosition), "Position" )

RETURN( NIL )

Uwe :lol: [/code]

Posted: Sun Apr 27, 2008 4:44 pm
by James Bott
Uwe,

>I added the Function to the program and it works fine now.

Glad to hear it. You may want to make the function a static function so it can't be seen elsewhere in your program.

James