社区
C#
帖子详情
GDI绘图:如何创建不规则的区域
daview
2008-12-18 09:09:21
想画一个不规则的窗体,窗体的形状通过一个透明的图片来表示,这个图片的外框非常不规则,该如何创建这个区域?
发现REGION没有办法使用IMAGE对象为区域参考的,GRAPHICSPATH也没有这个功能。
...全文
175
5
打赏
收藏
GDI绘图:如何创建不规则的区域
想画一个不规则的窗体,窗体的形状通过一个透明的图片来表示,这个图片的外框非常不规则,该如何创建这个区域? 发现REGION没有办法使用IMAGE对象为区域参考的,GRAPHICSPATH也没有这个功能。
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
dayizhixiaotutu
2008-12-19
打赏
举报
回复
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);
}
}
}
qiying1988
2008-12-19
打赏
举报
回复
up
daview
2008-12-18
打赏
举报
回复
主要是,设置透明后不能改变大小,否则刷新有问题
yagebu1983
2008-12-18
打赏
举报
回复
你到WWW.CNBLOGS.COM搜搜!!!
还没见过你这种问题呢!!
daview
2008-12-18
打赏
举报
回复
我在设置了窗体无边框后,把图片的透明色去掉在通过draw的方式绘制到窗体上,结果看到的是透明的,但实际却不是。
GDI
+delphi
不规则
窗体
delphi中
创建
不规则
窗体,里面有
GDI
API.pas等文件。窗体可以淡入,淡出效果。delphi7下面,调试通过。 结合
GDI
的使用,显示特殊窗体。
GDI
+
不规则
窗体
http://blog.csdn.net/greless/article/details/74011387
GDI
绘图
序列保存加载
GDI
绘图
序列保存加载
C#
GDI
绘图
源码总结
C#
GDI
绘图
源码总结,绝对经典,欢迎下载!
GDI
绘图
新手入门源代码
GDI
绘图
新手入门 源代码 适合新手看看 高手就过吧
GDI
绘图
新手入门 源代码 适合新手看看 高手就过吧
C#
111,092
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章