Home > Software engineering >  Without borders window moving and scaling, moving after scaling inevitable failure
Without borders window moving and scaling, moving after scaling inevitable failure

Time:09-22

1, change the window style SetWindowLong (myWindowHandle GWL_STYLE, WS_POPUP);
2, in the client area to create a title bar, the title bar of the background ondrag event execute the following code inside Windows mobile
 
ReleaseCapture ();
SendMessage (myWindowHandle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
SendMessage (myWindowHandle WM_LBUTTONUP, 0, 0);

3, he had to write a DLL, intercept WndProc method with SubWndProc method, WM_NCHITTEST event execute the code inside the
 
If (pt. X & gt;=rcClient. Right - 10 & amp; & Pt. Y & gt;=rcClient. Bottom - 10)
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_SIZENWSE)));
Return HTBOTTOMRIGHT;
}
Else if (pt. X & lt;=rcClient. Left + 10 & amp; & Pt. Y & gt;=rcClient. Bottom - 10)
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_SIZENESW)));
Return HTBOTTOMLEFT;
}
Else if (pt. X & lt;=rcClient. Left + 10 & amp; & Pt. Y & lt;=rcClient. Top + 10)
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_SIZENWSE)));
Return HTTOPLEFT;
}
Else if (pt. X & gt;=rcClient. Right - 10 & amp; & Pt. Y & lt;=rcClient. Top + 10)
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_SIZENESW)));
Return HTTOPRIGHT;
}
Else if (pt. X & gt;=rcClient. Right - 5)
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_SIZEWE)));
Return HTRIGHT;
}
Else if (pt. X & lt;=rcClient. Left + 5)
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_SIZEWE)));
Return HTLEFT;
}
Else if (pt. Y & lt;=rcClient. Top + 5)
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_SIZENS)));
Return HTTOP;
}
Else if (pt. Y & gt;=rcClient. Bottom - 5)
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_SIZENS)));
Return HTBOTTOM;
}
The else
{
SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_ARROW)));
Return HTCLIENT;
}


Problem is now, just click on the first homemade title bar to move the window
1, zoom doesn't work, when scaling the mouse become scaling style style, however, after the mouse drag, the window in the mobile, rather than scaling,
2, minimize the later, the mouse to click the task bar of the window, the window stick with the mouse on the mouse to move, must click left key, don't follow the mouse,
3, the SendMessage (myWindowHandle, WM_NCLBUTTONDOWN, HTCAPTION, 0); This line error: An abnormal situation has occurred: the PlayerLoop internal function has had called recursively. Both Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it.

CodePudding user response:

ReleaseCapture ();
SendMessage (myWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
SendMessage (myWindowHandle WM_LBUTTONUP, 0, 0);
I perform a maximum, and then went to the zoom window wouldn't
And I found the SendMessage (myWindowHandle, WM_NCLBUTTONDOWN, HTCAPTION, 0); This sentence in dragging homemade title bar to complete release the left mouse button will be An error: An abnormal situation has occurred: the PlayerLoop internal function has had called recursively. Both Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it.,
To SendMessage (myWindowHandle WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0). Wouldn't be an error, but after the drag to zoom window or unable to zoom into a moving window, release the left mouse button when the line will put the error,
My question is why I move after a custom title bar, the zoom window will trigger homemade title bar ondrag event, I thought it was the mouse didn't reset, so ondrag event after I add a ondragend, execution inside
ReleaseCapture ();
SendMessage (myWindowHandle WM_LBUTTONUP, 0, 0);
SendMessage (myWindowHandle WM_NCLBUTTONUP, 0, 0);
Still wrong
Run
ReleaseCapture ();
SendMessage (myWindowHandle, WM_SYSCOMMAND, SC_RESTORE, 0);
SendMessage (myWindowHandle WM_LBUTTONUP, 0, 0);
Still can't solve this problem

CodePudding user response:

Is it not NCHITTEST? Why the Dll?
 
Case WM_NCHITTEST:
Pt. X=LOWORD (lParam);
Pt. Y=HIWORD (lParam);
GetWindowRect (HWND, & amp; Rc);
//move the window
Rc. Top +=TestBorder;
Rc. Bottom -=TestBorder;
Rc. Left +=TestBorder;
Rc. Right -=TestBorder;
If (PtInRect (& amp; Rc, pt))
{
Return HTCAPTION;
}
//the size window
If (pt) x & lt; Rc. Left & amp; & Pt. Y & lt; Rc. Top)
{
Return HTTOPLEFT;
}
If (pt. X> Rc. Right & amp; & Pt. Y{
Return HTTOPRIGHT;
}
If (pt. X Rc. Bottom)
{
Return HTBOTTOMLEFT;
}
If (pt. X> Rc. Right & amp; & Pt. Y> Rc. Bottom)
{
Return HTBOTTOMRIGHT;
}
break;

CodePudding user response:

3 floor of brothers, I am in UNITY call API to implement without borders, no window title bar and then write their own DLL to achieve scaling,
Try your method, feel the entire window is the client area, point can be moved anywhere, zoom, the mouse must be refers to the four corners that one pixel to scaling,
I want to realize the function of the is:
1, my process is a POPUP window, no title bar and sizebox, I made the title bar in the client area,
Any mobile 2, drag the title bar, window, on the title bar to maximize, minimize, close the use sendmessage functionality,
3, mouse close to the border 5 pixels, close to four Angle of 10 pixels within the scope of the zoom window mouse tags, and drag the mouse can realize window scaling,

CodePudding user response:

1 the entire window is the client area, you can change bottom
2 the mouse must be refers to the four corners that one pixel to scaling, only 4
3 TestBorder=5 pixels

CodePudding user response:

5/f, modify the client to questions, your code logic with me nothing, respectively, in addition to the four edges to the range of + 5 pixels are customers, the other is the client area, right?
Can't solve my problem, I presume that is
SendMessage (myWindowHandle WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0). Executed, what is the state didn't reset, lead to this time to drag the border zoom still perform to my title bar moving events, if I move the window to perform a SendMessage (myWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0); Then go to the zoom window is all normalnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related