c#消息窗体
C#模拟弹出窗体系统菜单介绍
using System.Runtime.InteropServices; const uint TPM_LEFTBUTTON = ;
const uint TPM_RIGHTBUTTON = ;
const uint TPM_LEFTALIGN = ;
const uint TPM_CENTERALIGN = ;
const uint TPM_RIGHTALIGN = ;
const uint TPM_TOPALIGN = ;
const uint TPM_VCENTERALIGN = 0x10;
const uint TPM_BOTTOMALIGN = 0x20;
const uint TPM_RETURNCMD = 0x100;
const uint WM_SYSCOMMAND = 0x0112; #region DllImport
[DllImport("User32.dll")]
static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("User32.dll")]
static extern bool GetCursorPos(out Point lpPoint);
[DllImport("User32.dll")]
static extern int TrackPopupMenu(IntPtr hMenu, uint uFlags,
int x, int y, int nReserved, IntPtr hWnd, out Rectangle prcRect);
[DllImport("User32.DLL")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
#endregion private void button1_Click(object sender, EventArgs e)
{
Point vPoint;
Rectangle vRect;
GetCursorPos(out vPoint);
SendMessage(Handle, WM_SYSCOMMAND, TrackPopupMenu(
GetSystemMenu(Handle, false),
TPM_RETURNCMD | TPM_LEFTBUTTON, vPoint.X, vPoint.Y,
, Handle, out vRect), );
}
C#实现类似MSN Messenger的弹出提示窗体
也许有的朋友最近有些疑惑,我的Blog叫Windows Mobile开发历险,为什么最近的文章都是win32下的,其实我最近写的东西是Windows Mobile/Windows xp结构的,所以对于win32的某些技术用得到,也有了些自己的心得体会。后来想了想,不能让这些东西白白流失,还是写下来吧。以便让自己记得长久,还能跟大家分享。
今天的文章,我主要介绍MSN Messenger弹出窗体的实现方法,MSN Messenger的弹出窗体就是再联系人登录或者发送新消息时候桌面右下角弹出的窗体。实现这样的窗体很简单,delphi中我写过这样的组件,不过因为号称商业机密的东西不便发表。C#就自由了,随便发布,哈哈!
其实实现这个弹出窗体只需调用windows API函数即可,AnimateWindow——我们都可以顾名思义了,哈哈!就是动态窗口!那么接下来我们只需知道如何调用该函数,如果定义该函数的参数,就可以了。下面我给出一个实例,并配上简单的注释,这样就能实现我们所要的功能了。如下:
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 FormHintTest
{
public partial class FormHint : Form
{
public FormHint()
{
InitializeComponent();
// 根据系统当前分辨率确定Hint窗体的位置
int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width - ;
int y = Screen.PrimaryScreen.WorkingArea.Height - this.Height - ;
this.Location = new Point(x, y);
}
public void Popup()
{
//在public函数中调用API函数实现动态效果
AnimateWindow(this.Handle, , (uint)AnimateWindowFlags.AW_SLIDE |
(uint)AnimateWindowFlags.AW_VER_NEGATIVE |
(uint)AnimateWindowFlags.AW_ACTIVATE);
this.Show();
}
[DllImport("user32.dll")] //Invoke Windows API函数 AnimateWindow
public extern static bool AnimateWindow(IntPtr hwnd,uint dwTime,uint dwFlags);
public enum AnimateWindowFlags : uint //AnimateWindow的dwFlags参数定义
{
AW_HOR_POSITIVE = 0x00000001,
AW_HOR_NEGATIVE = 0x00000002,
AW_VER_POSITIVE = 0x00000004,
AW_VER_NEGATIVE = 0x00000008,
AW_CENTER = 0x00000010,
AW_HIDE = 0x00010000,
AW_ACTIVATE = 0x00020000,
AW_SLIDE = 0x00040000,
AW_BLEND = 0x00080000
}
}
}
c#消息窗体的更多相关文章
- 【C#】分享一个可携带附加消息的增强消息框MessageBoxEx
--------------201507160917更新--------------- 无意中发现标准消息框在Windows7是有声音的,只是在Windows server 2008(R2)无声,而我 ...
- messager(消息窗口)
一.$.messager.alert()类似js中的alert('String') 方法参数:title, msg, icon, function(回调函数) 描述:title头部面板标题.msg主要 ...
- easyui源码翻译1.32--Messager(消息窗口)
前言 使用$.messager.defaults重写默认值对象.下载该插件翻译源码 消息窗口提供了不同的消息框风格,包含alert(警告框), confirm(确认框), prompt(提示框), p ...
- Messager( 消息窗口) 组件
一. 加载方式消息窗口提供了不同的消息框风格,包含 alert(警告框).confirm(确认框).prompt(提示框).progress(进度框)等.所有消息框都是异步的,用户可以在交互消息之后使 ...
- Windows消息传递函数SendMessage参数属性
Windows消息传递函数SendMessage参数属性 转载于:http://www.cr173.com/html/5605_1.html Windows是一个消息驱动式系统,SendMessage ...
- EasyUI - Messager消息框
全局设定: JavaScript代码: //设置按钮中的文字,默认是-ok/cancel ,可以任意设置文字,比如现在的-确认/取消 $.messager.defaults = { ok: '确认', ...
- Delphi 7中的四种消息框
Delphi中平常使用的消息框有四种形式,有ShowMessage.MessageDlg.Application.MessageBox.MessageBox.下面来深入了解下这四种形式的实现和使用.1 ...
- 第二百零五节,jQuery EasyUI,Messager(消息窗口)组件
jQuery EasyUI,Messager(消息窗口)组件 学习要点: 1.加载方式 2.属性列表 3.方法列表 本节课重点了解 EasyUI 中 Messager(消息窗口)组件的使用方法,这个组 ...
- [译]NeHe教程 - 创建一个OpenGL窗体
原文: Setting Up An OpenGL Window 欢迎阅读我的OpenGL教程.我是一个热爱OpenGL的普通码农!我第一次听到OpenGL是在3Dfx刚发布他们给Voodoo I显卡的 ...
随机推荐
- JDK 5.0 新增解决线程安全 Callable接口和线程池
在jdk5.0后又新增了两种解决线程安全的问题 一: 实现Callable接口, 实现接口步骤: 1: 创建一个实现Callable接口的实现类 2: 实现Callable接口中的call()方法, ...
- HTML--JS 表单验证
<html> <head> <title>验证表单</title> <script type="text/javascript" ...
- Cordova指令
安装 cordova: npm install -g cordova 创建应用程序 cordova create hello com.example.hello HelloWorld cordov ...
- Ubuntu下使用boost例子
http://blog.csdn.net/dotphoenix/article/details/8459277 1. 安装boost库 sudo apt-get install libboost-al ...
- 如何在Python中使用Linux epoll
如何在Python中使用Linux epoll 内容 介绍 阻塞套接字编程示例 异步套接字和Linux epoll的好处 epoll的异步套接字编程示例 性能考量 源代码 介绍 从2.6版开始,Pyt ...
- jq 与原生js 方法互相转换
最近在用mui写页面,当然了在移动App里引入jq或zepto这些框架,肯定是极不理性的.虽然jq很简单,但是也有兼容问题,js基础是很重要的,jq的成功当时是因为ie6.7.8.9.10.chrom ...
- SpringCloud-Eureka-Provider&Consumer
Eureka-Provider 服务的提供者 新建一个服务提供者项目 1.导入pom文件 <properties> <java.version>1.8</java.ver ...
- 使用grunt0.4进行js代码混淆
1.grunt是基于node,node需要>=0.8.0的稳定版本(奇数是开发版,偶数是稳定版) 2.安装grunt脚手架 (mac电脑需要权限 在前面加上 sudo) npm install ...
- linux性能相关的各个环节
- psfaddtable - 添加一个Unicode字符表到控制台字体中
总览 psfaddtable 字体文件 表文件 [输出文件] 描述 Psfaddtable 命令融合了 字体文件 提供的 .psf 格式的控制台字体和 表文件 提供的Unicode字符表, 生成一个带 ...