logo 广告
Loading...
 导航 所在位置:论坛首页 -> ┈┋电脑网络┋┈ -> Asp/Asp.Net教程 -> 程序开发中C#创建不规则窗体代码
回复
标题:程序开发中C#创建不规则窗体代码收藏 编辑 删除 楼主 | 上一篇 下一篇
中国话
头像
等级:职业侠客
权限:普通用户
积分:61
金钱:2279
声望:77
经验:77
发帖数:573
注册:2007年12月4日
资料 短消息2008-10-3 11:37:15
代码如下:
 

  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);

  }

  }

  }进入讨论组讨论。

签名

2008-10-3 11:37:15 顶部
第1页 共页 共0个回复     <<    >>    
 快速回复
  • 支持UBB,HTML标签

  • 高级回复

  • 操作选项:评分 加精 解精 奖惩 设专题 设公告 解公告 固顶 总固顶 解固顶 结帖 解结帖 锁帖 解锁 移帖 删帖
      首页 | 购买指南 | 虚拟主机 | 特色介绍 | 下载中心 | 支付方式
    Copyright 2004-2008 BBSGood.com Powered By: BBSGood.Speed Version 5.0
      咨询电话:0575-85513832、0575-85513825(传真)、7*24小时咨询服务:13606552007 不良信息举报中心 浙ICP备05029817号
      业务QQ:38958768、客服QQ1:415896239、客服QQ2:343896043、MSN:jccsxx@hotmail.com