What is uMsg????

This is a discussion on What is uMsg???? within the Windows Programming forums, part of the Platform Specific Boards category; I've just start to program in windows and I was wondering was uMsg is. Ive seen it like a prototype ...

  1. #1
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343

    Question What is uMsg????

    I've just start to program in windows and I was wondering was uMsg is. Ive seen it like a prototype

    LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);

    and I cant figure it out what it is??? Could someone please enlight me
    Thx in advance

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    You see, when you declare/define a window procedure, you specify the parameters.

    -type HWND is the window in which the message is being sent-
    -type UINT (your uMsg) is a simple number that specifies the message being sent to your window procedure-
    -type WPARAM is just another part of the message you can process-
    -type LPARAM is another part of the message you can process-
    1978 Silver Anniversary Corvette

  3. #3
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    the uMsg is the actual message sent to your window, you should make a big switch and make a handler for each message of your interest

    Oskilian

  4. #4
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Yeah, uMsg is pretty much what you base your decisions (the program's decisions) on.

    --Garfield
    1978 Silver Anniversary Corvette

  5. #5
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102
    I made a simply windows app with the console still enabled and put a cout in my callback function and found that it calls my callback function everytime the mouse moves jsut a little bit, passing my pointer across the window causes my function to be called at least a hundred times, if I didn't need to do anything when the mouse is moved should I make my callback function something like for the purose of not doing much processing just for a little mouse movment


    Code:
    LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
    {
        switch(msg)
         
    case(WM_MOUSEMOVE)://or whatever the mouse move message is
        {
            return(DefWindowProc(hwnd, msg, wparam, lparam));// Don't do anything cause I don't need to or call another function to handle the movement
        }
        default:
        {
        // Call another function to handle other messages
        if(ScndMsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam))return (1);
        else
       {
       return(DefWindowProc(hwnd, msg, wparam, lparam));
       }
    }
    I'm sure I've gotten the switch case syntax wrong, but you got the idea

    So that a long switch case with all the messsages doesn't have to be processed for the frequent mouse movements

    I'm asking would it be a good way to do things? I'm wondering on the side of my mind how exactly a switch case is processed, how much longer it takes if more messages are added to it
    Last edited by WebSnozz; 11-24-2001 at 11:15 PM.

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    If you do not want to process mouse msg's don't.
    Ignore them.

    Also use

    case WM_COMMAND://or what ever
    break;

    and the return at the end of the switch.
    "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

  7. #7
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102
    But I don't want it to search through a long switch case a hundred times everytime someone passes a mouse over my window.
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

  8. #8
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Um...that's what the window procedure is. Just one big switch case test.

    --Garfield
    1978 Silver Anniversary Corvette

  9. #9
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102
    But instead of having that long switch case in the first function, I can have the switch case for all the messages I want to handle in a secondary procedure, and in the main procedure check to see if it's just an annoying mouse movement , if it's not then I call the second procedure. That way I don't process the long switch case everytime the system calls my procedure because of a move message, and move messages happen many many times more than any other meaningful message. Look at the code I posted. I don't mean to sound like I'm the end all of it, I haven't been doing winapi for long, I just don't think you see what I'm getting at. If you create a console win32 project and make a window and in the callback procedure function put a cout<<Msg; you'll see everytime you move the mouse just a tiny bit the function gets called and it's just about always the same message, assuming it's the mouse move message, but I only see it as an integer when it's outputted of course.
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to track every copy event
    By manav in forum Windows Programming
    Replies: 3
    Last Post: 06-05-2008, 10:37 AM
  2. DialogBox won't close with the X
    By Marcos in forum Windows Programming
    Replies: 7
    Last Post: 10-27-2006, 10:44 AM
  3. Message Handling
    By sethjackson in forum Windows Programming
    Replies: 14
    Last Post: 07-11-2006, 01:01 PM
  4. What's wrong with my Win32 Wrapper code?
    By miica in forum Windows Programming
    Replies: 9
    Last Post: 02-22-2005, 07:55 PM
  5. Menu problems
    By Bajanine in forum Windows Programming
    Replies: 4
    Last Post: 11-04-2002, 09:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21