自定义表单设计器,使用 WinAPI 移动/调整控件大小 [英] Custom form designer, move/resize controls using WinAPI
问题描述
我必须解决一些问题并增强很久以前为数据库项目编写的表单设计器.在设计面板类代码中,我遇到了这些行
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 指示鼠标是否在选定控件的任何边缘上.
FMousePosition indicates whether mouse was over any edge of selected control.
让我困惑的是这些 Windows 消息:似乎没有关于 WM_SYSCOMMAND 参数为 0xF001-0xF009 的文档(也许它会启动某种拖动/调整大小序列").有任何想法吗?
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?
推荐答案
它们是 未记录 参数.搜索后,我设法找到了这个列表.
They are undocumented parameters. After searching I managed to find this list.
- 0xF000(
SC_SIZE
,表单上的中心光标) - 0xF001(
SC_SZLEFT
,从左边调整大小) - 0xF002(
SC_SZRIGHT
,从右边调整大小) - 0xF003(
SC_SZTOP
,从顶部调整大小) - 0xF004(
SC_SZTOPLEFT
,锁定窗体右下角,左上角移动调整大小) - 0xF005(
SC_SZTOPRIGHT
,与左下角相同) - 0xF006(
SC_SZBOTTOM
,锁定右上角和左上边界,调整底部大小) - 0xF007(
SC_SZBOTTOMLEFT
,锁定上下边框,调整其他边框大小) - 0xF008(
SC_SZBOTTOMRIGHT
,锁定左上边框并调整其他大小) - 0xF009(
SC_SIZE|0x9
,从任何地方拖动) - 0xF00F (
SC_SEPARATOR
) - 0xF010(
SC_MOVE
,将光标置于上位) - 0xF012(
SC_DRAGMOVE
,拖动移动) - 0xF020(
SC_MINIMIZE
,自动最小化表单) - 0xF030(
SC_MAXIMIZE
,自动最大化表单) - 0xF040(
SC_NEXTWINDOW
,停止!你不想那样,它会锁定所有鼠标点击并让你重新启动) - 0xF148(
SC_SCREENSAVE|0x8
,激活屏幕保护程序) - 0xF13E(
SC_TASKLIST|0xE
,激活开始按钮)
- 0xF000 (
SC_SIZE
, Center cursor on the form) - 0xF001 (
SC_SZLEFT
, Resize from left) - 0xF002 (
SC_SZRIGHT
, Resize from right) - 0xF003 (
SC_SZTOP
, Resize from top) - 0xF004 (
SC_SZTOPLEFT
, Lock the bottom right corner of the form, the top left corner move for resize) - 0xF005 (
SC_SZTOPRIGHT
, Same from bottom left corner) - 0xF006 (
SC_SZBOTTOM
, Lock top right and left border, resize bottom) - 0xF007 (
SC_SZBOTTOMLEFT
, Lock top and right border, resize other border) - 0xF008 (
SC_SZBOTTOMRIGHT
, Lock left and top border and resize other) - 0xF009 (
SC_SIZE|0x9
, Drag from anywhere) - 0xF00F (
SC_SEPARATOR
) - 0xF010 (
SC_MOVE
, Put cursor centered at the upper order) - 0xF012 (
SC_DRAGMOVE
, move by dragging) - 0xF020 (
SC_MINIMIZE
, Auto-Minimize Form) - 0xF030 (
SC_MAXIMIZE
, Auto-Maximize Form) - 0xF040 (
SC_NEXTWINDOW
, Stop! You don't want that, it will lock all mouse click and make you reboot) - 0xF148 (
SC_SCREENSAVE|0x8
, Activate ScreenSaver) - 0xF13E (
SC_TASKLIST|0xE
, Activate StartButton)
参考:http://www.delphi3000.com/articles/article_1054.asp#评论
这篇关于自定义表单设计器,使用 WinAPI 移动/调整控件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!