|
Post by Roger Cabo on Jun 30, 2022 19:55:26 GMT 1
Hi everyone, I have a strange problem with Sub XXX_click() routines in WIN10. Here is an easy example. Run the tiny program. + Then click on the button in the frx1 form " click here" Stop Occurs.. Click NO.. to continue the program code. + Then the second form frm2 will open. ------ Until here all runs well ------ + Now close the second frm2 form. + Then click "Click here" in the first form again. Now the Sub Kunde_Click() is not called! And the Stop command is not executed as well. Did you have the same issue? Roger
Attachments:SUB Bug.G32 (562 B)
|
|
|
Post by Roger Cabo on Jun 30, 2022 20:02:06 GMT 1
Another quick version of the issue:
Attachments:SUB Bug2.G32 (710 B)
|
|
|
Post by (X) on Jun 30, 2022 20:11:00 GMT 1
Your original code...
LoadForm frm1 LoadForm frm2 Hidden
OcxOcx frm1 Command Kunde = "Click here", 0, 0, 200, 100 OcxOcx frm1 Command Kunde2 = " Or click here", 0, 150, 200, 100
Do Sleep Loop Until Me Is Nothing
Sub Kunde_Click() MsgBox "Press OK" frm2.Show MsgBox "now Close the new form2" Sub Kunde2_Click() MsgBox "Press OK" frm2.Show MsgBox "now Close the new form2"
I think this works...
LoadForm frm1 OcxOcx frm1 Command Kunde = "Click here", 0, 0, 200, 100 OcxOcx frm1 Command Kunde2 = " Or click here", 0, 150, 200, 100
Do Sleep Loop Until Me Is Nothing
Sub Kunde_Click() If IsNothing(frm2) LoadForm frm2 Hidden Top MsgBox "Press OK" frm2.Show MsgBox "now Close the new form2" Sub Kunde2_Click() If IsNothing(frm2) LoadForm frm2 Hidden Top MsgBox "Press OK" frm2.Show MsgBox "now Close the new form2"
If the user closes frm2, the program will need to load it again.
A request to show: "frm2.Show" just won't cut it.
|
|
|
Post by (X) on Jun 30, 2022 20:18:56 GMT 1
Hi everyone, I have a strange problem with Sub XXX_click() routines in WIN10. Here is an easy example. Run the tiny program. + Then click on the button in the frx1 form " click here" Stop Occurs.. Click NO.. to continue the program code. + Then the second form frm2 will open. ------ Until here all runs well ------ + Now close the second frm2 form. + Then click "Click here" in the first form again. Now the Sub Kunde_Click() is not called! And the Stop command is not executed as well. Did you have the same issue? Roger
If a form has been closed, just running <form>.show won't work. You will need to reload it.
|
|
|
Post by (X) on Jun 30, 2022 20:31:38 GMT 1
As you have done, to avoid reloading a form, you can "Hide" it but it will stay loaded and hidden even if you close down your main form. To close such a program you can still perform a STOP (Ctrl-Break) or End Task from the Task Manager.
To avoid a program that does not fully shutdown, you can declare the subordinate forms as: "Owned" by the main form or establish a Parent-Child relationship *, then, when the Owner / Parent form is closed the owned / child forms are automatically closed even if "hidden".
The following code may have a flaw because cmd1_Click only hides the form. Therefore when you shutdown your main form the hidden form is still loaded and hidden. So, either frm2 should be previously loaded as owned or simply closed instead of hidden.
Sub Kunde_Click() If IsNothing(frm2) LoadForm frm2 Hidden Top MsgBox "Press OK" frm2.Show frm2.OnTop = True MsgBox "now Close the new form2" Sub Kunde2_Click() If IsNothing(frm2) LoadForm frm2 Hidden Top MsgBox "Press OK" frm2.Show frm2.OnTop = True MsgBox "now Close the new form2" Sub cmd1_Click frm2.Hide
|
|
|
Post by Roger Cabo on Jun 30, 2022 20:44:34 GMT 1
Thanks.. but there is anything strange anyway.. Normaly you can use Cancel? = True in SUB FRm2_Close() to prevent unloading a form. You can simply use Form.Hide afterwards. This is recommended. And when you use a lot OCXOCX Frm2 Commands in form 2... you must reload all the stuff as well... when you use Loadform Frm2. Simply hiding and show a form is great pre caching to speed up things. The next demo is also strange to me. Simply start and close the form.. GB32 hangs in the do loop. Attachments:SUB Bug_4.G32 (614 B)
|
|
|
Post by Roger Cabo on Jun 30, 2022 20:54:29 GMT 1
This one works.. for any reason.. it use .Hide Perhaps I become a bit old :-] Attachments:SUB Works.G32 (632 B)
|
|
|
Post by Roger Cabo on Jun 30, 2022 21:08:09 GMT 1
|
|
|
Post by dragonjim on Jun 30, 2022 21:09:48 GMT 1
Very interesting: Me is definitely set to frm1 (put a Trace statement after Set Me = frm1) but it is not recognised in the Do...Loop.
Oddly enough, the following works fine (as long as you click the command button; if you click the window's close button, the program freezes).
OpenW 1 Ocx Command cmd = "Click Me", 10, 10, 100, 25 OpenW Hidden 2 Set Me = Win_1 Do : Sleep : Until Me Is Nothing CloseW 2
Sub cmd_Click CloseW 1 EndSub
|
|
|
Post by (X) on Jun 30, 2022 21:12:00 GMT 1
Here frm2 is loaded but never shown, so, the user can not close it because it is hidden. Even if you close frm1, Me takes on the identity of frm2 automatically, and the loop condition:"Loop Until Me Is Nothing", is now essentially waiting for the frm2 to close. Since frm2 is hidden, the user can't see it and can't close it therefore the program seems to hang. Ctrl-Break will let you cancel.
LoadForm frm1 OcxOcx frx1 Command Kunde = "Click here", 0, 0, 200, 100 OcxOcx frx1 Command Kunde2 = "Click here", 0, 150, 200, 100 LoadForm frm2 Hidden
Set Me = frm1
Do Sleep Loop Until Me Is Nothing
|
|
|
Post by (X) on Jun 30, 2022 21:18:38 GMT 1
Very interesting: Me is definitely set to frm1 (put a Trace statement after Set Me = frm1) but it is not recognised in the Do...Loop. Oddly enough, the following works fine (as long as you click the command button; if you click the window's close button, the program freezes). OpenW 1 Ocx Command cmd = "Click Me", 10, 10, 100, 25 OpenW Hidden 2 Set Me = Win_1 Do : Sleep : Until Me Is Nothing CloseW 2
Sub cmd_Click CloseW 1 EndSub "OpenW Hidden 2" loads Win_2 as Hidden.
I imagine, If Me (as Win_1) is closed, Me immediately defaults to the next form in the queue, the next form: Win_2 is assigned to Me automatically. Because Me (as Win_2) is Hidden the user can't close it. The program seems to freeze.
|
|
|
Post by dragonjim on Jun 30, 2022 21:24:02 GMT 1
I think you are probably correct in your surmise, although it does not explain why the Do..Loop is terminated in on the closing of the first window through the command button sub.
I know Sjouke did a lot of work getting Me working at all; I think what we have here are things he didn't get round to fixing.
My advice is to pas this on to him; however, he is busy at the moment, so be prepared to wait for a reply.
|
|
|
Post by Roger Cabo on Jun 30, 2022 21:30:37 GMT 1
The exe!
I never now anything of machine learning
|
|
|
Post by (X) on Jul 1, 2022 23:08:51 GMT 1
The exe!
I never now anything of machine learning 8-)
Is this a specific case or do you always get this message for any attempt to run a GFA compiled application?
|
|
|
Post by Roger Cabo on Jul 5, 2022 16:51:18 GMT 1
The exe!
I never now anything of machine learning
Is this a specific case or do you always get this message for any attempt to run a GFA compiled application? In this case I got the message. (SUB Bug.G32 versions) In others I do not get any message. I wrote to the Malwarebytes Team and send them the positive false already for checking!
|
|
webu
Full Member
Posts: 149
|
Post by webu on Jul 5, 2022 23:20:59 GMT 1
I think, this will close all 'Mes'! I end my programs with a 'Me_Close'-call from different places in the code. I don't care about dialogs and windows, because every Me will be closed.
OpenW Hidden 2 OpenW Hidden 3 OpenW Hidden 4 OpenW Hidden 5 OpenW 1 Do : Sleep : Until Win_1 Is Nothing
Me_Close
Proc Me_Close Do Sleep Me.Close Delay 0.2 Until Me Is Nothing End
|
|