关于Win32窗口怎么获取鼠标在窗口中的位置?

kaoshi100ha 2017-07-11 08:45:52
大一新生假期实习。。
case WM_LBUTTONDOWN:
{
pt.x=LOWORD(lParam);
pt.y=HIWORD(lParam);
}


可是LOWORD下面一直有波浪线啊。。。说未定义标识符lParam。。。求救。。看了几个小时还是弄不出来
...全文
1168 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
schlafenhamster 2019-09-11
  • 打赏
  • 举报
回复

case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
// When we get a mouse down message, we know that the mouse
// is over the control. We then do the following steps
// to set up the new state:
// 1. Hit-test the coordinates of the click to
// determine in which half the click occurred.
// 2. Set the appropriate SPINNERSTATE_*CLICK state
// and repaint that clicked half. This is another
// example of a change-state-and-repaint strategy.
// 3. Send an initial scroll message.
// 4. Set the mouse capture.
// 5. Set the initial delay timer before repeating
// the scroll message.

// if (uRightBt) break;
uRightBt = message;
// Get the mouse coordinates.
x = (int) LOWORD(lParam);
y = (int) HIWORD(lParam);
// Only need to hit-test the upper half Then change-state-and-repaint
GetClientRect (hArrow, &rect);
cy = rect.bottom >> 1; // /2
//
if (y > cy)
{
StateSet(dwSpinnerState, SPINNERSTATE_DOWNCLICK);
rect.top = cy;
wScroll = SB_LINEDOWN;
}
else
{
StateSet(dwSpinnerState, SPINNERSTATE_UPCLICK);
rect.bottom = cy + 1;
wScroll = SB_LINEUP;
}
//
SetWindowLong (hArrow, GWL_SPINNERSTATE, (LONG) dwSpinnerState);

InvalidateRect (hArrow, &rect, TRUE);
UpdateWindow (hArrow);

SetCapture (hArrow);

// Process SHIFT key state along with button message

if (wParam & MK_SHIFT)
{
if (message != WM_RBUTTONDOWN)
wScroll += (WORD) (SB_TOP - SB_LINEUP);
else
wScroll += (WORD) (SB_THUMBPOSITION - SB_LINEUP);
}
else
{
if (message == WM_RBUTTONDOWN)
wScroll += SB_PAGEUP - SB_LINEUP;

bArrowTimed = SetTimer (hArrow, SB_tmID,//GetWindowLong (hArrow, GWL_ID),
200, (TIMERPROC) ArrowTimerProc);
}
// send WM_VSCROLL to parent ?
//nScrollCode = (int) LOWORD(wParam); // scroll bar value
//nPos = (short int) HIWORD(wParam); // scroll box position
//hwndScrollBar = (HWND) lParam; // handle to scroll bar
SendMessage (hArrow, WM_VSCROLL, MAKELONG(wScroll,GetWindowLong (hArrow, GWL_ID)),
(LONG) hArrow);
break;
tianxian_1019 2019-09-11
  • 打赏
  • 举报
回复
pt.x = LOWORD(lParam); pt.y = HIWORD(lParam);
Eleven 2017-07-19
  • 打赏
  • 举报
回复
WM_LBUTTONDOWN fwKeys = wParam; xPos = LOWORD(lParam); yPos = HIWORD(lParam); 你检查了一下你的窗口过程函数是怎么写的?
三岁、就很帅 2017-07-17
  • 打赏
  • 举报
回复
pt.x=LOWORD(lParam); pt.y=HIWORD(lParam); 你这2个xy是什么类型的就强制转换成什么类型的啊 pt.x=double(wParam); pt.y=double(lParam);
hurryboylqs 2017-07-17
  • 打赏
  • 举报
回复
大一就有实习机会,不错
qq_33352615 2017-07-17
  • 打赏
  • 举报
回复
先GetCursorPos,得到在屏幕中的坐标,然后再用ScreenToClient转换一下就好
赵4老师 2017-07-12
  • 打赏
  • 举报
回复
百度搜“WM_LBUTTONDOWN”
jena_wy 2017-07-12
  • 打赏
  • 举报
回复
这个是未定义,说明你的函数的参数不是这个变量,要根据你的函数传相应的变量
schlafenhamster 2017-07-12
  • 打赏
  • 举报
回复
case WM_LBUTTONDOWN: 应该在 LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 中
qq_35578084 2017-07-12
  • 打赏
  • 举报
回复
你的函数参数名不对啊。 肯定是...WndProc(...LPARAM lParam)...啊

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧