如何在mfc中使用图片控件移动窗口 [英] How do I move window using picture control in mfc

查看:312
本文介绍了如何在mfc中使用图片控件移动窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MFC应用程序中

我创建了一个没有边框的对话框,我在一个位图图像的对话框上放了一个Picture控件



所以我想用那个图片框作为标题栏



这意味着鼠标按钮在图片上向下移动或拖动鼠标时窗口也被移动< br $> b $ b

我该怎么办?



我的尝试:



In MFC application
I Created a Dialog with no Border and I put one Picture control on the dialog with one bitmap image

so I wanted to use that picture box as title bar

it means when mouse button is down on the picture and mouse is moved or dragged The window is also be moved

What should I do?

What I have tried:

LRESULT CMoveWinUsingPicDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	if( message == (WM_RBUTTONDOWN) )
	{
		//I think Here I can do something or suggest any other best place or solution
	}
}

推荐答案

您已经在如何使用图片控件移动没有边框的窗口 - C / C ++ / MFC讨论板 [ ^ ],请不要在多个论坛中重新发布。
You already posted this question at How to move window with no border using picture control - C / C++ / MFC Discussion Boards[^], please do not repost in multiple forums.


BOOL CMoveWinUsingPicDlg::PreTranslateMessage(MSG *pMsg)
{
	static bool mouse_down = false;
	static CRect MainRect;
	static CPoint point;
	
	switch(pMsg->message)
	{
	case WM_LBUTTONDOWN:
		GetWindowRect(&MainRect);
		point = pMsg->pt;
		ScreenToClient(&point);
		mouse_down = true;
		break;
	case WM_LBUTTONUP:
		mouse_down = false;
		break;
	case WM_MOUSEMOVE:
		CRect r;
		m_myPic.GetWindowRect(&r);
		if(mouse_down && r.PtInRect(pMsg->pt))
		{
			MoveWindow(pMsg->pt.x - point.x,pMsg->pt.y - point.y,
				MainRect.Width(),MainRect.Height());
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}


这篇关于如何在mfc中使用图片控件移动窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆