Thread: quick question on windows API

  1. #1
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    quick question on windows API

    Do you people who program with Windows use SendMessage and PostMessage a lot? Or are these things that you CAN do, but there is no real need for them a lot.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793

    Re: quick question on windows API

    Originally posted by Leeman_s
    Do you people who program with Windows use SendMessage and PostMessage a lot? Or are these things that you CAN do, but there is no real need for them a lot.
    :: Taps Monitor ::

    "Hello!!?? Windows Board??!?"

    Yeah, I use SendMessage a lot to communicate with controls.....PostMessage not as much

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I think the only difference between the two is that SendMessage blocks while PostMessage returns immediately. But yes, used quite a lot...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Messages are a way of allowing communication between different processes, running in different threads. The Windows message API may seem complicated, but I don't see a better way of doing things.

    All (non-console) windows applications use messages at some level. How do you think mouse movements, mouse clicks, key presses are forwarded to the application?

    Personally, I use Borland BCB, which hides alot of the implementation of messages. However, underneath its just handling messages for me.

  5. #5
    Registered User MicroFiend's Avatar
    Join Date
    Nov 2002
    Posts
    80
    Without the SendMessage API call... thr would be no abillity to totally mess up window objects and make em look like all kind of wierd controls at runtime.... think of the lack of fun you would have or am i the only one who is sad enough to send buttons loadsof wierd messages making em act like text fields :?

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Messages are a way of allowing communication between different processes, running in different threads.
    True but not solely. It also allows your app to communicate with it's own objects in a non-blocking way. That is, were you to just manipulate a control directly, you would slow down the "multitasking" feel of your app. By sending messages, you are in a sense making your program multithreaded from within itself...


    Finally, console apps too are actually windows programs in disguise, and so they use the Windows message system just as heavily (unless compiled as DOS apps - my compiler won't even do that!).

    And Microfiend, yes, you are the only one
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    lol uhh, I don't think I've ever used either one of those functions... is that a bad thing, or is it just something I'll have to grow into? (like eating vegetables, for example )
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I also tend to use the macros for specific types of controls from commctrl.h

    ie
    ListView_GetItemCount() instead of SendMessage and LVM_GETITEMCOUNT
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  9. #9
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Use both all the time.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick question on learning win API...
    By yaya in forum Windows Programming
    Replies: 7
    Last Post: 01-05-2008, 06:14 PM
  2. A question about windows programming
    By Hussain Hani in forum Windows Programming
    Replies: 16
    Last Post: 05-23-2007, 07:38 AM
  3. Windows API - Controlling other windows
    By Asmyldof in forum Windows Programming
    Replies: 11
    Last Post: 11-06-2006, 08:05 AM
  4. Replies: 5
    Last Post: 08-16-2006, 02:05 PM
  5. A quick comprehension question...
    By Junior89 in forum Windows Programming
    Replies: 2
    Last Post: 01-08-2006, 08:27 PM