先看看获得edit
int num = GetDlgItemInt(IDC_EDIT2);
好了正文开始;绘图
CStatic *pStatic;
pStatic=(CStatic*)GetDlgItem(IDC_STATIC);
CRect lRect;
pStatic-> GetClientRect(&lRect);
用StretchDIBits(HDC,...)?
pStatic-> GetDC()-> GetSafeHdc();
::StretchDIBits(pStatic->GetDC()-> GetSafeHdc(), 0, 0, w, h, cx, cy, width, height, bmpData, (LPBITMAPINFO) &bmpHeader, DIB_RGB_COLORS, SRCCOPY);
把GetDC()换成GetWindowDC();就可以防止出边界
别忘了OnPaint更行的!
CDialog::OnPaint();
CDialog::UpdateWindow(); //更新windows窗口,如果无这步调用,图片显示还会出现问题
Show_picture(); //重绘图片函数
怎么聚焦
GetDlgItem(IDC_EDIT1)->SetFocus();
怎么监听
BOOL CtestaDlg::PreTranslateMessage(MSG* pMsg) {
if(pMsg->message==WM_LBUTTONDOWN) {
CPoint pt;
GetCursorPos(&pt);
CRect rect;
GetDlgItem(IDC_STATIC)->GetWindowRect(&rect);
if(rect.PtInRect(pMsg->pt)) //--------DO---------//
}
if (pMsg->message==WM_KEYDOWN){
if(pMsg->wParam == VK_LEFT){
currentStPt.x-=2;
}
return CDialog::PreTranslateMessage(pMsg);
}
捕获窗口坐标
CRect rect;
GetWindowRect(&rect);
pt.x -= rect.left;
pt.y -= rect.top;