MFC随着对话框全屏控件,图片移动相应的位置

一只正在啃的蜗牛 2018-09-26 10:18:49
MFC随着对话框全屏控件,图片移动相应的位置,
RectToRect(mDlgRect,recNow,mRectArray[0],false);
RectToRect(mDlgRect,recNow,mRectArray[1],false);
RectToRect(mDlgRect,recNow,mRectArray[2],false);
SetnIDRect(IDC_STATIC_COMM_PORT,mRectArray[0]);
SetnIDRect(IDC_EDIT_COMM_PORT,mRectArray[1]);
SetnIDRect(IDC_STATIC_SLAVE_ADDRESS,mRectArray[2]
这样已经在对话框已经有位置的在全屏时怎么编辑
...全文
318 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
RectToRect(const CRect& recSrc, const CRect& recDest, CRect& recRes, bool bReSize)
可以设置控件的大小?还是用什么设置大小的
schlafenhamster 2018-10-10
  • 打赏
  • 举报
回复
?这个执行代表哪个?"

CWnd::GetDlgCtrlID
int GetDlgCtrlID( ) const;

Return Value

The numeric identifier of the CWnd child window if the function is successful; otherwise 0.

该函数 可以 区分 那个 按钮
  • 打赏
  • 举报
回复

因为我有多个按键位图,这个执行代表哪个,,又在哪个地方改换成另外的,
  • 打赏
  • 举报
回复
不好意思,发帖的新手,请问下如何给回复帖子的人分数?
zgl7903 2018-09-27
  • 打赏
  • 举报
回复

void CMyButton::OnPaint()
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
// Do not call CButton::OnPaint() for painting messages


CDC *pDC = &dc;

//保存设备现场
int nSaveDC = pDC->SaveDC();

//获取客户区位置&大小
CRect rcRect;
GetClientRect(&rcRect);

//获取位图
HBITMAP hBmp = GetBitmap();
BITMAP bmpInfo = {0};
if(hBmp && GetObject(hBmp, sizeof(bmpInfo), &bmpInfo))
{
//创建兼容DC
CDC memDC;
memDC.CreateCompatibleDC(pDC);
//选人位图
HGDIOBJ hOldBmp = memDC.SelectObject(hBmp);

//设置缩放模式
pDC->SetStretchBltMode(HALFTONE);
//缩放贴图
pDC->StretchBlt(rcRect.left, rcRect.top, rcRect.Width(), rcRect.Height(),
&memDC,
0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight,
SRCCOPY);

//恢复内存DC位图
memDC.SelectObject(hOldBmp);
}

//恢复现场
pDC->RestoreDC(nSaveDC);
}

  • 打赏
  • 举报
回复
自己处理 WM_PAINT 用 StretchBlt 贴图,,,有例子?
schlafenhamster 2018-09-27
  • 打赏
  • 举报
回复

void CCenterDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
if((SC_RESTORE==nID)||(SC_MAXIMIZE==nID))
{
LockWindowUpdate();
}
CDialog::OnSysCommand(nID, lParam);
}
}
schlafenhamster 2018-09-27
  • 打赏
  • 举报
回复
参考

//#define USE_DEFER
void CCenterDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CRect rcTmp;
// LockWindowUpdate(); has to be in OnSysCommand();
int iControlCount = 1;
#ifdef USE_DEFER
HDWP hdwp = BeginDeferWindowPos(11);
#endif
#define Border 5
int iCaptionHeight = GetSystemMetrics(SM_CYCAPTION);
if(!IsWindow(m_btMax.m_hWnd)) return;
if (nType == SIZE_RESTORED)// =0
{
m_btMax.SetWindowText("Maximize");
iCaptionHeight +=Border;// not 3; 28+5=33
CWnd* pWnd = GetTopWindow();
while(pWnd != NULL)
{
rcTmp=rcOrig[iControlCount];
rcTmp.top -= (rcOrig[0].top+iCaptionHeight);
rcTmp.bottom-= (rcOrig[0].top+iCaptionHeight);
rcTmp.left -= (rcOrig[0].left+Border);
rcTmp.right -= (rcOrig[0].left+Border);
#ifdef USE_DEFER
DeferWindowPos(hdwp, pWnd->m_hWnd, NULL,
rcTmp.left, rcTmp.top,rcTmp.Width(),rcTmp.Height(),
SWP_NOZORDER);
#else
pWnd->MoveWindow(&rcTmp,FALSE);
#endif
pWnd = pWnd->GetNextWindow();
iControlCount++;
}
}
//
if (nType == SIZE_MAXIMIZED)// =2
{
m_btMax.SetWindowText("Restore");
CWnd* pWnd = GetTopWindow();
while(pWnd != NULL)
{
rcTmp=rcOrig[iControlCount];
rcTmp.top -= iCaptionHeight;
rcTmp.bottom -= iCaptionHeight;
#ifdef USE_DEFER
DeferWindowPos(hdwp, pWnd->m_hWnd, NULL,
rcTmp.left, rcTmp.top,rcTmp.Width(),rcTmp.Height(),
SWP_NOZORDER);
#else
pWnd->MoveWindow(&rcTmp,FALSE);
#endif
pWnd = pWnd->GetNextWindow();
iControlCount++;
}
}
// redraw all the windows
#ifdef USE_DEFER
EndDeferWindowPos(hdwp);
#endif
// try it ? there are 2 pictures !
// 1st is a picture in which no ctrols moves.
// 2nd is a picture in which all ctrols moved.
// that's why the window be flickering.
// However with LockWindowUpdate(), you will not see 2 pictures !
// Sleep(1500);// to see the 2 pictures.
UnlockWindowUpdate();
}
  • 打赏
  • 举报
回复
这是只改变一个?
qq_26868981 2018-09-26
  • 打赏
  • 举报
回复
没明白你的问题
赵4老师 2018-09-26
  • 打赏
  • 举报
回复
建议直接上WPF
zgl7903 2018-09-26
  • 打赏
  • 举报
回复
重载CButton类, 自己处理 WM_PAINT 用 StretchBlt 贴图
  • 打赏
  • 举报
回复
按钮全屏,按钮里面的位图大小不变,要怎么样才能相应改变
  • 打赏
  • 举报
回复
按键里面的位图要全屏的话怎么编写

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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