Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-02

cannot understand popup menu and form not-closing

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roberto Padovani

Hi list,

I have a problem hard to understand (for me), and hard to explain. I am writing a win32 application to let me quickly open files and folders; i'm going to place it in the quick launch bar near "start", so that with one click I get the (XML configurable) list of objects. I do not show the main form, but only the popup menu, right there where I clicked.
If I can click something on the list, a TProcess will take care of opening that file.
If I do not click anything within 5 seconds or if I click somewhere else, the application shall close itself.

The main problem is this:
- if I hoover with the mouse on one of the objects shown on the popup without clicking, after 5 seconds the application closes correctly
- if I hoover somewhere else (for example on "Cancel", using my attached example) without clicking, the popup closes, but the application does not. And then I have to kill the process.

What I really do not understand is that I can get it to work, i.e. application closing, only by adding the lines

//**** here is the trick
      showmessage('Timed out');
  //**** end of the trick

that you can see in the UnitMain.pas

Can anyone explain me this behaviour? Besides, what is the right way to have the application close itself after the popup.close(), without the trick?

Thanks a lot,

Roberto
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UnitMain.pas
Type: application/octet-stream
Size: 2705 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100212/6259e370/attachment-0004.obj> -------------- next part --------------
A non-text attachment was scrubbed...
Name: TryPopup.lpi
Type: application/octet-stream
Size: 7023 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100212/6259e370/attachment-0005.obj> -------------- next part --------------
A non-text attachment was scrubbed...
Name: TryPopup.lpr
Type: application/octet-stream
Size: 424 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100212/6259e370/attachment-0006.obj> -------------- next part --------------
A non-text attachment was scrubbed...
Name: UnitMain.lfm
Type: application/octet-stream
Size: 592 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100212/6259e370/attachment-0007.obj>

Reply by email

JoshyFun
to Roberto Padovani

Hello Lazarus-List,

Friday, February 12, 2010, 5:26:14 PM, you wrote:

RP> Hi list,

RP> I have a problem hard to understand (for me), and hard to explain. RP> I am writing a win32 application to let me quickly open files and RP> folders; i'm going to place it in the quick launch bar near "start", RP> so that with one click I get the (XML configurable) list of objects. RP> I do not show the main form, but only the popup menu, right there RP> where I clicked.
[...]
RP> Can anyone explain me this behaviour? Besides, what is the right way RP> to have the application close itself after the popup.close(), without RP> the trick?

This seems to be related to this bug report: http://bugs.freepascal.org/view.php?id=12552

It is a bit strange and seems to be related to the message queue process as in the bug report comments you can see that calling an Application.ProcessMessages before ending the affected function "solves" the problem.

Best regards, JoshyFun

Reply by email

Roberto Padovani
to JoshyFun

2010/2/12 JoshyFun :

Show quoted text 24 lines
Hello Lazarus-List, Friday, February 12, 2010, 5:26:14 PM, you wrote: RP> Hi list, RP> I have a problem hard to understand (for me), and hard to explain. RP> I am writing a win32 application to let me quickly open files and RP> folders; i'm going to place it in the quick launch bar near "start", RP> so that with one click I get the (XML configurable) list of objects. RP> I do not show the main form, but only the popup menu, right there RP> where I clicked. [...] RP> Can anyone explain me this behaviour? Besides, what is the right way RP> to have the application close itself after the popup.close(), without RP> the trick? This seems to be related to this bug report: http://bugs.freepascal.org/view.php?id=12552 It is a bit strange and seems to be related to the message queue process as in the bug report comments you can see that calling an Application.ProcessMessages before ending the affected function "solves" the problem.

I tried to put it everywhere but the problem is still there. Which is the affected function in your opinion?

R.

Show quoted text 11 lines
-- Best regards, ?JoshyFun -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

JoshyFun
to Roberto Padovani

Hello Lazarus-List,

you wrote
> It is a bit strange and seems to be related to the message queue > process as in the bug report comments you can see that calling an > Application.ProcessMessages before ending the affected function > "solves" the problem.

RP> I tried to put it everywhere but the problem is still there. RP> Which is the affected function in your opinion?

I was trying the last weekend to find the root of the problem debugging all LCL messages without success, seems that the window after the 5 seconds receives a "Are you alive" message which is not being processed so window is marked as "possible not alive" (background becomes a white background usually) and when the close is issued nothing happends. This problem must be fixed by somebody with a deep know of the LCL and the windows message system. If in the close mode you use "caFree" instead "caHide" it closes fine as the handle is destroyed but using "caHide" the window is hidden and thats the operation that fails.

The message queue seems to hold something like a pending showwindow not processed, the close sends a hidewindow but using sendmessage so the message is processed just in time, but as a showwindow is pending in the queue nothing heppends. This is not the exact behaviour as this could fail in the first close try but not in the next ones.

Try to .free the window programatically, if it works you are quite sure in the same situation as the bug report, if it fails the problem should be different.

Best regards, JoshyFun

Reply by email

JoshyFun

Hello Lazarus-List,

Monday, February 15, 2010, 10:36:53 AM, you wrote:

RP> I'm using caFree, but the application does not close, unless something RP> is shown; for example, a "showmessage" box or bettere a Form1.show. RP> However I set the form to be minimized, not showing in taskbar and RP> with width=height=0, so it doesn't flash.
RP> But I think it is a workround.

So it looks to something different, but maybe related in some way.

RP> I also tried to handle the WM_SHOWWINDOW, and my routine is actually RP> called, however the problem is not solved. Maybe I was just reacting RP> to the message, without "consuming" it. What do you think ?

I doubt that as the comsume of the event is a must which happends with or without your handle.

RP> Shall I submit a bug report ?

Yes, but it is important in this case to provide a sample application that raises the bug, either by clicking something (or a sequence of things to do) or by programatically trigger the unexpected behavior. Post only the source codes in the bug tracker, not the exe ;)

Best regards, JoshyFun

Reply by email