
每种显示屏都是不一样的,我现在用的这个三星的就有专门的按钮是自动调整的
至于普通的显示屏可以进入MENU后自己找找,
另外一个办法就是百度上找“自动调整屏幕软件”
我记得网上是有这个软件的
给你个例子吧
建立一个frmmain主窗体
Option Explicit
Private Sub Form_Load()
'初始化imgIcon控件的Picture属性
imgIconPicture = LoadPicture(AppPath & "\" & "heartico")
mnuTrayShowEnabled = False
'初始化NOTIFYICONDATA数据结构
Dim nid As NOTIFYICONDATA
nidcbSize = Len(nid)
nidhwnd = frmTemphwnd
niduId = 1&
niduFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
niduCallbackMessage = WM_NOTIFYICON
nidhicon = imgIconPicture
nidszTip = "系统托盘中的图标" & Chr(0)
'调用Shell_NotifyIcon函数将图标加入到系统托盘中
Shell_NotifyIcon NIM_ADD, nid
End Sub
Private Sub Form_Unload(Cancel As Integer)
'设置自定义类型的变量的内容
Dim nid As NOTIFYICONDATA
nidcbSize = Len(nid)
nidhwnd = frmTemphwnd
niduId = 1&
niduFlags = 0
'调用Shell_NotifyIcon方法来删除系统托盘中的图标
Shell_NotifyIcon NIM_DELETE, nid
Unload frmTemp
End Sub
Private Sub mnuTrayExit_Click()
Unload Me
End Sub
Private Sub mnuTrayHide_Click()
'隐藏窗体,并相应改变菜单项的状态
MeHide
mnuTrayHideEnabled = False
mnuTrayShowEnabled = True
End Sub
Private Sub mnuTrayIcon_Click()
'设置dlgOpen公用对话框的属性,以便取得相应的图标文件
dlgOpenFilter = "图标文件(ico)|ico"
dlgOpenFlags = cdlOFNFileMustExist
dlgOpenShowOpen
If dlgOpenFileName = "" Then Exit Sub
'根据所取得图标文件,来改变imgIcon文件的属性
imgIconPicture = LoadPicture(dlgOpenFileName)
'设置NOTIFYICONDATA数据结构
Dim nid As NOTIFYICONDATA
nidcbSize = Len(nid)
nidhwnd = frmTemphwnd
niduId = 1&
niduFlags = NIF_ICON
nidhicon = imgIconPicture
'调用Shell_NotifyIcon函数来修改系统托盘中的图标
Shell_NotifyIcon NIM_MODIFY, nid
End Sub
Private Sub mnuTrayShow_Click()
'显示窗体,并相应改变菜单项的状态
MeShow
mnuTrayHideEnabled = True
mnuTrayShowEnabled = False
End Sub
Private Sub mnuTrayTip_Click()
Dim str As String
str = InputBox("输入系统托盘中的图标的提示信息:", "提示信息")
If str = "" Then Exit Sub
'设置NOTIFYICONDATA数据结构
Dim nid As NOTIFYICONDATA
nidcbSize = Len(nid)
nidhwnd = frmTemphwnd
niduId = 1&
niduFlags = NIF_TIP
nidszTip = str & Chr(0)
'调用Shell_NotifyIcon函数来修改系统托盘中的图标的提示
Shell_NotifyIcon NIM_MODIFY, nid
End Sub
再建立一个空窗体叫frmTemp
再建一个模块,名字随便了
Option Explicit
'声明Shell_NotifyIcon函数,用于将图标加入到系统托盘中
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
'声明自定义的数据类型NOTIFYICONDATA
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallbackMessage As Long
hicon As Long
szTip As String 64
End Type
'声明常量
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
'定义SetWindowLong,用以改变frmTemp窗体的窗体函数
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
'定义事件的常数代码
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_USER = &H400
'定义自定义的事件WM_NOTIFYICON
Public Const WM_NOTIFYICON = WM_USER + &H100
'替换窗口处理函数
Public Const GWL_WNDPROC = (-4)
'该函数为frmTest的窗体处理函数。
Function DialogProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim bln As Boolean
bln = True
If uMsg = WM_NOTIFYICON Then
'表示对系统托盘中的程序进行 *** 作
If lParam = WM_LBUTTONDOWN Then
'如果按下鼠标左键,则显示菜单
frmMainShow
frmMainmnuTrayShowEnabled = False
frmMainmnuTrayHideEnabled = True
ElseIf lParam = WM_RBUTTONDOWN Then
'如果按下鼠标右键,则d出菜单
frmMainPopupMenu frmMainmnuTray
Else
'否则,将程序控制权交给系统处理
bln = False
End If
Else
'否则,将程序控制权交给系统处理
bln = False
End If
DialogProc = bln
End Function
Sub Main()
Load frmTemp
frmMainShow
'调用SetWindowLong函数来改变frmTemp窗体的窗体函数
Call SetWindowLong(frmTemphwnd, GWL_WNDPROC, AddressOf DialogProc)
End Sub
我就不详细解释了,看看注释,如果稍微会一点vb就能看懂了建立工程也很简单,不再罗嗦
注意:把vbp的代码也给你,中间mnu开头的是自己建的菜单中间HEARTICO和SPADEICO是指2个在托盘中显示的图标如果不自己改例子的代码,就把图标放到同目录下吧
Type=Exe
Form=frmMainfrm
Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#12#0; COMDLG32OCX
Form=frmTempfrm
Module=mdlStandard; mdlStandardbas
IconForm="frmMain"
Startup="Sub Main"
HelpFile=""
title="TBIcon"
ExeName32="TBIconexe"
Command32=""
Name="TrayIcon"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=5
AutoIncrementVer=1
ServerSupportFiles=0
VersionComments="Exemple VB4 "
VersionCompanyName="-"
VersionLegalCopyright="Benjamin Bourderon Benjab@msncom"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
[MS Transaction Server]
AutoRefresh=1
using System;
using SystemDrawing;
using SystemCollections;
using SystemComponentModel;
using SystemWindowsForms;
using SystemData;
using SystemIO;
namespace RichText
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : SystemWindowsFormsForm
{
private SystemWindowsFormsMainMenu mainMenu1;
private SystemWindowsFormsMenuItem menuItem1;
private SystemWindowsFormsRichTextBox rtxContent;
private SystemWindowsFormsMenuItem menuItemOpen;
private SystemWindowsFormsMenuItem menuItemSave;
private SystemWindowsFormsToolBar tbrStatus;
private StreamReader sr;
private StreamWriter sw;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private SystemComponentModelContainer components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
componentsDispose();
}
}
baseDispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
SystemResourcesResourceManager resources = new SystemResourcesResourceManager(typeof(Form1));
thisrtxContent = new SystemWindowsFormsRichTextBox();
thismainMenu1 = new SystemWindowsFormsMainMenu();
thismenuItem1 = new SystemWindowsFormsMenuItem();
thismenuItemOpen = new SystemWindowsFormsMenuItem();
thismenuItemSave = new SystemWindowsFormsMenuItem();
thistbrStatus = new SystemWindowsFormsToolBar();
thisSuspendLayout();
//
// rtxContent
//
thisrtxContentAnchor = ((SystemWindowsFormsAnchorStyles)((((SystemWindowsFormsAnchorStylesTop | SystemWindowsFormsAnchorStylesBottom)
| SystemWindowsFormsAnchorStylesLeft)
| SystemWindowsFormsAnchorStylesRight)));
thisrtxContentLocation = new SystemDrawingPoint(0, 0);
thisrtxContentName = "rtxContent";
thisrtxContentSize = new SystemDrawingSize(296, 272);
thisrtxContentTabIndex = 0;
thisrtxContentText = "";
//
// mainMenu1
//
thismainMenu1MenuItemsAddRange(new SystemWindowsFormsMenuItem[] {
thismenuItem1});
//
// menuItem1
//
thismenuItem1Index = 0;
thismenuItem1MenuItemsAddRange(new SystemWindowsFormsMenuItem[] {
thismenuItemOpen,
thismenuItemSave});
thismenuItem1Text = "&File";
//
// menuItemOpen
//
thismenuItemOpenIndex = 0;
thismenuItemOpenText = "&Open";
thismenuItemOpenClick += new SystemEventHandler(thismenuItemOpen_Click);
//
// menuItemSave
//
thismenuItemSaveIndex = 1;
thismenuItemSaveText = "&Save";
thismenuItemSaveClick += new SystemEventHandler(thismenuItemSave_Click);
//
// tbrStatus
//
thistbrStatusButtonSize = new SystemDrawingSize(16, 16);
thistbrStatusDock = SystemWindowsFormsDockStyleBottom;
thistbrStatusDropDownArrows = true;
thistbrStatusLocation = new SystemDrawingPoint(0, 244);
thistbrStatusName = "tbrStatus";
thistbrStatusShowToolTips = true;
thistbrStatusSize = new SystemDrawingSize(292, 22);
thistbrStatusTabIndex = 1;
//
// Form1
//
thisAutoScaleBaseSize = new SystemDrawingSize(6, 14);
thisClientSize = new SystemDrawingSize(292, 266);
thisControlsAdd(thistbrStatus);
thisControlsAdd(thisrtxContent);
thisIcon = ((SystemDrawingIcon)(resourcesGetObject("$thisIcon")));
thisMenu = thismainMenu1;
thisName = "Form1";
thisText = "Text";
thisResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
ApplicationRun(new Form1());
}
private void menuItemOpen_Click(object sender, SystemEventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1Filter = "txt files (txt)|txt";
openFileDialog1FilterIndex = 2 ;
openFileDialog1Title = "Select A File ";
if(openFileDialog1ShowDialog() == DialogResultOK)
{
sr = new StreamReader(openFileDialog1FileName);
thisrtxContentText = srReadToEnd();
srClose();
}
}
private void menuItemSave_Click(object sender, SystemEventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1Filter = "txt files (txt)|txt";
saveFileDialog1Title = "Save A File";
if(saveFileDialog1ShowDialog() == DialogResultOK)
{
sw = new StreamWriter(saveFileDialog1FileName);
swWrite(thisrtxContentText);
swClose();
}
}
}
}
TRzMenuButton控件提供了一个简单和简洁的方式来显示一个d出菜单给用户。设置TRzMenuButton控件的DropdownMenu属性,可以将一个TPopupMenu赋给它。
以上就是关于液晶显示器亮度调节有四个按扭MENU ,DOWN, UP, EXIT,那个可以解决桌面出现图像自动调整的问题全部的内容,包括:液晶显示器亮度调节有四个按扭MENU ,DOWN, UP, EXIT,那个可以解决桌面出现图像自动调整的问题、怎么能让VB 程序最小化时在托盘显示呀急急急!~希望VB高手帮忙!、c#问题!100分等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)