C#创建不规则窗体代码
ReadyGo!技术成就梦想
网络搜索
efish
2008-8-2 23:35:11
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
{
private struct POINTAPI
{
internal int x;
internal int y;
}
private static extern IntPtr CreatePolygonRgn(
ref POINTAPI lpPoint,
int nCount,
int nPolyFillMode);
private static extern IntPtr SetWindowRgn(
IntPtr hWnd,
IntPtr hRgn,
ref Boolean bRedraw);
public Form1()
{
InitializeComponent();
//创建不规则窗体
POINTAPI;
poin.x = 90;
poin.y = 90;
poin.x = this.Width;
poin.y = 0;
poin.x = Width ;
poin.y = this.Height/2;
poin.x = Width / 2;
poin.y = Height / 2;
poin.x = 0;
poin.y = Width;
Boolean flag = true;
IntPtr hRgn= CreatePolygonRgn(ref poin,8,1);
SetWindowRgn(this.Handle, hRgn, ref flag );
this.BackColor = Color.BurlyWood;
}
//设置窗体显示状态
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);
}
}
}
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
{
private struct POINTAPI
{
internal int x;
internal int y;
}
private static extern IntPtr CreatePolygonRgn(
ref POINTAPI lpPoint,
int nCount,
int nPolyFillMode);
private static extern IntPtr SetWindowRgn(
IntPtr hWnd,
IntPtr hRgn,
ref Boolean bRedraw);
public Form1()
{
InitializeComponent();
//创建不规则窗体
POINTAPI;
poin.x = 90;
poin.y = 90;
poin.x = this.Width;
poin.y = 0;
poin.x = Width ;
poin.y = this.Height/2;
poin.x = Width / 2;
poin.y = Height / 2;
poin.x = 0;
poin.y = Width;
Boolean flag = true;
IntPtr hRgn= CreatePolygonRgn(ref poin,8,1);
SetWindowRgn(this.Handle, hRgn, ref flag );
this.BackColor = Color.BurlyWood;
}
//设置窗体显示状态
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);
}
}
}
-
相关文章
如何为程式码加上行号
如何为程式码加上行号
ViewState使用兼谈序列化
ViewState使用兼谈序列化
微软CFO:10亿美元收购雅虎搜索
微软CFO:10亿美元收购雅虎搜索
百度首页添加hao123链接
百度首页添加hao123链接
希捷一年出货硬盘1.83亿块 每秒钟近6块
希捷一年出货硬盘1.83亿块 每秒钟近6块
IT界对云计算的20个定义
IT界对云计算的20个定义
用vim处理字符的大小写转换
用vim处理字符的大小写转换
Vim 使用技巧
Vim 使用技巧
GRUB模拟光盘启动
GRUB模拟光盘启动
wine中文支持设置
wine中文支持设置
2秒记住本站域名
玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的ReadyGo.com.cn
