欢迎光临
我们一直在努力

程序运行过程中动态改变控件大小的方法-.NET教程,组件控件开发

建站超值云服务器,限时71元/月

在程序运行期间改变控件大小要用到windowsapi函数

以下是主要的代码

[dllimport("user32.dll", entrypoint="getwindowlong")]

public static extern int getwindowlong (

int hwnd,

int nindex

);

[dllimport("user32.dll", entrypoint="setwindowlong")]

public static extern int setwindowlong (

int hwnd,

int nindex,

int dwnewlong

);

[dllimport("user32.dll", entrypoint="setwindowpos")]

public static extern int setwindowpos (

int hwnd,

int hwndinsertafter,

int x,

int y,

int cx,

int cy,

int wflags

);

public const int gwl_style = (-16);

public const int ws_thickframe = 0x40000;

const int swp_nosize = 0x1;

const int swp_nomove = 0x2;

const int swp_nozorder = 0x4;

const int swp_framechanged = 0x20 ;

private void button1_click(object sender, system.eventargs e)

{

int style = getwindowlong((int)this.textbox1.handle,gwl_style);

style |=ws_thickframe;

setwindowlong((int)this.textbox1.handle,gwl_style,style);

setwindowpos((int)this.textbox1.handle,(int)this.handle,0,0,0,0,swp_nozorder|swp_nosize|swp_nomove|swp_framechanged);

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 程序运行过程中动态改变控件大小的方法-.NET教程,组件控件开发
分享到: 更多 (0)