[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
//发送消息//winuser.h 中有函数原型定义
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture(); //释放鼠标捕捉winuser.h
[DllImportAttribute("user32.dll")] //winuser.h
private static extern Boolean ShowWindow(IntPtr hWnd, Int32 nCmdShow);
public void ShowForm(string ftitletext, string fcontenttext, Rectangle fRegionofFormTitle,
Rectangle fRegionofFormTitlebar, Rectangle fRegionofFormContent, Rectangle fRegionofCloseBtn)
{
titleText = ftitletext;
contentText = fcontenttext;
WorkAreaRectangle = Screen.GetWorkingArea(WorkAreaRectangle);
this.Top = WorkAreaRectangle.Height + this.Height;
FormBorderStyle. = FormBorderStyle.None;
WindowState = FormWindowState.Normal;
this.SetBounds(WorkAreaRectangle.Width - this.Width,
WorkAreaRectangle.Height - currentTop, this.Width, this.Height);
CurrentState = 1;
timer1.Enabled = true;
TitleRectangle = fRegionofFormTitle;
TitlebarRectangle = fRegionofFormTitlebar;
ContentRectangle = fRegionofFormContent;
CloseBtnRectangle = fRegionofCloseBtn;
ShowWindow(this.Handle, 4); //#define SW_SHOWNOACTIVATE
}
public void SetBackgroundBitmap(Image image, Color transparencyColor)
{
BackgroundBitmap = new Bitmap(image);
Width = BackgroundBitmap.Width;
Height = BackgroundBitmap.Height;
Region = BitmapToRegion(BackgroundBitmap, transparencyColor);
}
public Region BitmapToRegion(Bitmap bitmap, Color transparencyColor)
{
if (bitmap == null)
throw new ArgumentNullException("Bitmap", "Bitmap cannot be null!");
int height = bitmap.Height;
int width = bitmap.Width;
GraphicsPath path = new GraphicsPath();
for (int j = 0; j < height; j++)
for (int i = 0; i < width; i++)
{
if (bitmap.GetPixel(i, j) == transparencyColor)
continue;
int x0 = i;
while ((i < width) && (bitmap.GetPixel(i, j) != transparencyColor))
i++;
path.AddRectangle(new Rectangle(x0, j, i - x0, 1));
}
Region region = new Region(path);
path.Dispose();
return region;
}
protected override void OnPaintBackground(PaintEventArgs e)
{
Graphics grfx = e.Graphics;
grfx.PageUnit = GraphicsUnit.Pixel;
Graphics offScreenGraphics;
Bitmap offscreenBitmap;
ffscreenBitmap = new Bitmap(BackgroundBitmap.Width, BackgroundBitmap.Height);
ffScreenGraphics = Graphics.FromImage(offscreenBitmap);
if (BackgroundBitmap != null)
{
offScreenGraphics.DrawImage(BackgroundBitmap, 0, 0,
BackgroundBitmap.Width, BackgroundBitmap.Height);
}
DrawText(offScreenGraphics);
grfx.DrawImage(offscreenBitmap, 0, 0);
}
private void TaskbarForm_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (TitlebarRectangle.Contains(e.Location)) //单击标题栏时拖动
{
ReleaseCapture(); //释放鼠标捕捉
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); //发送左键点击的
//消息至该窗体(标题栏)
}
if (CloseBtnRectangle.Contains(e.Location)) //单击Close按钮关闭
{
this.Hide();
currentTop = 1;
}
if (ContentRectangle.Contains(e.Location )) //单击内容区域
{
System.Diagnostics.Process.Start("http://www.Rithia.com"); }
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有