Thursday 15 September 2011

winforms - Visual c++, resize a control on mousedown -


I have created a UserControl library that contains many regular button controls.

I would like to change it on drag again via the dragging Windows messages and it is faster to do the innocent work.

I also set a correct cursor and .. back to WM_MOUSELEAVE .

  Override Virtual Zero WndProc (Message% M) {// Operating System Message Switch (MMS) {// Listen for more code //. // .. // ... case WM_MOUSEMOVE: if (m.WParam.ToInt32 () == MK_CONTROL) {debug :: WriteLine ("MK_CONTROL"); Return; } And if (m.WParam.ToInt32 () == MK_LBUTTON) {debug :: lineline ("MK_Lubutan"); If (Ismaussdown) {Debug :: Linline ("Drag Detected"); Debug: lineline ("ismausoudown:" + ismasudddown.tostring ()); Int tempX = (small) (M.L.P.M.O.OIT32 () and 0x0000FFFF); This- & gt; Shape. With = (this-> location.x-tempX); // & lt; --- does not work! Return; } Return; } And if (m.WParam.ToInt32 () == MK_MUTUTN) {debug :: linline ("MK_bootton"); Return; } And if (m.WParam.ToInt32 () == MK_RBUTTON) {debug :: WriteLine ("MK_Rubutton"); Return; } And if (m.WParam.ToInt32 () == MK_SHIFT) {Debug :: Linline ("MKCHIFT"); Return; } And if (m.WParam.ToInt32 () == MK_XBUTTON1) {debug :: lin line ("Mk_xbut1"); Return; } And if (m.WParam.ToInt32 () == MK_XBUTTON2) {debug :: lin line ("MK_XBUTTON2"); Return; } Return; // more code // // .. // ... return; } System :: Windows :: Form :: User Control :: WWFProp (M); }   

this still this-> Size.Width = (this-> location.x- e-> location.x); // & lt; --- Not working! this-> Size.Width will already remain on the default value of 400 set by the Properties window.

I know that it is possible to set the size through window messages, but I failed to understand how the C # was taken from:

  // This is C + + [DllImport ("User32.dll", for charts = charset.auto) does not seam the right syntax) 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 bool Akstrn Setvandopos (Handlrf Acdbludblud, Handlrf Acdblyuendanderrtapr, Int X, Y Int, Int CX, Int cycle, Int flag);   

Usront does not have any properties / errors that SetWindowPos

how to proceed is?

If the size of the property is a strucutre which gives value type you get a copy, you Modify, but the original remains the same. To resize the form, you can set:

this-> Size = new size (100, 100);

Use or better, width and height propetries:

it- & gt; Width + = 100;

No comments:

Post a Comment