无边窗体在任务栏上的系统菜单
来源:互联网 发布:个人博客 php 源码 编辑:程序博客网 时间:2024/05/16 14:46
我们可能会用到一个没有边框的窗体,因为这样我们可以在整个窗体上自由的绘制。然后我们也会发现一个讨厌的问题,这个时候在任务栏上鼠标右键点不出那可爱的系统菜单了。这样会不好,会使得用户感觉到没有道理,为什么别的窗口都有系统菜单,而只有我们的窗体没有系统菜单呢?
其实如果我们使用VC建立MFC程序的时候,我们可以把窗体的“Title Bar”设置为False,这样MFC的窗口就是无标题的,然而这个窗口在运行后的任务栏上是有右键的系统菜单的。
为什么C#做不到而MFC可以做的到呢。。。
其实C#也可以做的到,只不过当C#里把一个窗体设置为不显示标题的时候它会默认的把系统菜单给隐藏掉了,而MFC是没有隐藏的。我们只要在C#里把这个被隐藏掉的系统菜单给放开就可以了。有如下的代码参考:
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 NoBorderForm{ public partial class NoBorder : Form { [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)] public static extern int GetWindowLong(HandleRef hWnd, int nIndex); [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)] public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong); public NoBorder() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int WS_SYSMENU = 0x00080000; this.FormBorderStyle = FormBorderStyle.None; int windowLong = (GetWindowLong(new HandleRef(this, this.Handle), -16)); SetWindowLong(new HandleRef(this, this.Handle), -16, windowLong | WS_SYSMENU); } }}转载地址:http://blog.csdn.net/hbxtlhx/article/details/1721061
0 0
- 无边窗体在任务栏上的系统菜单
- 无边窗体在任务栏上的系统菜单
- 无边窗体在任务栏上的系统菜单
- winfrom 在任务栏上的右键菜单
- 遍历任务栏上的窗体
- 窗体不出现在任务栏上
- 非MainForm窗体显示在任务栏上
- C#无边框窗体在任务栏右键菜单
- Delphi 让子窗体显示在任务栏上的几种方法
- 使子窗体也能出现在任务栏上
- 使子窗体也能出现在任务栏上
- DELPHI 让子窗体显示在任务栏上
- DELPHI 让子窗体显示在任务栏上
- 子窗体在任务栏上显示且能最小化到任务栏
- 窗体在任务栏显示 MFC
- 如何是生成的窗体在任务栏中不存在
- 改变对话框的系统菜单:程序运行时,在任务栏中的图标右键时弹出的菜单或是程序左上角左键弹出的菜单
- 在窗体上画线【使用系统方法】
- [问题]CocoaPods:XX(from `./`)` required by `Podfile`
- Maven常见异常及解决方法 .
- PL/SQL Developer中Dynamic Performance Tables Not Accessible的解决
- 局部变量的类型
- Android中对闹钟Alarm的事件处理
- 无边窗体在任务栏上的系统菜单
- 【BMT】MTK电池充电问题
- 【DButils学习之】总结
- C# - Abstract Classes
- Storm框架入门-很好的入门教材
- js效果——积累
- HDU 2546 饭卡
- 深入了解DSP与ARM的区别与联系
- 关于_ENV(lua5.2 or later)