Data back from a TDialog to TMainWindow

Hello all...any ideas about this?

What I'm trying to accomplish is the following:

Quote
>From my Main window (A TDlgWindow) I show another dialog (TDialog) in
>which the user can swith between a preset Low and High value. These
>values correspond to two Auto TRadioButtons. With either of these
>buttons selected the appropriate scrollbars are "initialized" and the
>user can thus modify the values by scrolling the Scrollbars (obviously).

>The values of the scrollbars (of type TRatesArray) are past to the
>TRates dialog by means of  a Transfer Record.

>However I don't seem to be able to transfer the (changed) data back from
>my TRates Dialog to my TMainWindow. Is this at all possible by means of
>a transfer buffer?

>I've included some code snippets from my applications which will
>hopefully give a clue of what I'm trying to accomplish.

>Type
>  TCurrency = Array[0..5] of Char;

>  (* RateRecord contains Rate data *)
>  TRateRecord = Record
>    Currency, UnitCurrency: TCurrency;
>    Cents,Seconds,AlarmSeconds,AlarmSecondsMax: Word;
>  end;

>  (* RateArray is used for storing RateHi & RateLo *)
>  PRateArray = TRateArray;
>  TRateArray = Array[1..2] of TRateRecord;

>Type
>  (* TRatesDlg is the Rates dialog of the application. *)
>  PRatesDlg = ^TRatesDlg;
>  TRatesDlg = Object(TDialog)
>    CurrencyE,UnitCurrencyE: PEdit;
>    RateCostSB,RateSecondsSB,AlarmSecondsSB: PScrollBar;
>    RateArray: TRateArray;  
>    RunningYN: Boolean;
>    RateActive: Word;

>    Constructor Init(AParent: PWindowsObject; AName: PChar; Var XferBuf:
>    TRatesXRec);
>     Procedure SetupWindow;
>      Virtual;

>    Procedure SetRate;
>    Procedure CurrencyEMsg(Var Msg: TMessage);
>      Virtual id_First + id_CurrencyE;
>    Procedure UnitCurrencyEMsg(Var Msg: TMessage);
>      Virtual id_First + id_UnitCurrencyE;
>    Procedure RateCostHScroll(Var Msg: TMessage; Var XferBuf:  
>    TRatesXRec);
>      Virtual id_First + id_RateCostSB;
>    Procedure RateSecondsHScroll(Var Msg: TMessage; Var XferBuf:
>    TRatesXRec);
>      Virtual id_First + id_RateSecondsSB;
>    Procedure AlarmSecondsHScroll(Var Msg: TMessage; Var XferBuf:
>    TRatesXRec);
>      Virtual id_First + id_AlarmSecondsSB;
>    Procedure RateHi(Var Msg: TMessage);
>      Virtual id_First + id_RateHi;
>    Procedure RateLo(Var Msg: TMessage);
>      Virtual id_First + id_RateLo;
>  end;

>In one of my BPW 7 books I read that TransferBuffer items can be links
>to TWindowsObjects by means of an InitResouce and thus the data
>concerning the controls is passed back and forth automatically. But
>unfortunately my TRateArray isn't a windows Control so the data transfer
>will never work autmatically... <Grin>

>Constructor TRatesDlg.Init(AParent: PWindowsObject; AName: PChar;
>                           Var XferBuf: TRatesXRec);
>Var
> P: PWindowsObject;
>Begin
> TDialog.Init(AParent, AName);

> (* Accept input parameters *)
> RunningYN := XferBuf.RunningYN;
> RateActive:= XferBuf.RateActive;
> RateArray:= XferBuf.RateArray;

> with RateArray[RateActive] do begin
>   CurrencyE     :=
>   New(PEdit,InitResource(@Self,id_CurrencyE,SizeOf(Currency)));
>   UnitCurrencyE :=
>   New(PEdit,InitResource(@Self,id_UnitCurrencyE,SizeOf(UnitCurrency)));
>   P  
>               := New(PRadioButton, InitResource(@Self, id_RateLo)); P  
>                           :=
>   New(PRadioButton, InitResource(@Self, id_RateHi));
> end;
> RateCostSB    := New(PScrollBar,InitResource(@Self,id_RateCostSB));
> RateSecondsSB := New(PScrollBar,InitResource(@Self,id_RateSecondsSB));
> AlarmSecondsSB:= New(PScrollBar,InitResource(@Self,id_AlarmSecondsSB));

> EnableTransfer;
> TransferBuffer:= @XferBuf;

> (* Initialize the RateCost Scrollbar *)
> RateCostSB^.SetRange(1,250);
> RateCostSB^.SetPosition(RateArray[RateActive].Cents);

> (* Initialize the RateSeconds Scrollbar *)
> RateSecondsSB^.SetRange(1,600);
> RateCostSB^.SetPosition(RateArray^[RateActive].Seconds);

> (* Initialize the AlarmSeconds Scrollbar *)
> RateSecondsSB^.SetRange(0,RateArray^[RateActive].Seconds);

> RateCostSB^.SetPosition(RateArray[RateActive].Seconds);
> if RateArray[RateActive].AlarmSeconds < RateArray[RateActive].Seconds
>     then RateCostSB^.SetPosition(RateArray[RateActive].AlarmSeconds)
>     else RateCostSB^.SetPosition(0);
>End;

>{-----------------------------------------------------------------------
>--------------
> TMainDlg: DoRates: Runs the Rates Dailog.
> -----------------------------------------------------------------------
> --------------}
>Procedure TMainDlg.DoRates;
>Var
> MyRatesDlg: PRatesDlg;
>Begin
> (* Initialize the Dialog *)
> FillChar(RatesXRec,SizeOf(RatesXRec),Chr(0));
> if RateActive = 1
>    then RatesXRec.RateLo:= 1
>    else RatesXRec.RateHi:= 1;
> RatesXRec.RateActive:= RateActive;
> RatesXRec.RateArray := RateArray;
> if IsWindowEnabled(GetDlgItem(hWindow,id_Stop))
>   then RatesXRec.RunningYN:= True
>   else RatesXRec.RunningYN:= False;

>(* Execute the dialog *)
> MyRatesDlg:= New(PRatesDlg, Init(@Self, 'Rates2',RatesXRec));
> if Application^.ExecDialog(MyRatesDlg) = id_OK then begin
>   (* Accept RateActive: THIS WORKS *)
>   if RatesXRec.RateLo = 0
>      then RateActive:= 2
>      else RateActive:= 1;

> SetDlgItemInt(hWindow,id_Test01,RateActive,True);

>   RateArray := RatesXRec.RateArray;
>{THIS DOESN'T RETURN THE CORRECT DATA FROM THE DIALOG TO THE MAIN
>WINDOW}

>   (* Fill entry: Currency descriptions*)
>   StrCopy(Currency,RateArray[RateActive].Currency);
>   SetDlgItemText(hWindow,id_Currency1,Currency);
>   SetDlgItemText(hWindow,id_Currency2,Currency);

>   (* Fill entry: Unit of Currency descriptions*)
>   StrCopy(UnitCurrency,RateArray[RateActive].UnitCurrency);
>   SetDlgItemText(hWindow,id_CentsDesc,UnitCurrency);

>   (* Fill entry: Cents *)
>   Cents:= RateArray[RateActive].Cents;
>   SetDlgItemInt(hWindow,id_Cents,Cents,False);

>   (* Fill entry: Seconds & Seconds Left*)
>   Seconds:= RateArray[RateActive].Seconds;
>   SetDlgItemInt(hWindow,id_Seconds,Seconds,False);
>   SetDlgItemInt(hWindow,id_SecondsLeft,Seconds,False);

>   (* Fill entry: Alarm Seconds *)
>   SecondsAlarm:= RateArray[RateActive].AlarmSeconds;
>   UpdateWindow(hWindow);
> end;
>End;

>PLEASE, PLEASE Reply to me privately (LPosth...@pobox.qstone.nl) as
>I'm not in the position to check the UseNet archives regularly.

>Have a nice day! And I truely hope that someone will be able to point
>me in the right selection. I want to make these changes to this BPW7
>program asap so I can get back to my other projects I'm working.

>[*** End of Message ***]