Page 1 of 2

Need Autorestore Window in @ .. DCDIALOG

Posted: Thu Jan 28, 2010 9:41 am
by rdonnay
Could you pls also integrate the Autorestore feature in Dialogs created with @ 1,1, DCDIALOG oWinDlg DrawingArea oDlg

still does not work :-(

This was sent as an email to me by Michael Rudrich.
I am posting it here so it is not forgotten.

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Fri Jan 29, 2010 6:09 pm
by rdonnay
Michael -

This works for me:

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], oDlg

DC_AutoRestoreWindow( { HKEY_CURRENT_USER, 'Software\Donnay Software\eXpress++\Windows' } )

@ 0,0 DCDIALOG oDlg SIZE 300,300 PIXEL CAPTION 'My test dialog'

DCREAD GUI FIT ADDBUTTONS TITLE 'Some title'

RETURN nil

* ------------

PROC appsys ; return

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Sat Jan 30, 2010 10:18 pm
by edv-rudrich
Hi..

so what is wrong with this construct??

#include "dcdialog.ch"

STATIC oDialog

Procedure APPSYS()
RETURN

Function Main()
Local oHaupt, oSub, GetOptions, ;
GetList := {}, nEvent, mp1, mp2, oXbp, oAppWindow

Public nDialogNummer := 0
GUI ON

DC_AutoRestoreWindow ({HKEY_CURRENT_USER, '\SOFTWARE\Michael\Demo\Fenster'})

// Menu
DCMenuBar oHaupt
DCSubMenu oSub PROMPT "&Action" PARENT oHaupt

DCMenuItem "&Dialog" PARENT oSub;
ACTION {|| o:=Thread():new(),o:Start("Test1",oDialog) }

DCMenuItem "&End" PARENT oSub ;
ACTION {|| PostAppEvent(xbeP_Close) }


DCGETOPTIONS WINDOWHEIGHT 480 ;
WINDOWWIDTH 640 ;
TABSTOP

DCREAD GUI TITLE 'Test++' ;
OPTIONS GetOptions ;
EVAL {|o|SetAppWindow(o),SetAppFocus(o)};
PARENT @oDialog

DC_GetDestroy(Getlist)
RETURN nil

Function Test1(oDialog)
Local oDlg, oDlgWindow, Getlist := {}, lOK := .F.
Local GetOptions, oSession
Local oTabPage1,oTabPage2, oTabPage3
Local cVar1 := space(10)
Local cVar2 := space(10)
Local cVar3 := space(10)

nDialogNummer++

@ 1,1 DCDIALOG oDlgWindow DRAWINGAREA oDlg SIZE 50,17 ;
CAPTION 'Dialog ' + strzero(ThreadId(),2) NOMINBUTTON NORESIZE

@ 1,1 DCTABPAGE oTabPage1 CAPTION 'Tab 1';
SIZE 76,17 PREOFFSET 0 POSTOFFSET 86 PARENT oDlg

@ 0,0 DCTABPAGE oTabPage2 CAPTION 'Tab 2' ;
RELATIVE oTabPage1 PARENT oDlg

@ 0,0 DCTABPAGE oTabPage3 CAPTION 'Tab 3' ;
RELATIVE oTabPage2 PARENT oDlg

@ 2,2 DCSAY "Hello 1" GET cVar1 PARENT oTabPage1
@ 4,2 DCSAY "Hello 2" GET cVar2 PARENT oTabPage1

@ 2,2 DCSAY "Hello 2" GET cVar2 PARENT oTabPage2

@ 2,2 DCSAY "Hello 3" GET cVar3 PARENT oTabPage3

DCGETOPTIONS ;
CHECKGET;
TABSTOP;
CASCADE;
HILITEGETS GRA_CLR_RED NOMINBUTTON NOMAXBUTTON NORESIZE
//AUTORESIZE

DCREAD GUI ;
parent oDialog;
OPTIONS GetOptions;
HANDLER _DlgHandler;
TO lOK

DC_GetDestroy(Getlist)

nDialogNummer--

DbCLoseAll()
DbCommitAll()

RETURN (NIL)

STATIC FUNCTION _DlgHandler ( nEvent, mp1, mp2, oXbp, oDialog, GetList )
IF nEvent = xbeP_Close
RETURN(DCGUI_EXIT_OK)
ENDIF

RETURN DCGUI_NONE


- Michael

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Sat Jan 30, 2010 10:32 pm
by rdonnay
What happens if you remove CASCADE from DCGETOPTIONS ?

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Sat Jan 30, 2010 11:11 pm
by edv-rudrich
Hi (from China)

same behaviour when I remove CASCADE

- Michael

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Sun Jan 31, 2010 7:05 am
by rdonnay
I wonder if the handler is interfering with the code that saves the coords.

You should see an entry in your registry under HKEY_CURRENT_USER\SOFTWARE\Michael\Demo\Fenster\Windows.

It will have the same name as the title (caption) of the window.

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Sun Jan 31, 2010 6:37 pm
by edv-rudrich
Hi --

sorry, no entry...

- Michael

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Sun Jan 31, 2010 6:38 pm
by edv-rudrich
Hi again:
Could you compile and run the code?
So you might find out what's wrong..

- Michael

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Sun Jan 31, 2010 7:03 pm
by RDalzell
Hallo Michael,

Remove the "\" from before the "SOFTWARE"

i.e.
was:
DC_AutoRestoreWindow ({HKEY_CURRENT_USER, '\SOFTWARE\Michael\Demo\Fenster'})

Should be:
DC_AutoRestoreWindow ({HKEY_CURRENT_USER, 'SOFTWARE\Michael\Demo\Fenster'})

Rick

Re: Need Autorestore Window in @ .. DCDIALOG

Posted: Sun Jan 31, 2010 7:20 pm
by edv-rudrich
Hey Rick -

that does it!!!
Thank you..

man - what a trivial bug :-((

Thanks

- Michael