Sign in Join

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

Mailing lists / fpc-devel / 2010-02

procedure ... message(); in Linux

52 messages · 12 people · –

Reply by email Subscribe to this list Your subscription

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

Michael Schnell

What messages does it capture ?

How to send a message from a thread ?

How to send a message from another process ?

I do know that there are other (supposedly more decent) ways to do inter-thread and inter-process communication, But as procedure...message(), does compile in a Linux executable, I'd like to know how it's supposed to be used.

-Michael

Reply by email

Marco van de Voort
to Michael Schnell

In our previous episode, Michael Schnell said:

Show quoted text 8 lines
How to send a message from a thread ? How to send a message from another process ? I do know that there are other (supposedly more decent) ways to do inter-thread and inter-process communication, But as procedure...message(), does compile in a Linux executable, I'd like to know how it's supposed to be used.

Afaik it is nothing more than a table that says "for msg with value xxx call method yyy". IOW it is abstract.

Reply by email

Graeme Geldenhuys
to Michael Schnell: What messages does it capture ? How to send a message from a thread ? How to send a…

I hope I understand your question correctly...

Michael Schnell wrote
What messages does it capture ?

Anything that fits into 'var message' parameter. fpGUI uses the following base structure for the event queue.

  TfpgMessageRec = record
    MsgCode: integer;
    Sender: TObject;
    Dest: TObject;
    Params: TfpgMessageParams;
    Stop: Boolean;
  end;
How to send a message from a thread ?

fpGUI has an internal event queue which later gets dispatched to the target using TObject.Dispatch(). fpGUI v0.4 and earlier used a Object based even system and had it's own distribution functions. Later version of fpGUI uses Record based messages and the 'message' language feature of Object Pascal.

fpGUI has the following procedures defined in fpg_main.pas unit that work with the message queue.

procedure fpgPostMessage(Sender, Dest: TObject; MsgCode: integer; var
aparams: TfpgMessageParams); overload;
procedure fpgPostMessage(Sender, Dest: TObject; MsgCode: integer); overload;
procedure fpgSendMessage(Sender, Dest: TObject; MsgCode: integer; var
aparams: TfpgMessageParams); overload;
procedure fpgSendMessage(Sender, Dest: TObject; MsgCode: integer); overload;
procedure fpgDeliverMessage(var msg: TfpgMessageRec);
procedure fpgDeliverMessages;

Here is an example of the X11 backend in fpGUI translating the X11 window messages into fpGUI messages and dispatching them to the message queue.

--------------------------------------
X.FocusIn:
fpgPostMessage(nil, FindWindowByHandle(ev.xfocus.window),

            FPGM_ACTIVATE);
    X.FocusOut:
        fpgPostMessage(nil, FindWindowByHandle(ev.xfocus.window),
            FPGM_DEACTIVATE);
    X.EnterNotify:
        fpgPostMessage(nil, FindWindowByHandle(ev.xcrossing.window),
            FPGM_MOUSEENTER);

X.LeaveNotify:
fpgPostMessage(nil, FindWindowByHandle(ev.xcrossing.window),

            FPGM_MOUSEEXIT);

--------------------------------------

All the above describes messages from main thread to component or thread to component.

For one thread to another thread, I would imagine a simple thread-safe message queue could be created (a simple list with message items). I'm not sure if FPC supplies a thread-safe list class. Each thread will periodically check the queue for messages related to itself, or post messages for other threads. A multi-read-single-write synchronizer (available in FPC as TMultiReadExclusiveWriteSynchronizer) could be used when accessing the message queue.

How to send a message from another process ?

On example would be to use IPC as defined in the SimpleIPC unit - part of FCL. SimpleIPC documentation can be found at:

http://www.freepascal.org/docs-html/fcl/simpleipc/index.html

You can obviously use other custom communications methods too.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Michael Schnell
to Graeme Geldenhuys: I hope I understand your question correctly... Anything that fits into 'var message'…
Graeme Geldenhuys wrote 10 lines
> How to send a message from another process ? > On example would be to use IPC as defined in the SimpleIPC unit - part of FCL. SimpleIPC documentation can be found at: http://www.freepascal.org/docs-html/fcl/simpleipc/index.html

Yep. Here you need to do a server and a client and it does not seem to use "procedure .... message". But In Delphi/Windows you don't need to create a server. Just using "procedure .... message" is enough o receive a message from another process. If this is possible with FPC/Linux, I should make sure that it's still possible with the NoGUIApplication package.

-Michael

Reply by email

Michael Schnell
to Graeme Geldenhuys: I hope I understand your question correctly... Anything that fits into 'var message'…
Graeme Geldenhuys wrote 12 lines
fpGUI has an internal event queue which later gets dispatched to the target using TObject.Dispatch(). fpGUI v0.4 and earlier used a Object based even system and had it's own distribution functions. Later version of fpGUI uses Record based messages and the 'message' language feature of Object Pascal. fpGUI has the following procedures defined in fpg_main.pas unit that work with the message queue. procedure fpgPostMessage(Sender, Dest: TObject; MsgCode: integer; var aparams: TfpgMessageParams); overload;

my fpc sources don't have any fpg* files other than fpglibc* and fpgtk*.

Lazarus does have a directory /lazarus/lcl/interfaces/fpgui/ but it does not contain a file fpg_main.* and fpgPostMessage is not mentioned in any file :(.

-Michael

Reply by email

Sergei Gorelkin
to Michael Schnell: Yep. Here you need to do a server and a client and it does not seem to use "procedure…
Michael Schnell wrote
Yep. Here you need to do a server and a client and it does not seem to use "procedure .... message". But In Delphi/Windows you don't need to create a server. Just using "procedure .... message" is enough o receive a message from another process.

Things are more complicated than that. At the very least Delphi application must receive the message from system (using GetMessage() or other API), determine the target object and call its Dispatch method with message as parameter.

If this is possible with FPC/Linux, I should make sure that it's still possible with the NoGUIApplication package.

Windows has a built-in transport for the messages, Linux doesn't. Of course there are libraries providing similar or even better functionality, but you end up depending on particular library.

Sergei

Reply by email

Michael Schnell
to Sergei Gorelkin: Things are more complicated than that. At the very least Delphi application must receive…

On 02/18/2010 02:48 PM, Sergei Gorelkin wrote:If this is possible with FPC/Linux, I

Show quoted text 8 lines
> should make sure that it's still possible with the NoGUIApplication > package. > Windows has a built-in transport for the messages, Linux doesn't. Of course there are libraries providing similar or even better functionality, but you end up depending on particular library.

I do know this. This is why I need to port Martin's NoGUIApplication, which has an internal message queue, to Lazarus,

I suppose with Linux, FPC (or Lazarus ? ) uses X11 as a message queue provider. But I was not yet able to find out how to post a message into the X11 queue (with a thread or another application) and capture this message by an FPC "procedure ... message" construct. (with FPC/Lazarus on Windows this does work fine using Windows messages)

If it does work with Linux/X1, I need to think how to make it work with NoGUIApplication, as well. If it does not work in Linux, anyway, I don't think I'll bother.

-Michael

Reply by email

Marc Weustink
to Michael Schnell: On 02/18/2010 02:48 PM, Sergei Gorelkin wrote:If this is possible with FPC/Linux, I I do…
Michael Schnell wrote 16 lines
On 02/18/2010 02:48 PM, Sergei Gorelkin wrote:If this is possible with FPC/Linux, I >> should make sure that it's still possible with the NoGUIApplication >> package. >> > Windows has a built-in transport for the messages, Linux doesn't. Of > course there > are libraries providing similar or even better functionality, but you > end up depending > on particular library. I do know this. This is why I need to port Martin's NoGUIApplication, which has an internal message queue, to Lazarus, I suppose with Linux, FPC (or Lazarus ? ) uses X11 as a message queue provider.

Nope. On non windows widgetrsets, lazarus implements its own messagequeue which is handled in application.Idle. On some widgetsets (iirc Carbon and QT) this messagequeue is mixed with the messagequeue if that widgetset.

But I was not yet able to find out how to post a message into the X11 queue (with a thread or another application) and capture this message by an FPC "procedure ... message" construct. (with FPC/Lazarus on Windows this does work fine using Windows messages)

AFAIK, X11 has no messagequeue but is based on callbacks.

If it does work with Linux/X1, I need to think how to make it work with NoGUIApplication, as well. If it does not work in Linux, anyway, I don't think I'll bother.

Marc

Reply by email

Michael Schnell
to Marc Weustink
Marc Weustink wrote
Nope. On non windows widgetrsets, lazarus implements its own messagequeue which is handled in application.Idle.

I'll try to find out how this works....(and how things like Timer and the waiting for events are done). Maybe it's an alternative to use this code instead of the mse code (which actually does run fine for me when (ported and) compiled with Lazarus) for NoGUIApplication.

-Thanks,
-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell: my fpc sources don't have any fpg* files other than fpglibc* and fpgtk*. Lazarus does…
Michael Schnell wrote 6 lines
my fpc sources don't have any fpg* files other than fpglibc* and fpgtk*. Lazarus does have a directory /lazarus/lcl/interfaces/fpgui/ but it does not contain a file fpg_main.* and fpgPostMessage is not mentioned in any file :(.

Sorry for the confusion. I was talking about fpGUI, so thought it would be obvious to look in the fpGUI repository for those methods and units. fpGUI is not part of FPC or Lazarus, it's a separate project like MSEgui.

fpGUI Home page:
http://opensoft.homeip.net/fpgui/

SourceForge project page
http://sourceforge.net/projects/fpgui/

Direct repository access:
git clone git://fpgui.git.sourceforge.net/gitroot/fpgui/fpgui

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys

Sorry, I posted the reply to the Lazarus list by accident.

---------- Forwarded message ----------

Earlier message 41 lines
From: Graeme Geldenhuys Date: 18 February 2010 19:16 Subject: Re: [fpc-devel] procedure ... message(); in Linux To: Lazarus mailing list On 18 February 2010 15:16, Michael Schnell wrote: > > Yep. Here you need to do a server and a client and it does not seem to "client/server" is just a term used for communications. You could use pipes too. > use "procedure .... message". But In Delphi/Windows you don't need to > create a server. Just using "procedure .... message" is enough o receive Well that "message" feature is Windows technology, and Delphi was designed ONLY for Windows, so obviously it's not going to be the same on other platforms. IPC is an alternative to accomplish a similar task, and it works on multiple platforms. -- Regards,  - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ -- Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Michael Schnell: Of course I did try this, but the project seems to be abandoned:…
Michael Schnell wrote
Of course I did try this, but the project seems to be abandoned:

It works fine here (from the office and home). I can also assure you the project is not abandoned. :) I use it daily in our company and am currently busy putting together the next (long overdue) release.

The project website is hosted on our company servers. We sometimes get minor internet outages (we have ADSL), but I wasn't aware of any today.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Nikolai Zhubr
to Michael Schnell: Yep. Here you need to do a server and a client and it does not seem to use "procedure…

18.02.2010 16:16, Michael Schnell:
[trim]

use "procedure .... message". But In Delphi/Windows you don't need to create a server. Just using "procedure .... message" is enough o receive a message from another process.

No. AFAIK even in Delphi, "message procedures" for non-components are pretty much abstract (and probably almost useless). The messaging system you are talking about only works automagically for components belonging to the Application component (and is therefore limited to the main thread).

If you create a thread in Delphi (even a Tthread descendant) you will not be able to insert components to it, because it is not a component itself. So, if you are going to make this messaging work to some degree in non-main thread on windows, you'll probably need to take care of some things manually. First, you'll need some window handle created within your thread, as otherwise OS will not even create a message queue for this thread. Delphi won't do this for you, AFAIK. Then, in the body of your thread, you'll need to regularily fetch new messages (GetMessage or PeekMessage etc) and actually dispatch them to some objects (maybe to this very tthread object for instance).

If this is possible with FPC/Linux, I

should make sure that it's still possible with the NoGUIApplication package.

When I ported some threaded delphi application to linux I replaced window handles (used for inter-thread communication) by unix pipes. These are not exactly the same, but generally provide sufficient functionality and are quite easy to use. No idea if it is anywhere appropriate in your case, though.

Hope this helps:)

Nikolai

Show quoted text 6 lines
-Michael _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Graeme Geldenhuys
to Michael Schnell: What messages does it capture ? How to send a message from a thread ? How to send a…
Michael Schnell wrote
What messages does it capture ? How to send a message from a thread ?

Just thought of something else. Not sure if this is a solution, but it might head you in the right direction. Have a look at two behavioural design patterns: Chain of Responsibility, Command.

These patterns describe something like what you are trying to do. If you can't find documentation on these, I can email you the two chapters from the Design Patterns (GoF) book.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Michael Schnell
to Nikolai Zhubr: 18.02.2010 16:16, Michael Schnell: [trim] No. AFAIK even in Delphi, "message procedures"…
Nikolai Zhubr wrote
... if you are going to make this messaging work to some degree in non-main thread on windows, you'll probably need to take care of some things manually.

Of course you are right that the Delphi / Windows paradigm only allows for a single message queue and same is dedicated to the main thread as a receiver. Lazarus / Windows uses the same algorithm as Delphi. Lazarus / Linux reproduces the same behavior with a different algorithm. For now, the NoGUIApplication Lazarus package I am planning, is suppose to reproduce this behavior, too, with a home-brew message queue. For the future I think about having the home-brew message queue done in a way that allows for multiple instances of same and thus allow for worker threads to be programmed using an event-driven paradigm.

When I ported some threaded delphi application to linux I replaced window handles (used for inter-thread communication) by unix pipes.

While this of course is possible, I suppose a pure user-land algorithm should offer better performance.

These are not exactly the same, but generally provide sufficient functionality and are quite easy to use. No idea if it is anywhere appropriate in your case, though.

The event queue (ported form mse) already does work nicely for me (e.g. with for timer events, TThread.Synchronize). I just wonder if supporting procedure ... messages in the package is possible / viable / necessary.

-Michael

Reply by email

Michael Schnell
to Graeme Geldenhuys: Just thought of something else. Not sure if this is a solution, but it might head you in…
Graeme Geldenhuys wrote
Just thought of something else. Not sure if this is a solution,

Thanks a lot for your support, but in fact I am not seeking for a solution, but the question is if the compilable FPC construct "procedure ... message" works at all in (Lazarus /) Linux and what it can be used for.

I could verify, that with (Lazarus /) Windows "procedure ... message" can fetch windows system messages and messages to a window generated by a thread (I did not yet test sending windows messages from another application, but as I used postmessage() and not postthreadmessage(), I suppose it will work as well. I did not get postthreadmessage working in Lazarus/Windows nor in Delphi yet.)

-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell: It works at home, No idea why it is blocked here. Is this a kind of spam-prone server ?…
Michael Schnell wrote 5 lines
On 02/18/2010 05:35 PM, Michael Schnell wrote: > I'll try at home .... > It works at home, No idea why it is blocked here. Is this a kind of spam-prone server ?

In this last month I was bombarded with web crawlers even though I have a robots.txt file setup. So about a week ago I setup a .htaccess in the opensoft.homeip.net root website to block some of those domains.

Is your domain listed in any of these?

-----------------------
# Deny hosts or spam domains
RewriteCond %{REMOTE_HOST} sputnikmedia.net [NC,OR] RewriteCond %{REMOTE_HOST} cuil.com [NC,OR]
RewriteCond %{REMOTE_HOST} altushost.com [NC,OR]
RewriteCond %{REMOTE_HOST} ufanet.ru [NC]
-----------------------

I only set up the blocking for the http://opensoft.homeip.net site. Can you access any of the other virtual sites hosted on our server?

http://capture.myphotos.cc
or
http://mastermaths.dnsalias.com

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Show quoted text 13 lines
So about a week ago I setup a .htaccess in the opensoft.homeip.net root website to block some of those domains. Is your domain listed in any of these? ----------------------- # Deny hosts or spam domains RewriteCond %{REMOTE_HOST} sputnikmedia.net [NC,OR] RewriteCond %{REMOTE_HOST} cuil.com [NC,OR] RewriteCond %{REMOTE_HOST} altushost.com [NC,OR] RewriteCond %{REMOTE_HOST} ufanet.ru [NC] -----------------------

Nope it's "lumino.de". (And I of course can't see your .haccess file :( , either.

-Michael

Reply by email

Michael Schnell
to Michael Schnell: What messages does it capture ? How to send a message from a thread ? How to send a…

Can't anyone answer the question if in Linux the legal and compilable construct

procedure... message;

either

is not supposed to be working

or

how I can have such a procedure be executed (e.g. by posting a message from a thread or another application, what I successfully did in Windows.

P.S.:
I found that with

Application.QueueAsyncCall

I can create an queued event in a thread that is executed by the mainthread when all other queued events are done.

This is what procedure...message can do for thread communication, but of course the syntax is completely different.

Thanks again,
-Michael

Reply by email

Mattias Gärtner
to Michael Schnell

Zitat von Michael Schnell :

Show quoted text 13 lines
Can't anyone answer the question if in Linux the legal and compilable construct procedure... message; either is not supposed to be working or how I can have such a procedure be executed (e.g. by posting a message from a thread or another application, what I successfully did in Windows.

Maybe if you provide a more complete example, some Linux users can help you.

Mattias

Reply by email

David W Noon
to Michael Schnell: Can't anyone answer the question if in Linux the legal and compilable construct…

On Thu, 25 Feb 2010 17:59:05 +0100, Michael Schnell wrote about Re: [fpc-devel] procedure ... message(); in Linux:

Show quoted text 14 lines
Can't anyone answer the question if in Linux the legal and compilable construct procedure... message; either is not supposed to be working or how I can have such a procedure be executed (e.g. by posting a message from a thread or another application, what I successfully did in Windows.

I have been using the Message option on Procedure/Function declarations for a couple of years. Provided you are using Lazarus classes, it works just like Windows: the PostMessage() and SendMessage() functions in the LCLIntf unit provide closely analogous functionality to their Win32 API namesakes. [In all the applications I have written to exploit this, I used the Gtk2 widget set.]

What is it that you cannot get working?

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) =======================================================================

Reply by email

Nikolai Zhubr
to Michael Schnell: Can't anyone answer the question if in Linux the legal and compilable construct…

25.02.2010 19:59, Michael Schnell:

Show quoted text 8 lines
Can't anyone answer the question if in Linux the legal and compilable construct procedure... message; either is not supposed to be working

Is is working fine on linux, see my example below.

or how I can have such a procedure be executed (e.g. by posting a message from a thread or another application, what I successfully did in Windows.

Some sort of IPC is necessary as a ground for that. On windows, PostMessage/GetMessage mechanism is always available and it does not require any additional libraries (as it is an integral part of the system), so it is used most of the time.
On linux, there is no such "global default" (AFAICS), but you are free to choose some existing library or create your specific implementation based on OS functionality directly (like my favourite pipes or whatever).

Nikolai

------------------------------ cut -------------------------------
{$mode delphi}
{$ifdef win32 }{$apptype console }{$endif }
const
   const_my_msg = $7FFF;
type
   TMyMessage = record
     Msg: Cardinal;
     SomeData1: byte;
   end;
   TSomeTestObj = class
     procedure msg_my_msg_proc(var Msg: TMyMessage); message const_my_msg;
   end;
procedure TSomeTestObj.msg_my_msg_proc(var Msg: TMyMessage);
begin
   writeln('I got called! SomeData1 = ', Msg.SomeData1);
end;
var
   o: TSomeTestObj;
   m: TMyMessage;
begin
   m.Msg := const_my_msg;
   m.SomeData1 := 1;
   o := TSomeTestObj.Create;
   o.Dispatch(m);
   o.Free;
end.

Reply by email

Michael Schnell
to Mattias Gärtner: Zitat von Michael Schnell : Maybe if you provide a more complete example, some Linux…
Mattias Gärtner wrote
Maybe if you provide a more complete example, some Linux users can help you.

Sorry, but an example how "procedure ... message" can be used in Linux is what I am requesting.

A working example in Windows is trivial. Here it works exactly as in Delphi and can be triggered e.g. by "postmessage()" (which of course is a non portable Windows API call).

I also would be content when I would get an official statement that "procedure ... message" is not supposed to be functional in a Linux environment. But in this case I vote for having the compiler issue an error message.

-Michael

Reply by email

Michael Schnell
to David W Noon: On Thu, 25 Feb 2010 17:59:05 +0100, Michael Schnell wrote about Re: [fpc-devel] procedure…
David W Noon wrote 7 lines
for a couple of years. Provided you are using Lazarus classes, it works just like Windows: the PostMessage() and SendMessage() functions in the LCLIntf unit provide closely analogous functionality to their Win32 API namesakes. [In all the applications I have written to exploit this, I used the Gtk2 widget set.]

I'll try to find "PostMessage" in the LCL source code (once again).

What is it that you cannot get working?

When compiling, I get "Identifier not found: Postmessage", even though I do have "uses Classes" in a standard "Application" project.

-Michael

Reply by email

Michael Schnell
to Nikolai Zhubr: 25.02.2010 19:59, Michael Schnell: Is is working fine on linux, see my example below.…

OK, Thisa does take me one step further.

1) "procedure...message" does wok in Linux
2) it can be triggered by "Dispatch".

This is good news, as FPC/Lazarus is confirmed to work as expected. :) This is bad news as now I need to consider "procedure...message" when doing the NoGUIApplication package. ;)

What I now need to know is the exact spec of "Dispatch". Can it be legally used in a thread (like PostMessage in Windows can)?

Thanks a lot for your support !
-Michael

Reply by email

Mattias Gaertner
to Michael Schnell: I'll try to find "PostMessage" in the LCL source code (once again). When compiling, I get…
Show quoted text 16 lines
On 02/25/2010 07:47 PM, David W Noon wrote: > > for a couple of years. Provided you are using Lazarus classes, it > works just like Windows: the PostMessage() and SendMessage() functions > in the LCLIntf unit provide closely analogous functionality to their > Win32 API namesakes. [In all the applications I have written to > exploit this, I used the Gtk2 widget set.] > I'll try to find "PostMessage" in the LCL source code (once again). > What is it that you cannot get working? > When compiling, I get "Identifier not found: Postmessage", even though I do have "uses Classes" in a standard "Application" project.

Classes is not part of the LCL.
SendMessage is defined in unit LCLIntf and implemented in the LCL interfaces. In the end it calls Dispatch. AFAIK under gtk it does not support sending messages to/from other apps.

Mattias

Reply by email

Mattias Gaertner
to Michael Schnell: OK, Thisa does take me one step further. 1) "procedure...message" does wok in Linux 2) it…
Show quoted text 11 lines
OK, Thisa does take me one step further. 1) "procedure...message" does wok in Linux 2) it can be triggered by "Dispatch". This is good news, as FPC/Lazarus is confirmed to work as expected. :) This is bad news as now I need to consider "procedure...message" when doing the NoGUIApplication package. ;) What I now need to know is the exact spec of "Dispatch". Can it be legally used in a thread (like PostMessage in Windows can)?

PostMessage is threadsafe, dispatch is not.

Mattias

Reply by email

Michael Schnell
to Graeme Geldenhuys: And this is what I have been telling you since the start! :-) - Graeme - fpGUI Toolkit -…
Graeme Geldenhuys wrote 8 lines
Michael Schnell wrote: > 1) "procedure...message" does wok in Linux > 2) it can be triggered by "Dispatch". > And this is what I have been telling you since the start! :-)

I did not see the relevance, as I did not suppose that Dispatch is thread save and "procedure ...message" does not make any sense at all it it needs to be triggered from the Main thread, simulating - more or less
- a normal function call.

-Michael

Reply by email

Mattias Gaertner
to Michael Schnell
Show quoted text 9 lines
On 02/26/2010 10:19 AM, Mattias Gaertner wrote: > > SendMessage is defined in unit LCLIntf and implemented in the > LCL interfaces. > Great ! This is the info I needed. with "uses LCLIntf" it gets compiled.

There are several tools in Lazarus for this:
- click compile, fpc will give "identifier not found", right click on the message - popup menu - search identifier. This will search all units. On first time it may take a minute to scan
the about 1000 units of fpc.
- search / find in files

Mattias

Reply by email

Michael Schnell
to Mattias Gaertner
Mattias Gaertner wrote 7 lines
' There are several tools in Lazarus for this: - click compile, fpc will give "identifier not found", right click on the message - popup menu - search identifier. This will search all units. On first time it may take a minute to scan the about 1000 units of fpc.

Thanks a lot,
Sorry but no :(

Right-Clicking the message gives:
- Create local Variable
- Clear
- Copy selected messages to clipboard
- copy all messages to clipboard
- copy all and hidden messages to clipboard
- Help
- Save all messages to file

All these are very interesting options I was not aware of, but unfortunately no search for identifiers.

- search / find in files

Can search in
- Project Files
- open files
- a given directory.

(1) and (2) are not helpful,

(3) Of course I often did search the FPC or LCL sources using standard keyword search but here I get all the instances not just the definition and of course with these system functions there are several definitions that are included in the active sources or not depending on the compile-target.

-Michael

Reply by email

Michael Schnell
to Mattias Gaertner: On Fri, 26 Feb 2010 09:53:44 +0100 PostMessage is threadsafe, dispatch is not. Mattias
Mattias Gaertner wrote
PostMessage is threadsafe, dispatch is not.

Not only thread-save, but thread traversing, which is the proper function of the message delivering library service.

Seemingly the function names are wisely chose (regarding the work of a parcel service that uses a store-and foreword warehouse):

Dispatch() performs the local (i.e. within the same thread) delivery to the final recipient. This is to be done by the library itself (the parcel service agent).

PostMessage() performs giving the message to the library to have it transport it to the main thread (the remote location)., This is to be done by the user software (the client of the parcel service.

-Michael

Reply by email

Mattias Gaertner
to Michael Schnell: Sorry but no :( Right-Clicking the message gives: - Create local Variable - Clear - Copy…
Show quoted text 11 lines
On 02/26/2010 04:10 PM, Mattias Gaertner wrote: > ' > There are several tools in Lazarus for this: > - click compile, fpc will give "identifier not found", right click on > the message - popup menu - search identifier. This will search all > units. On first time it may take a minute to scan > the about 1000 units of fpc. > Thanks a lot, Sorry but no :(
Right-Clicking the message gives: - Create local Variable

You need lazarus 0.9.29.

- Search identifier

Show quoted text 25 lines
- Clear - Copy selected messages to clipboard - copy all messages to clipboard - copy all and hidden messages to clipboard - Help - Save all messages to file All these are very interesting options I was not aware of, but unfortunately no search for identifiers. > - search / find in files > Can search in - Project Files - open files - a given directory. (1) and (2) are not helpful, (3) Of course I often did search the FPC or LCL sources using standard keyword search but here I get all the instances not just the definition and of course with these system functions there are several definitions that are included in the active sources or not depending on the compile-target.

Wait until it finds the first, stop the search. Do find declaration on the first found.

Mattias

Reply by email

Mattias Gaertner
to Juha Manninen: You must first select the error saying "identifier not found" and then right click on it.…
Show quoted text 10 lines
Hi, > All these are very interesting options I was not aware of, but > unfortunately no search for identifiers. You must first select the error saying "identifier not found" and then right click on it. I tested it with some broken code and it gave no think it should always give some message.

What gave no feedback?

Mattias

Reply by email

Juha Manninen
to Mattias Gaertner: On Mon, 1 Mar 2010 11:43:23 +0200 What gave no feedback? Mattias

Hi,

What gave no feedback?

Ok, I tested again with a non-typical situation.
I worked with lazarus.lpi and built Lazarus from tools -> Configure Build Lazarus. The error messages show up just like when compiling a "normal" project but "search identifier" does nothing.

Now I tested with a "normal" project and it works. It is a cool feature actually.
I noticed a minor bug: the Scope combobox gets "Project" by default. If I click the down-arrow to see a list then the first "Lazarus IDE" gets selected automatically. I guess you forgot to set Combobox.ItemIndex and only set its text.

BTW, what does the Scope do? If I comment out SysUtils in my source, it always finds the missing function under FCL, whatever scope I select.

Juha

Reply by email

Mattias Gärtner
to Juha Manninen: Ok, I tested again with a non-typical situation. I worked with lazarus.lpi and built…

Zitat von Juha Manninen :

Show quoted text 8 lines
Hi, > What gave no feedback? Ok, I tested again with a non-typical situation. I worked with lazarus.lpi and built Lazarus from tools -> Configure Build Lazarus. The error messages show up just like when compiling a "normal" project but "search identifier" does nothing.

I tested with lazarus.lpi: It works.
Do you have english messages?

Show quoted text 6 lines
Now I tested with a "normal" project and it works. It is a cool feature actually. I noticed a minor bug: the Scope combobox gets "Project" by default. If I click the down-arrow to see a list then the first "Lazarus IDE" gets selected automatically. I guess you forgot to set Combobox.ItemIndex and only set its text.

It didn't matter for me. I now set the ItemIndex. Does that fix it?

BTW, what does the Scope do? If I comment out SysUtils in my source, it always finds the missing function under FCL, whatever scope I select.

That's the interesting difference between the codebrowser and a find declaration. Find declaration will search only via the uses sections and search paths. The codebrowser searches in whole packages and projects. That's why it can tell you in which unit an identifier is defined.
If you set scope to 'project' it will search in all units of the project. If you check the 'with packages' it will search in all packages required by the project too. This normally includes the FCL package, so it will search in all units installed by FPC.

Mattias

Reply by email

Mattias Gärtner
to Michael Schnell: I might try to get this running some day soon.... Try that on "PostMessage". I've not yet…

Zitat von Michael Schnell :

Show quoted text 8 lines
On 03/01/2010 10:36 AM, Mattias Gaertner wrote: > > You need lazarus 0.9.29. > I might try to get this running some day soon.... Try that on "PostMessage".

I get a method in unit InterfaceBase and a procedure in unit LCLIntf. Obviously you want the last.

I've not yet been able top find the Linux definition of same. Keeping on trying....

Mattias

Reply by email