Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms visualc&x2B+;,在mousedown上调整控件的大小_Winforms_Winapi_Visual C++_Winforms Interop - Fatal编程技术网

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);