Another problem with dialog boxes

Post Reply
User avatar
driessen
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Another problem with dialog boxes

Post by driessen »

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

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

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.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

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
driessen
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

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.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Michel,

Then use public variables
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
driessen
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

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.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Michel,

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

Antonio Linares
www.fivetechsoft.com
User avatar
driessen
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

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.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

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: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

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
driessen
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

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.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Post Reply