WINdows窗口的背景图片,有什么办法可以移动这个背景图片吗?

fengshangren 2019-01-25 11:35:21
我看到一个C++写的程序,他只有一个窗口,图片就放在窗口背景图片上,但是他滚动条可以移动这个图片坐标。请问是怎么做到的。不用移动组件的办法来移动图片。只移动图片
...全文
186 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
CT8100 2019-01-26
  • 打赏
  • 举报
回复

重绘
zgl7903 2019-01-25
  • 打赏
  • 举报
回复
CScrollView Class 或者窗口添加相应的滚动处理
fengshangren 2019-01-25
  • 打赏
  • 举报
回复
我看到一个源码他是这样写的,这是怎么搞的,能简单说一下吗
fengshangren 2019-01-25
  • 打赏
  • 举报
回复
[quote=引用 2 楼 schlafenhamster 的回复:] // 初始化窗口大小结构 m_hDC = ::GetDC(m_hWnd); m_hMemDC = CreateCompatibleDC(m_hDC); m_hFullBitmap = CreateDIBSection(m_hDC, m_lpbmi, DIB_RGB_COLORS, &m_lpScreenDIB, NULL, NULL); SelectObject(m_hMemDC, m_hFullBitmap); SetScrollRange(SB_HORZ, 0, m_lpbmi->bmiHeader.biWidth); SetScrollRange(SB_VERT, 0, m_lpbmi->bmiHeader.biHeight); InitMMI(); SendNext(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CScreenSpyDlg::ResetScreen() { UINT nBISize = m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1; if (m_lpbmi != NULL) { int nOldWidth = m_lpbmi->bmiHeader.biWidth; int nOldHeight = m_lpbmi->bmiHeader.biHeight; delete[] m_lpbmi; delete[] m_lpbmi_rect; m_lpbmi = (BITMAPINFO *) new BYTE[nBISize]; m_lpbmi_rect = (BITMAPINFO *) new BYTE[nBISize]; memcpy(m_lpbmi, m_pContext->m_DeCompressionBuffer.GetBuffer(1), nBISize); memcpy(m_lpbmi_rect, m_pContext->m_DeCompressionBuffer.GetBuffer(1), nBISize); DeleteObject(m_hFullBitmap); m_hFullBitmap = CreateDIBSection(m_hDC, m_lpbmi, DIB_RGB_COLORS, &m_lpScreenDIB, NULL, NULL); SelectObject(m_hMemDC, m_hFullBitmap); memset(&m_MMI, 0, sizeof(MINMAXINFO)); InitMMI(); // 分辨率发生改变 if (nOldWidth != m_lpbmi->bmiHeader.biWidth || nOldHeight != m_lpbmi->bmiHeader.biHeight) { RECT rectClient, rectWindow; GetWindowRect(&rectWindow); GetClientRect(&rectClient); ClientToScreen(&rectClient); // 计算ClientRect与WindowRect的差距(标题栏,滚动条) rectWindow.right = m_lpbmi->bmiHeader.biWidth + rectClient.left + (rectWindow.right - rectClient.right); rectWindow.bottom = m_lpbmi->bmiHeader.biHeight + rectClient.top + (rectWindow.bottom - rectClient.bottom); MoveWindow(&rectWindow); } }
schlafenhamster 2019-01-25
  • 打赏
  • 举报
回复
CRect wrc;
GetWindowRect(wrc);
ScreenToClient(&wrc);
MapWindowPoints(pDlg,wrc);
SetBrushOrgEx(dc.m_hDC,-wrc.left,-wrc.top,0);

15,978

社区成员

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

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