I have a quick question. I created a standard window with the window api from the MSDN creating a window site. What I want the program to do is change the title of the window the mouse cursor is at when i press a key on the keyboard. To do so i've installed a low level mouse hook like so:
LRESULT CALLBACK LowLevelMouseProc(__in int nCode, __in WPARAM wParam, __in LPARAM lParam) {
MSLLHOOKSTRUCT* p = (MSLLHOOKSTRUCT*)lParam;
HWND hiWnd = WindowFromPoint(p->pt); //Get a handle to the top-most window
ScreenToClient(hiWnd, &p->pt); //Converts the cursor position from screen to the specified window
char buf[33];
switch (wParam) {
case WM_MOUSEMOVE:
snprintf(buf, sizeof(buf) - 1, "X:%ld, Y:%ld", p->pt.x, p->pt.y); //Put the cursor coordinates into a char buffer
SendMessage(hiWnd, WM_SETTEXT, 0, (LPARAM)buf); //Send a message to the other window to change the title
break;
}
return CallNextHookEx(0, nCode, wParam, lParam);
}
Upon calling the mouse hook, Only my program changes text. Also, the text is a bunch of Chinese Characters, And not one or two, but a bunch like so:
藡覶 跾 瑍痸碚 齫儽戃 羭聧蔩, 圪妀 跾 鶀嚵巆 堔埧娾 爂犤繵 摿斠榱 軥軱逴 潫 徖梜, 薍薝
Do I have to mess around with the foreground window and instead get the background window? Or window where current mouse pos is at? I would assume that
ScreenToClient(hiWnd, &p->pt)
Thanks for the help guys!