C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,022 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello , how can I convert this c# code to C++/CLI code to make my borderless form SizeAble?
this - > SetStyle(ControlStyles::ResizeDraw, true);
private
const int cGrip = 16;
private
const int cCaption = 32;
protected override void WndProc(ref Message m)
{
if(m.Msg == 0x84)
{
Point pos = new Point(m.LParam.ToInt32());
pos = this.PointToClient(pos);
if(pos.Y < cCaption)
{
m.Result = (IntPtr) 2;
return;
}
if(pos.X\ >= this.ClientSize.Width - cGrip && pos.Y\ >= this.ClientSize.Heigh - cGrip)
{
m.Result = (IntPtr) 17;
return;
}
}
base.WndProc(ref m);
}
Try adding this code to your form class:
#include <Windows.h>
. . .
private:
const int cGrip = 16;
const int cCaption = 32;
protected:
void WndProc( Message% m ) override
{
switch( m.Msg )
{
case WM_NCHITTEST:
Point pos = Point( m.LParam.ToInt32( ) );
pos = PointToClient( pos );
if( pos.Y < cCaption )
{
m.Result = IntPtr( HTCAPTION );
return;
}
if( pos.X >= ClientSize.Width - cGrip && pos.Y >= ClientSize.Height - cGrip )
{
m.Result = IntPtr( HTBOTTOMRIGHT );
return;
}
break;
}
__super::WndProc( m );
}
. . .