[Lazarus] Carbon: Loosing kAEOpenDocuments AppleEvents before AppRun
dominique at savagesoftwaresolutions.com
dominique at savagesoftwaresolutions.com
Wed Oct 28 15:57:21 CET 2009
Ah, this would seem to explain the reason why the OnDropFiles is never
firing in my application.
I have about 15 forms between Application.Initialize; and Application.Run;
and I've never mangaed to get it working under Mac OS X,
even though I've followed the examples religiously. I also have a "Beta in
progresss" form, that appears before the main form is displayed.
Any ideas?
Dominique.
On Wed, 28 Oct 2009 15:50:34 +0100, "EarMaster - Bent Olsen"
<bent at earmaster.com> wrote:
> I might add that this also happens when you call CreateForm for two or
more
> forms, where you call ShowModal (as in a user login form) before the
> first/main form is showing.
>
> The ShowModal calls AppProcessMessages, and hence the events disappears
> before TApplicationProperties on the main form gets these.
>
> Best regards,
> Normann
>
>> -----Original Message-----
>> From: EarMaster - Bent Olsen [mailto:bent at earmaster.com]
>> Sent: 28. oktober 2009 14:06
>> To: 'lazarus at lists.lazarus.freepascal.org'
>> Subject: Carbon: Loosing kAEOpenDocuments AppleEvents before AppRun
>>
>> Hi,
>>
>> I came across a problem when using TApplicationProperties and waiting
>> for OnDropFiles to be called.
>>
>> In a normal Application Initialize, CreateForm, and Run, the
>> OnDropFiles event is fired, but if something happens in between
>> Initialize and Run (like multiple CreateForms with a couple of controls
>> "badly" calling ProcessMessages, or something else causing messages
>> being released), before AppRun sets up an event handler, the
>> OnDropFiles event is not fired - likely because the kAEOpenDocuments
>> message has been released way before.
>>
>> You can check this by creating a new application, put a
>> TApplicationProperties on Form1, assign OnDropFiles to a procedure
>> which just sets the forms caption to FileNames[0], and in the project
>> source code:
>>
>> ...
>> Application.Initialize;
>> Application.CreateForm(TForm1, Form1);
>> Application.ProcessMessages;
>> Application.Run;
>>
>> You need to create a shortcut to the compiled application on your Mac
>> Dock, and drag any file on to it - the application should execute, when
>> it is not running, and give you the name of the file in Form1's
>> caption.
>>
>> The OnDropFiles doesn't fire (that is, if the application wasn't
>> running and was being executed), but comment out the ProcessMessage and
>> the OnDropFiles works fine.
>>
>> This might be a normal behavior for ProcessMessages to release
>> unhandled messages, but I wish ProcessMessages could skip if no global
>> event handler is set, so it is unfortunate TApplicationProperties is
>> not receiving these messages.
>>
>> I'm not using ProcessMessages in the creating process in my
>> application, but some controls are doing this internally, making it
>> impossible to get OnDropFiles fired.
>>
>> Any tips? I could create the MainForm first, and create the other forms
>> in an event after Run, but why and how? MainForm's Show is call just
>> before AppRun, so this wouldn't do...
>>
>> Any help would be much appreciated. Best regards,
>> Normann
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
More information about the Lazarus
mailing list