Another problem with dialog boxes

Another problem with dialog boxes

Postby driessen » Wed Sep 10, 2008 3:12 pm

Hello,

I have a very strange problem with dialog boxes. The dialog boxes are build from resources.

The code looks like this :
Code: Select all  Expand view  RUN
PRIVATE LnDlg,ClkDlg
......

DEFINE DIALOG LnDlg NAME ...
......
ACTIVATE DIALOG LnDlg NOWAIT ...

......

DEFINE DIALOG ClkDlg NAME ...
......
ACTIVATE DIALOG ClkDlg NOWAIT ...

At a certain point, one dialog box needs to be ended. To do this, I use :
Code: Select all  Expand view  RUN
ClkDlg:End()


But what happens ? When the dialog box ClkDlg is ended here, the dialog box LnDlg is ended as well.

I also noticed that the problem only occurs when ClkDlg is defined before LnDlg is defined. If LnDlg is defined before ClkDlg, then the problem doesn't occur.

How can there be any connection between those dialog boxes ?
Why does LnDlg end when ClkDlg is ended ?

Thank you very much in advance for any help.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Wed Sep 10, 2008 3:18 pm

Michel,

You are using private variables and non modal dialogboxes. As they are non modal, the execution of the PRG does not stop there and you exit from your function and those private variables get destroyed.

Please change those private variables into static variables
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby driessen » Wed Sep 10, 2008 3:24 pm

Antonio,

Thanks for your quick answer.

I defined those variables as PRIVATE right at the start of my main program. Is that not the same as a STATIC variable ?

I'll try your suggestion and I let you know the outcome.

Thanks a lot.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Wed Sep 10, 2008 3:32 pm

Michel,

Then use public variables
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby driessen » Wed Sep 10, 2008 3:48 pm

Antonio,

I changed the PRIVATE variables first to STATIC variables.

At the ClkDlg:End(), I got an error that "Variable ClkDlg doesn't exist".

Then I changed those variables to PUBLIC variables but than the behaviour is just the same as it was with PRIVATE variables.

What now ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Wed Sep 10, 2008 3:52 pm

Michel,

Could you provide me a small example to test here ? thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby driessen » Wed Sep 10, 2008 4:11 pm

Antonio,

I wish I could provide you with a example.

It a some very small parts of a huge application (more than 120.000 lines of code). Second problem that OLE is involved (for a connection with Word).

I'll try to give some more explanation :

ClkDlg is a small dialogbox. In combination, a timer is started for the user to know the time he has been using for a certain job. The dialogbox is used to end the clock and a registration of the time used is saved into a timesheet.

While the timer is running, a document in Word can be made. During the time, the document in Word is active, a small dialogbox is defined which contains some buttons for the user to be able to close Word and to save the document into the archive of the system.

So a small summary :

1. The clock is started (ClkDlg).
2. Word is starten through OLE with its dialog box (LnDlg).
3. ClkDlg is clicked to halt the time and the time used is registered.
4. And now, I notice that LnDlg has disappeared too (I found out through the debugger that LnDlg is closed at the instruction ClkDlg:End() )

In this case the problem does NOT happen :

1. Word is starten through OLE with its dialog box (LnDlg).
2. The clock is started (ClkDlg).
3. ClkDlg is clicked to halt the time and the time used is registered.
4. LnDlg is still available.

Do you have any idea ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Wed Sep 10, 2008 4:38 pm

Michel,

You can hide the dialogbox instead of ending it:

ACTIVATE DIALOG oDlg NOWAIT VALID ( oDlg:Hide(), .T. )

Next time you want to use it, don't create it again. Simply do oDlg:Show().

Lets see if this helps, if not, we will find another way :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Sep 10, 2008 4:46 pm

Michel,

I guess this is what is going on: the word dialog is child of the clock dialog, so when you End() the clock, the word is also ended.

Do it this way:

DEFINE DIALOG ClkDlg OF oWndMain

...

DEFINE DIALOG LnDlg OF oWndMain

this way, the word dialog is not a child of the clock dialog
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby driessen » Wed Sep 10, 2008 6:41 pm

Antonio,

That was indeed the problem.

I changed my code and anything is running fine now.

Thanks a lot. You've been a great help.

What a fantastic product FiveWin is.

See you.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 27 guests