dlggetpos.cpp
来自「简单的远程控制工具,分为服务器与客户斋,让你了解socket编程的知识.」· C++ 代码 · 共 1,263 行 · 第 1/3 页
CPP
1,263 行
else
nHeight = rc.Height ();
StretchBlt (pDC->m_hDC, nLeft, nTop, nWidth, nHeight,
m_hMemDC,0,0,m_nBmpWidth,m_nBmpHeight,SRCCOPY);
*/
/* m_ptBmpDraw = CPoint (nLeft,nTop);
if (nLeft > rc.left)
pDC->FillSolidRect (rc.left,rc.top,nLeft,rc.bottom,GetSysColor (COLOR_BACKGROUND));
if (nTop > rc.top)
pDC->FillSolidRect (rc.left,rc.top,rc.right,nTop,GetSysColor (COLOR_BACKGROUND));
if (nWidth < rc.Width())
pDC->FillSolidRect (nLeft+nWidth,rc.top,rc.right,rc.bottom,GetSysColor (COLOR_BACKGROUND));
if (nHeight < rc.Height())
pDC->FillSolidRect (rc.left,nTop+nHeight,rc.right,rc.bottom,GetSysColor (COLOR_BACKGROUND));
pDC->FrameRect (rc,&CBrush(RGB(0,0,0)));
*/
}
void CDlgGetPos::Move_Image (int xMove, int yMove)
{
CRect rc;
CDC* pDC;
pDC = m_oStaArea.GetWindowDC ();
m_oStaArea.GetClientRect (&rc);
m_ptBmpDraw.x += xMove;
m_ptBmpDraw.y += yMove;
BitBlt (pDC->m_hDC,m_ptBmpDraw.x,m_ptBmpDraw.y,m_nBmpWidth,m_nBmpHeight,
m_hMemDC,0,0,SRCCOPY);
if (m_ptBmpDraw.x > rc.left)
pDC->FillSolidRect (rc.left,rc.top,m_ptBmpDraw.x,rc.bottom,GetSysColor (COLOR_BACKGROUND));
if (m_ptBmpDraw.y > rc.top)
pDC->FillSolidRect (rc.left,rc.top,rc.right,m_ptBmpDraw.y,GetSysColor (COLOR_BACKGROUND));
if (m_ptBmpDraw.x + m_nBmpWidth < rc.Width())
pDC->FillSolidRect (m_ptBmpDraw.x + m_nBmpWidth,rc.top,rc.right,rc.bottom,GetSysColor (COLOR_BACKGROUND));
if (m_ptBmpDraw.y + m_nBmpHeight < rc.Height())
pDC->FillSolidRect (rc.left,m_ptBmpDraw.y + m_nBmpHeight,rc.right,rc.bottom,GetSysColor (COLOR_BACKGROUND));
pDC->FrameRect (rc,&CBrush(RGB(0,0,0)));
}
void CDlgGetPos::Get_Screen_Data (LPVOID lpBmpData, PSENDMSG lpMsg)
{
BYTE *lpData = NULL, *lpData1 = NULL;
SENDMSG msg;
CRect rcOld;
rcOld.top = lpMsg->rcArea.top;
rcOld.bottom = lpMsg->rcArea.bottom;
rcOld.left = lpMsg->rcArea.left;
rcOld.right = lpMsg->rcArea.right;
if (rcOld.left < 0 || rcOld.top < 0 )
int i = 0;
if (lpBmpData == NULL)//无图
{
if (m_bFullScreen == FALSE)//只显示
{
m_sNote.Format("%d-%d %d-%d %dBits Size:%dto%dKb Frame:%d Err:%d",
rcOld.left, rcOld.top,
rcOld.right, rcOld.bottom,
lpMsg->nBits, lpMsg->dwFileSize/1024,
lpMsg->dwBmpSize/1024,
++m_lFrame,
m_lError);
SetDlgItemText(IDC_NOTE, m_sNote);
}
return;
}
if (lpMsg->nCompress == 0) //Nothing
{
lpData = m_Jpeg.LoadBMP((LPSTR)lpBmpData,
(unsigned long *)&m_nBmpWidth,
(unsigned long *)&m_nBmpHeight);
if(lpData==NULL) return;
}
else if(lpMsg->nCompress == 1) //Huffman
{
//lpData1 = new BYTE[lpMsg->dwFileSize];
lpData1 = (BYTE *)GlobalAlloc (GMEM_FIXED, lpMsg->dwFileSize);
if (lpData1==NULL)return;
memset(lpData1, 0, lpMsg->dwFileSize);
m_huf.ntDecode((char *)lpData1, (char *)lpBmpData);
lpData = m_Jpeg.LoadBMP((LPSTR)lpData1,
(unsigned long *)&m_nBmpWidth,
(unsigned long *)&m_nBmpHeight);
//delete lpData1;
GlobalFree (lpData1);
if (lpData == NULL) return ;
}
else if(lpMsg->nCompress == 2) //Jpeg
{
lpData = m_Jpeg.JpegFileToRGB((BYTE *)lpBmpData,
lpMsg->dwBmpSize,
(UINT *)&m_nBmpWidth,
(UINT *)&m_nBmpHeight);
if (lpData == NULL) return ;
}
else if(lpMsg->nCompress == 3) //动态Jpeg
{
if (lpMsg->nCell) m_Jpeg.DeletePreData();
if(!lpMsg->iErrorCode)
{
lpData = m_Jpeg.JpegFileToRGB((BYTE *)lpBmpData+lpMsg->dwBmpInfoSize,
lpMsg->dwBmpSize,
(UINT *)&m_nBmpWidth,
(UINT *)&m_nBmpHeight);
}
else
{
lpData = (BYTE *)lpBmpData+lpMsg->dwBmpInfoSize;
m_nBmpWidth = 16;
m_nBmpHeight = lpMsg->iErrorCode;
}
if (lpData == NULL) return ;
lpData = m_Jpeg.FixtoBMP(lpData, m_nBmpWidth,
m_nBmpHeight,(BYTE *)lpBmpData,
lpMsg->dwBmpInfoSize,
lpMsg->rcArea.Width(),
lpMsg->rcArea.Height());
m_nBmpWidth = lpMsg->rcArea.Width();
m_nBmpHeight = lpMsg->rcArea.Height();
if (lpData == NULL) return ;
}
if (lpMsg->nCompress != 3)
{
m_Jpeg.BGRFromRGB(lpData, m_nBmpWidth, m_nBmpHeight);
m_Jpeg.VertFlipBuf(lpData, m_nBmpWidth * 3, m_nBmpHeight);
}
if (lpMsg->nArea > 0) //当前窗口
{
lpData1 = lpData;
lpData = m_Jpeg.MovetoBuf((BYTE *)lpData1, &lpMsg->rcArea,
m_pDoc->m_SrvrArea.Width(),
m_pDoc->m_SrvrArea.Height());
delete lpData1;
lpMsg->rcArea = m_pDoc->m_SrvrArea;
m_nBmpWidth = m_pDoc->m_SrvrArea.Width();
m_nBmpHeight = m_pDoc->m_SrvrArea.Height();
}
m_nBmpTop= lpMsg->rcArea.top;
m_nBmpLeft = lpMsg->rcArea.left;
UINT m_widthDW;
m_lpImageData = m_Jpeg.MakeDwordAlignedBuf((BYTE *)lpData,
m_nBmpWidth,
m_nBmpHeight,
&m_widthDW);
// m_lpImageData = lpData;
if (IsDlgButtonChecked (IDC_GRAY) ||
IsDlgButtonChecked (IDC_TURN))
{
m_Jpeg.MakeGrayScale(m_lpImageData, m_nBmpWidth,
m_nBmpHeight,IsDlgButtonChecked (IDC_TURN));
}
if (m_bFullScreen == TRUE && m_pDlgFullScreen != NULL)
{
m_pDlgFullScreen->m_hMemDC = m_hMemDC;
m_pDlgFullScreen->Set_BackGroud_Image();
}
else
{
Set_BackGroud_Image ();
m_sNote.Format("%d-%d %d-%d %dBits Size:%dto%dKb Frame:%d Err:%d",
rcOld.left, rcOld.top,
rcOld.right, rcOld.bottom,
lpMsg->nBits, lpMsg->dwFileSize/1024,
lpMsg->dwBmpSize/1024,
++m_lFrame,
m_lError);
SetDlgItemText(IDC_NOTE, m_sNote);
}
}
//DEL void CDlgGetPos::OnButtonClean()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL HBRUSH hOldBrush;
//DEL HBRUSH hBrush = CreateSolidBrush (GetSysColor (COLOR_BACKGROUND));
//DEL hOldBrush = (HBRUSH )SelectObject (m_hMemDC,hBrush);
//DEL PatBlt (m_hMemDC,0,0,m_nRmtWidth,m_nRmtHeight,PATCOPY);
//DEL Set_BackGroud_Image ();
//DEL
//DEL DeleteObject(hBrush);
//DEL DeleteObject(hOldBrush);
//DEL }
void CDlgGetPos::OnButtonFullscreen()
{
// TODO: Add your control notification handler code here
/* if (m_pFullWnd == NULL)
{
m_pFullWnd = new CSplashWnd;
m_pFullWnd->m_hMemDC = m_hMemDC;
m_pFullWnd->Create (this);
}
*/
if (m_bFullScreen == FALSE && m_pDlgFullScreen == NULL)
{
m_pDlgFullScreen = new CDlgFullScreen (this);
m_pDlgFullScreen->m_hMemDC = m_hMemDC;
m_bFullScreen = m_pDlgFullScreen->Create (m_pDoc);
// m_bFullScreen = m_bFullScreen;
}
}
//打开抓图线程
void CDlgGetPos::OnCheckContinue()
{
// TODO: Add your control notification handler code here
UpdateData (TRUE);
BOOL bStatus;
m_lError = 0;
m_pDoc->m_rcArea =CRect(m_nLeft,m_nTop,m_nWidth,m_nHeight);
if (m_bChkContinue)
{
m_pDoc->m_nCellSize = 1;
CmdProc_SysLogImage();
bStatus = FALSE;
}
else
{
int old = m_pDoc->m_nEdtSecond;
m_pDoc->m_nEdtSecond = 2000;
CmdProc_SysEndLogImage();
m_pDoc->m_nEdtSecond = old;
bStatus = TRUE;
}
((CButton *)GetDlgItem(IDC_EDIT_TOP))->EnableWindow(bStatus);
((CButton *)GetDlgItem(IDC_EDIT_LEFT))->EnableWindow(bStatus);
((CButton *)GetDlgItem(IDC_EDIT_WIDTH))->EnableWindow(bStatus);
((CButton *)GetDlgItem(IDC_EDIT_HEIGHT))->EnableWindow(bStatus);
((CButton *)GetDlgItem(IDC_TURN))->EnableWindow(bStatus);
((CButton *)GetDlgItem(IDC_GRAY))->EnableWindow(bStatus);
((CButton *)GetDlgItem(IDC_COMBO_AREA)->EnableWindow(bStatus));
((CButton *)GetDlgItem(IDC_EDIT_SECOND)->EnableWindow(bStatus));
((CButton *)GetDlgItem(IDC_COMBO_COLORS)->EnableWindow(bStatus));
((CButton *)GetDlgItem(IDC_COMBO_COMPRESS)->EnableWindow(bStatus));
((CButton *)GetDlgItem(IDC_QUALITY)->EnableWindow(bStatus));
}
//DEL void CDlgGetPos::OnTimer(UINT nIDEvent)
//DEL {
//DEL // TODO: Add your message handler code here and/or call default
//DEL if (nIDEvent == 1)
//DEL OnButtonGetscreen (); // m_pDoc->SendMsg(CMD_GET_SCREEN);
//DEL CDialog::OnTimer(nIDEvent);
//DEL }
void CDlgGetPos::OnRadioCut()
{
// TODO: Add your control notification handler code here
Set_BackGroud_Image ();
}
void CDlgGetPos::OnRadioImage()
{
// TODO: Add your control notification handler code here
Move_Image (0,0);
}
BOOL CDlgGetPos::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (!IsDlgButtonChecked (IDC_CHECK_CONTROL))
return CDialog::PreTranslateMessage(pMsg);
// CDlgGetPos *pWnd = (CDlgGetPos *)m_pParent;
// TODO: Add your specialized code here and/or call the base class
// if(pMsg->message == WM_KEYDOWN)
if(m_bFullScreen == FALSE&&pMsg->message == WM_SENDKEY_DOWN)
{
BYTE vKey,nScan;
vKey = (BYTE) pMsg->wParam;
nScan = (BYTE) (pMsg->lParam & 0x00ff0000)>>16;
m_pDoc->m_dwHookFlags = 0;
m_pDoc->m_dwHookParam1 = vKey;
m_pDoc->m_dwHookParam2 = nScan;
SendMsg (CMD_KEY_HOOK);
return true;
}
// if(pMsg->message == WM_KEYUP)
if(m_bFullScreen == FALSE&&pMsg->message == WM_SENDKEY_UP)
{
BYTE vKey,nScan;
vKey = (BYTE) pMsg->wParam;
nScan = (BYTE) (pMsg->lParam & 0x00ff0000)>>16;
m_pDoc->m_dwHookFlags = KEYEVENTF_KEYUP;
m_pDoc->m_dwHookParam1 = vKey;
m_pDoc->m_dwHookParam2 = nScan;
SendMsg (CMD_KEY_HOOK);
return true;
}
if((pMsg->message == WM_KEYDOWN ||
pMsg->message == WM_SYSKEYDOWN ||
pMsg->message == WM_KEYUP ||
pMsg->message == WM_SYSKEYUP) &&
m_bChkControl == TRUE)
return true;
//////////////////////
/* Move to CDlgFullScreen
if (m_pDoc->m_bIsHook)
{
m_pDoc->m_bIsHook = FALSE;
return TRUE;
//return CDialog::PreTranslateMessage(pMsg);
}
if(pMsg->message == WM_KEYDOWN)
{
BYTE vKey,nScan;
vKey = (BYTE) pMsg->wParam;
nScan = (BYTE) (pMsg->lParam & 0x00ff0000)>>16;
m_pDoc->m_dwHookFlags = 0;
m_pDoc->m_dwHookParam1 = vKey;
m_pDoc->m_dwHookParam2 = nScan;
m_pDoc->SendMsg (CMD_KEY_HOOK);
}
if(pMsg->message == WM_KEYUP)
{
BYTE vKey,nScan;
vKey = (BYTE) pMsg->wParam;
nScan = (BYTE) (pMsg->lParam & 0x00ff0000)>>16;
m_pDoc->m_dwHookFlags = KEYEVENTF_KEYUP;
m_pDoc->m_dwHookParam1 = vKey;
m_pDoc->m_dwHookParam2 = nScan;
m_pDoc->SendMsg (CMD_KEY_HOOK);
}
if(pMsg->message == WM_MOUSEMOVE ||
pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONUP ||
pMsg->message == WM_RBUTTONDOWN || pMsg->message == WM_RBUTTONUP)
{
CPoint pt;
switch (pMsg->message)
{
case WM_MOUSEMOVE:
m_pDoc->m_dwHookFlags = MOUSEEVENTF_MOVE;
break;
case WM_LBUTTONDOWN:
m_pDoc->m_dwHookFlags = MOUSEEVENTF_LEFTDOWN;
break;
case WM_LBUTTONUP:
m_pDoc->m_dwHookFlags = MOUSEEVENTF_LEFTUP;
break;
case WM_RBUTTONDOWN:
m_pDoc->m_dwHookFlags = MOUSEEVENTF_RIGHTDOWN;
break;
case WM_RBUTTONUP:
m_pDoc->m_dwHookFlags = MOUSEEVENTF_RIGHTUP;
break;
default:
break;
}
pt = CPoint (GET_X_LPARAM (pMsg->lParam),GET_Y_LPARAM (pMsg->lParam));
m_oStaArea.ClientToScreen (&pt);
m_pDoc->m_dwHookFlags |= MOUSEEVENTF_ABSOLUTE;
m_pDoc->m_dwHookParam1 = pt.x;
m_pDoc->m_dwHookParam2 = pt.y;
m_pDoc->SendMsg (CMD_MOUSE_HOOK);
}
*/
return CDialog::PreTranslateMessage(pMsg);
}
/*
void CDlgGetPos::OnKillfocusDelaysend()
{
// TODO: Add your control notification handler code here
////////// Setup send message after delay time
m_pDoc->m_lDelaySend = m_lDelaySend;
}
*/
BOOL CDlgGetPos::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
m_pDoc->m_bDlgScreen = FALSE;
// m_pDoc->m_dlgGetScreen = NULL;
/*
int old = m_pDoc->m_nEdtSecond;
m_pDoc->m_nEdtSecond = 2000;
CmdProc_SysEndLogImage();
m_pDoc->m_nEdtSecond = old;
*/
CmdProc_EndHook();
CmdProc_SysEndLogImage();
return CDialog::DestroyWindow();
}
void CDlgGetPos::OnChangeEditSecond()
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?