Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
	}
}
Posted
Updated 14-Mar-17 21:28pm

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.
 
Share this answer
 
Comments
Premnath Mali 10-Mar-17 5:23am    
Sorry About that !
But I didn't get solution yet
Richard MacCutchan 10-Mar-17 5:27am    
I suggested one in your other question. Please delete this and stick to one forum.
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);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900