Winforms visualc&x2B+;,在mousedown上调整控件的大小
我制作了一个Winforms visualc&x2B+;,在mousedown上调整控件的大小,winforms,winapi,visual-c++,winforms-interop,Winforms,Winapi,Visual C++,Winforms Interop,我制作了一个UserControl库,其中包含几个常规按钮控件 我想在拖动时调整它的大小。 DragDection是通过windows消息完成的,它可以完美地工作 我甚至成功地设置了一个正确的光标并。。回到WM_MOUSELEAVE virtual void WndProc( Message %m ) override { // Listen for operating system messages switch ( m.Msg ) { // more
UserControl
库,其中包含几个常规按钮控件
我想在拖动时调整它的大小。
DragDection是通过windows消息完成的,它可以完美地工作
我甚至成功地设置了一个正确的光标并。。回到WM_MOUSELEAVE
virtual void WndProc( Message %m ) override
{
// Listen for operating system messages
switch ( m.Msg )
{
// more code
// .
// ..
// ...
case WM_MOUSEMOVE:
if(m.WParam.ToInt32() == MK_CONTROL)
{
Debug::WriteLine("MK_CONTROL");
return;
}
else if(m.WParam.ToInt32() == MK_LBUTTON)
{
Debug::WriteLine("MK_LBUTTON");
if(isMouseDown)
{
Debug::WriteLine("drag Detected");
Debug::WriteLine("isMouseDown: " + isMouseDown.ToString());
int tempX = (short)(m.LParam.ToInt32() & 0x0000FFFF);
this->Size.Width = (this->Location.X - tempX); // <--- does not work!
return;
}
return;
}
else if(m.WParam.ToInt32() == MK_MBUTTON)
{
Debug::WriteLine("MK_MBUTTON");
return;
}
else if(m.WParam.ToInt32() == MK_RBUTTON)
{
Debug::WriteLine("MK_RBUTTON");
return;
}
else if(m.WParam.ToInt32() == MK_SHIFT)
{
Debug::WriteLine("MK_SHIFT");
return;
}
else if(m.WParam.ToInt32() == MK_XBUTTON1)
{
Debug::WriteLine("MK_XBUTTON1");
return;
}
else if(m.WParam.ToInt32() == MK_XBUTTON2)
{
Debug::WriteLine("MK_XBUTTON2");
return;
}
return;
// more code
// .
// ..
// ...
return;
}
System::Windows::Forms::UserControl::WndProc( m );
}
UserControl
没有名为SetWindowPos
如何继续?Size属性返回一个结构,它是值类型。所以你得到了一个副本,你可以修改它,但是原始的保持不变。要更改窗体的大小,可以设置: 此->尺寸=新尺寸(100100) 或者更好地使用宽度和高度属性:
此->宽度+=100 你说得对
this->Width
,发生了一些事情。。。虽然,我不知道。。。到底是什么。。。在上面。
// this doesn't seam the right synthax for C++
[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(HandleRef hWnd, int msg, int wParam, int lParam);
[DllImport("User32.dll", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern bool SetWindowPos(HandleRef hWnd, HandleRef hWndInsertAfter,
int x, int y, int cx, int cy, int flags);