How to set the popup window to the mouse position ?

I found an example with the popup and works, but the popup window follows the desktop coordinates. How to set the right coordinates of the mouse pointer ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
case WM_MOUSEMOVE:
{
   if(!g_fMouseTracking && !wPop)
   {
	// start tracking if we aren't already
	TRACKMOUSEEVENT tme = {};
	tme.cbSize = sizeof(TRACKMOUSEEVENT);
	tme.dwFlags = TME_HOVER | TME_LEAVE;
	tme.hwndTrack = hwnd;
	tme.dwHoverTime = HOVER_DEFAULT;

	g_fMouseTracking = TrackMouseEvent(&tme);
   }
}break;

case WM_MOUSEHOVER:
{
   g_fMouseTracking = FALSE; // tracking now canceled

   if(!wPop)
   {
	// Test popup
	wPop = CreateWindowA(WC_STATIC, TEXT("Information"), WS_POPUP | SS_CENTER, 0, 0, 80, 20, 
						hwnd, NULL, hInst, NULL);

	ShowWindow(wPop, SW_SHOW);

	// set up leave tracking
	TRACKMOUSEEVENT tme = {};

	tme.cbSize = sizeof(TRACKMOUSEEVENT);
	tme.dwFlags = TME_LEAVE;
	tme.hwndTrack = hwnd;

	g_fMouseTracking = TrackMouseEvent(&tme);
   }
   return 0;
}break;

case WM_MOUSELEAVE:
{
   g_fMouseTracking = FALSE; // tracking now canceled

   if(wPop)
   {
	// close wPop if it's open
	ShowWindow(wPop, SW_HIDE);
	DestroyWindow(wPop);
	wPop = NULL;
   }
   return 0;
}break;
Last edited on
And another problem is that, whatever static control I hover with the mouse pointer, popup the same control message. How can I specify the window that mouse pointer is on ?
Topic archived. No new replies allowed.