Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Message processing

  1. #1
    Join Date
    Sep 2004
    Posts
    281
    Rep Power
    0

    Default Message processing

    I am designing a application that will require the processing of some windows messages. Is it mandatory that I redesign the window procedsure to process these new messages?

  2. #2
    Join Date
    Jan 2004
    Posts
    2,011
    Rep Power
    0

    Default

    i would assume so. in winapi for c++ you'ld definatly have to modify the wndproc() and just common sense of it sound like you'ld have to redefine it or extend it if its a predifind function. i had to write my own when doing winapi+ but there was a standard one that i learn which i always re used and modified as i saw fit to handle msgs in a particular manner

  3. #3
    Join Date
    Mar 2003
    Posts
    492
    Rep Power
    0

    Default

    In some cases you dont have to override the WndProc(). It depends on which message you are trying to process.

    You can declare your procedure to trap certain messages in your private section of your form.

    eg)

    TMyForm = class(TForm)
    ....
    private
    procedure CatchMyMessage(var Message : TMessage); message WM_WHATEVER_MESSAGE

    Now create the procedure to handle the message when in comes around in the message loop.

    If you have to override the WndProc() remember to save the OldProc and replace it when you're done.

  4. #4
    Join Date
    Sep 2004
    Posts
    281
    Rep Power
    0

    Default

    Thanks guys. Blunty Killer's responce is what i was hoping for.

    will give that a shot...

  5. #5
    Join Date
    Mar 2003
    Posts
    492
    Rep Power
    0

    Default

    You should note, that these are only messages directed at the handle of the form that owns the message handler. So if you are processing messages between applications you will need to know the handle of the form you are sending the message to. You would use the SendMessage() or PostMessage() functions for this.

    Are you trying to process Windows Messages from the OS? Trying to trap certain messages or trying to communicate between applications and forms?

  6. #6
    Join Date
    Sep 2004
    Posts
    281
    Rep Power
    0

    Default

    I am trying to communicate between two applications. one will run as a service and the other will run as a user entry form to a database (GUI). And to be Honest this is my first Attempt to do somthing like this. i have read; and am still reading though some material to gain a better understanding of what i will need to make things work....it's quite alot of mater and they dont seem to explaing the entire process quite smoothly.

    I have used send and postmessage begore as well as some other window API's.

  7. #7
    Join Date
    Mar 2003
    Posts
    492
    Rep Power
    0

    Default

    I have a couple services apps written and running and the PostMessage is the quick and dirty way to communicate. But be warned, you should look into registering a unique message identifier, because sometimes you might define a message constant and some other app catches it coming from your service.

    It happened to my first service app sending a message tagged with my own WM_USER + SomeNumber. Turns out, when I sent it to bring my app out of sleep mode, it also maximized FireFox. Go figure that FireFox would actually trap this message and know its identifier.

    So that is a pitfall you need to be careful of when running service apps communicating with the main app.

  8. #8
    Join Date
    Sep 2004
    Posts
    281
    Rep Power
    0

    Default

    Since you mentioned it! is doing ""WM_USER + SomeNumber"
    standard/ only way to createa a unique msg ID
    can you point me to a resource that explaines the topic from intro to advance or at least the best intro resource you know off. i bout myself a copy of Mastering Delphi 7, i have not seen anything targeting this topic inside, not as yet anyway's.

    And yes it is quite intresting that firefox should trap a msp ID that you just craeated, there should be some place that holds/ list the know msg ID's to developers could check and ensoure that that does does not happen. Kind off what is done with intenet ports. As there is a list of the common ports in use. IE port 80 for http and 21/20 for ftp.

  9. #9
    Join Date
    Sep 2004
    Posts
    281
    Rep Power
    0

    Thumbs up

    If anyone else ever decides to venture down this road. Here are a few sources i found most useful

    http://www.howtodothings.com/compute...plication.html
    http://www.ibrtses.com/delphi/threads.html
    http://www.cryer.co.uk/brian/delphi/...ow_message.htm

  10. #10
    Join Date
    Mar 2003
    Posts
    492
    Rep Power
    0

    Default

    I think you can use the PeekMessage function in some cases to check a message in the message queue.

    For the RegisterMessage here is a link:
    http://delphi.about.com/od/windowssh.../aa093003c.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •