I have to fix some problems and enchance form designer written long ago for a database project. In Design Panel class code I encountered these lines
private void DesignPanel_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
(sender as Control).Capture = false;
switch (FMousePosition)
{
case MousePosition.mpNone:
SendMessage((sender as Control).Handle, WM_SYSCOMMAND, 0xF009, 0);
break;// Move
case MousePosition.mpRightBottom:
SendMessage((sender as Control).Handle, WM_SYSCOMMAND, 0xF008, 0);
break;//RB
case MousePosition.mpLeftBottom:
SendMessage((sender as Control).Handle, WM_SYSCOMMAND, 0xF007, 0);
// ... here are similar cases ...
case MousePosition.mpLeft:
SendMessage((sender as Control).Handle, WM_SYSCOMMAND, 0xF001, 0);
break;//L
}
}
}
FMousePosition indicates whether mouse was over any edge of selected control.
What confusing me is these windows messages: it seems there is no documentation on WM_SYSCOMMAND with parameters 0xF001-0xF009 (maybe it starts some kind of 'drag/resize sequence'). Any ideas?
If my suggestion is right, then how can I cancel these sequences?
-
See APIViewer and check out constants starting with SC_
-
They are undocumented parameters. After searching I managed to find this list.
- 0xF000 (Centre cursor on the form)
- 0xF001 (Resize from left)
- 0xF002 (Resize from right)
- 0xF003 (Resize from up)
- 0xF004 (Lock the bottom right corner of the form, the up left corner move for resize)
- 0xF005 (Same from bottom left corner)
- 0xF006 (Lock up right and left border, resize other)
- 0xF007 (Lock up and right border, resize other border)
- 0xF008 (Lock left and up border and resize other)
- 0xF009 (Drag from anywhere)
- 0xF010 (Put cursor centred at the upper order)
- 0xF020 (Auto-Minimize Form)
- 0xF030 (Auto-Maximize Form)
Reference: http://www.delphi3000.com/articles/article_1054.asp#Comments
-
Based on my Win32 Programming (Rector and Newcomer) p902-903 explains
WM_SYSCOMMANDis sent when the user selects an item from the system menu (rather than sending the normalWM_COMMAND).The MSDN help says SC_SIZE = 0xF000 and it and Win32 Programming also say Windows uses the four low-order bits of the predefined system menu IDs internally but doesn't go on to clarify their use. Thanks stukelly for clarifying them.
0 comments:
Post a Comment