本文介绍了使用ShowWindow(SW_SHOWMAXIMIZED)l时,如何调整主窗口内的工具以填充对话框的大小?以及如何移动窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在编写OnClick函数的主窗口中使用了命令按钮
作为ShowWindow(SW_SHOWMAXIMIZED);被使用.
问题是只有窗口的边缘会增加,但是我希望窗口内的工具也能更改大小以填充最大化的窗口.

I have used a commandbutton in a main window where OnClick function is written
as ShowWindow(SW_SHOWMAXIMIZED); is used.
The problem is that only the edges of the window increases but i want the tools inside the window also change size to fill the maximized window.

void CDemoDlg::ClickMaximize()
{
ShowWindow(SW_SHOWMAXIMIZED);
}

推荐答案


void CDemoDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default

	 CRect myRect;
	 GetWindowRect(&myRect);
              //save current cursor coordinate
		GetCursorPos(&point);
		//ScreenToClient(&point);
		SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, 0);
	__super::OnLButtonDown(nFlags, point);
}

void CDemoDlg::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default

	CRect myRect;
	 GetWindowRect( &myRect);
	 CPoint curpoint;
	 GetCursorPos(&curpoint);
     {     
           MoveWindow(curpoint.x - point.x, curpoint.y - point.y, 
			myRect.right - myRect.left, myRect.bottom - myRect.top, TRUE);
     }
	
	 __super::OnMouseMove(nFlags, point);
}


这解决了我移动窗口的问题


This solved my problem of moving window


这篇关于使用ShowWindow(SW_SHOWMAXIMIZED)l时,如何调整主窗口内的工具以填充对话框的大小?以及如何移动窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 17:40