- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我创建了一个显示位图图像的自定义静态窗口,该窗口是其他窗口的子窗口。现在我想捕获此窗口的鼠标事件,以便我可以提供裁剪图像的功能。
但问题是鼠标事件没有传递给这个子窗口....以下是子窗口的WndProc
代码片段..
WNDPROC origStatProc;
// Variable which stores the handle of BITMAP image
HBITMAP hBitmap=NULL;
LRESULT CALLBACK dispWndProc(HWND hwnd,UINT msg, WPARAM wParam, LPARAM lParam)
{
static HDC hdc;
static PAINTSTRUCT paintSt;
static RECT aRect;
switch(msg)
{
case WM_PAINT:
{
hdc = BeginPaint(hwnd,&paintSt);
GetClientRect(hwnd,&aRect);
if(hBitmap!=NULL)
{
HDC memDC = CreateCompatibleDC(hdc);
if(memDC!=NULL)
{
BITMAP bmp;
GetObject(hBitmap,sizeof(bmp),&bmp);
SelectObject(memDC,hBitmap);
SetStretchBltMode(hdc,HALFTONE);
StretchBlt(hdc,0,0,aRect.right,aRect.bottom,
memDC,0,0,bmp.bmWidth,bmp.bmHeight,
SRCCOPY);
DeleteObject(&bmp);
ReleaseDC(hwnd,memDC);
}
}
// the code for painting
EndPaint(hwnd,&paintSt);
}
break;
case STM_SETIMAGE:
{
InvalidateRect(hwnd,&aRect,true);
}
break;
case WM_LBUTTONDOWN:
{
int xPos = GET_X_LPARAM(lParam);
int yPos = GET_Y_LPARAM(lParam);
char xstr[10];
_itoa(xPos,xstr,10);
MessageBox(NULL,xstr,"X Value ",MB_OK);
}
break;
default:
return origStatProc(hwnd,msg,wParam,lParam);
}
return 0;
}
任何人都可以告诉我我还需要什么来捕获此子窗口内的鼠标事件...
最佳答案
您为窗口使用的窗口类将确定窗口的某些默认行为。静态窗口类特别难用,因为 Windows 假定窗口永远不会更改其内容,并且不会以任何方式与用户交互。您可能会发现 WM_LBUTTONDOWN 被传递到父窗口。
关于c++ - 为什么我的子窗口对鼠标事件没有反应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5883414/
我正在尝试将高斯模糊添加到场景中。我正在使用此GLSL着色器:。当您提供图像作为tDiffuse纹理时,它对图像起作用,但我正在尝试将其添加为后处理效果。我试图获取摄影机的renderTarget并将
我正在做一款天气应用程序,到目前为止还不错。现在,我想通过单击按钮来呈现一些额外的信息。我有一个5天的预报,然后想显示每一天的信息。我已经成功地过滤了数据,但无法获得要渲染的数据地图。以下是我的一些代
我正在做一款天气应用程序,到目前为止还不错。现在,我想通过单击按钮来呈现一些额外的信息。我有一个5天的预报,然后想显示每一天的信息。我已经成功地过滤了数据,但无法获得要渲染的数据地图。以下是我的一些代
我在全球安装了Create Reaction应用程序。然后我就跑了。NPX创建-反应-应用JSX。它安装了大约1460个包的所有包,但没有设置Public和src文件夹。在我的JSX文件夹中,只有1:
我是一名优秀的程序员,十分优秀!