当前位置:首页 -> 焦点新闻

程序运行过程中动态改变控件大小的方法

2005/1/7 14:52:02       
在程序运行期间改变控件大小要用到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);
  }

煤炭网版权与免责声明:

凡本网注明"来源:煤炭网www.coal.com.cn "的所有文字、图片和音视频稿件,版权均为"煤炭网www.coal.com.cn "独家所有,任何媒体、网站或个人在转载使用时必须注明"来源:煤炭网www.coal.com.cn ",违反者本网将依法追究责任。

本网转载并注明其他来源的稿件,是本着为读者传递更多信息的目的,并不意味着本网赞同其观点或证实其内容的真实性。其他媒体、网站或个人从本网转载使用时,必须保留本网注明的稿件来源,禁止擅自篡改稿件来源,并自负版权等法律责任。违反者本网也将依法追究责任。 如本网转载稿件涉及版权等问题,请作者在两周内尽快来电或来函联系。

  • 用手机也能做煤炭生意啦!
  • 中煤远大:煤炭贸易也有了“支付宝”
  • 中煤开启煤炭出口贸易人民币结算新时代
  • 下半年煤炭市场依然严峻
市场动态

网站技术运营:北京真石数字科技股份有限公司、喀什中煤远大供应链管理有限公司、喀什煤网数字科技有限公司

总部地址:北京市丰台区总部基地航丰路中航荣丰1层

京ICP备18023690号-1      京公网安备 11010602010109号


关注中煤远大微信
跟踪最新行业资讯