注册本站  论坛  繁體中文

慧民电脑芯片级维修-电脑技巧
手机 | MP3 | MP4 | 显卡 | 主板 | 显示器 | 光存储 | 笔记本 | 网络设备 | 移动存储 | 数码相机
键鼠 | CPU | 音箱 | GPS | 电视 | 服务器 | 投影机 | 机箱电源 | 品牌电脑 | 办公打印 |
| 网站首页 | Cisco | Windows | Linux | Java | Dotnet | Oracle | 网页设计 | 平面设计 | 安全 | 软件应用 | 电脑维修 | 办公维修 |
您现在的位置: 电脑技巧 >> Dotnet >> C# >> Dotnet正文

程序开发中C#创建不规则窗体代码

文章来源:www.qqread.com 作者:易庆华 更新时间:2008-9-22 12:25:26 【 】 【加入收藏

代码如下:

 

  using System;

  using System.Collections.Generic;

  using System.ComponentModel;

  using System.Data;

  using System.Drawing;

  using System.Text;

  using System.Windows.Forms;

  using System.Runtime.InteropServices;

  namespace APIDemo

  {

  public partial class Form1 : Form

  {

  [StructLayout(LayoutKind.Sequential)]

  private struct POINTAPI

  {

  internal int x;

  internal int y;

  }

  [DllImport("gdi32.dll")]

  private static extern IntPtr CreatePolygonRgn(

  ref POINTAPI lpPoint,

  int nCount,

  int nPolyFillMode);

  [DllImport("user32.dll")]

  private static extern IntPtr SetWindowRgn(

  IntPtr hWnd,

  IntPtr hRgn,

  ref Boolean bRedraw);

  public Form1()

  {

  InitializeComponent();

  //创建不规则窗体

  POINTAPI[] poin;

  poin =new POINTAPI [5];

  poin[0].x = 90;

  poin[0].y = 90;

  poin[1].x = this.Width;

  poin[1].y = 0;

  poin[2].x = Width ;

  poin[2].y = this.Height/2;

  poin[3].x = Width / 2;

  poin[3].y = Height / 2;

  poin[4].x = 0;

  poin[4].y = Width;

  Boolean flag = true;

  IntPtr hRgn= CreatePolygonRgn(ref poin[0],8,1);

  SetWindowRgn(this.Handle, hRgn, ref flag );

  this.BackColor = Color.BurlyWood;

  }

  //设置窗体显示状态

  [DllImport("user32.dll")]

  private static extern int SetWindowPos(

  IntPtr hwnd,

  int hWndInsertAfter,

  int x,

  int y,

  int cx,

  int cy,

  int wFlags);

  private void Start_Btn_Click(object sender, EventArgs e)

  {//始终显示在前面

  SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1);

  }

  private void button1_Click(object sender, EventArgs e)

  {

  //最小化始终显示在前面

  SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 0);

  }

  }

  }进入讨论组讨论。

  • 上一篇Dotnet:

  • 下一篇Dotnet:
  • 最 新 热 门
     详解如何实现最基本的AJAX框架
     XAML命名空间和命名空间映射
     SOA and Web services 新手入门
     Ajax实战:在浏览器端应用MVC
     超越XML和JSON:YAM
     闲话Java Web层框架优缺点 用哪个呢?
     如何通过Web Services上传和下载文件
     ASP.NET中XML数据的处理
     关于.net和Java的比较
     ADO.NET实体框架准备好面向企业级应用了?
    最 新 推 荐
     如何构造一个C#语言的爬虫蜘蛛程序
     C#编程轻松实现对文件的操作技巧
     C#如何取硬件标志代码
     C#中将Big5繁体转换简体GB2312的代码
     C#线程池的实现
     程序开发中C#创建不规则窗体代码
     程序员提高C#编程水平的50个要点
     自学.NET之路-C#编程之基础总结
     C#编程中给数据库添加会议数据
     提高C#编程水平的50个要点
    相 关 文 章

    VB6如何在托盘中写入应用程序图标
    VC程序开发中定制对话框中的回车键
    .net开发绑定到LINQ查询的结果实例
    .net开发实例:绑定到ADO.NET数据源
    Visual C#通用模块开发:后台管理员模块
    Visual C#通用模块开发:DataGrid控件
    .NET开发中正则表达式中BUG一例
    .net开发使用QueryString
    .net开发中批量删除记录时如何实现全选功能
    ASP.NET开发中的八个最佳实践

    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告

     

    Copyright 2006-2008 pcjx.com All Rights Reserved
    电脑技巧 版权所有 粤ICP备06059145号 地图
    门市地址:广东省佛山市南海区黄岐黄海路133号
    本网站所有内容未经许可不得转载或做其他使用