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

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

Postby ukoenig » Sat Apr 26, 2008 11:31 am

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:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby James Bott » Sat Apr 26, 2008 3:51 pm

Have you tried oFolder:nOption?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Message from Child to Main-Window

Postby ukoenig » Sat Apr 26, 2008 4:58 pm

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:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby James Bott » Sat Apr 26, 2008 9:35 pm

Uwe,

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

James

Code: Select all  Expand view  RUN
function setOption(nNewOption)
   local nReply
   static nOldOption:=1
   nReply:= nOldOption
   if nNewOption != nil
      nOldOption:= nNewOption
   endif
return nReply
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Message from MDI-Folder to Main-Window

Postby ukoenig » Sun Apr 27, 2008 9:33 am

Hello James,

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

Code: Select all  Expand view  RUN

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]
Last edited by ukoenig on Mon Apr 28, 2008 8:24 am, edited 3 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby James Bott » Sun Apr 27, 2008 4:44 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests

cron