Thread: Float number and sendmessage

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    43

    Float number and sendmessage

    I have been trying out some things with the SendMessage function which is supposed to send keystrokes to a certain window.

    Code:
    SendMessage(hwndMineSweeper, WM_LBUTTONDOWN, MK_LBUTTON, (YPos<<16)+XPos); 
    SendMessage(hwndMineSweeper, WM_LBUTTONUP, MK_LBUTTON, (YPos<<16)+XPos);
    I have a float number which always has 3 digits before the decimal point and 2 after: XXX.XX

    Is there a way I can send the whole float number without having to create a seperate Sendmessage command for each digit?

    If not, could the number first be converted to a string and then sent as a string to the sendmessage function?

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well first off you do realize for a WM_LBUTTONDOWN (or any other mouse message) you can't send a float no matter what you do. Windows actually has to interpret the data you send. If you are asking because you are wanting to do a custom SendMessage() where you are need two floating point values I would suggest a structure.

    Example:
    Code:
    struct myPoints {
      float x, y;
    };
    
    /* To use this with SendMessage(), use pointers */
    int main(void) {
      struct myPoints *points = malloc(sizeof(*points));
    
      SendMessage(hwndMineSweeper, MY_CUSTOM_WINDOWS_MESSAGE, MY_FLAG, (int)points);
    
      return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. line number on a rich edit control
    By rakan in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2008, 07:58 AM
  2. Combobox problem
    By gargamel in forum Windows Programming
    Replies: 2
    Last Post: 05-06-2005, 01:37 PM