Windows programming PostMessage

Hi, I am trying to write a windows program where i have an interface that lists options of simulated left, right and double click. i have created a new thread within the program to determine if there is static movement of cursor, if so then sends a message back to my main program and tell it to simulate whatever type of click.

The problem now is i dont really understand how to use postmessage. how do i get my main program's hwnd and put it in PostMessage ( HWND, msg, wParam, lParam)

thanks

please feel free to ask me to explain further if u dont understand this, i know i am rubbish at explaining.
Last edited on
the parameters you pass to PostMessage are the exact same parameters that get passed to the window's message handler.

(EDIT: on second thought, the message pump might translate the coords a bit. Experiment with X,Y coords and see)

So if you want to send a left click event, you'd want to post a WM_LBUTTONDOWN message.

See WM_LBUTTONDOWN reference here: http://msdn.microsoft.com/en-us/library/ms645607(VS.85).aspx


Just fill in the parameters appropriately:

1
2
3
4
5
6
PostMessage(
  window_you_want_to_post_message_to,
  WM_LBUTTONDOWN,
  MK_LBUTTON,
  (y_coord << 16) | x_coord
    );
Last edited on
ok, so what i have done now to my program is created a gobal variable HWND ehwnd this is used when creating the main window and passed into my new thread. ie my_new_thread (ehwnd);[.code] within the thread i then use [code]PostMessage (ehwnd, xxx, yyy, zzz);

Anything wrong with doing that?
yeah, actually i wanna make a program in windows app but i'm still newbie. can anyone help me? my compiler is vs 2008 express ed. i tried with the sourceforge (i forgot the web name) but it doesn't work. can anyone help me find a proper tutorial?
Buy programming windows fifth edition by charles petzold, thats how i learnt win32 api in 2 days doing simple programs.
Topic archived. No new replies allowed.