how to make menu disable?

101_halg 2004-04-04 07:06:15
我让一个menu响应了一个事件,我现在想让他disable,到想用他进再让他enable,
可是我右键点击menu的property起不到disable的作做,都不灰化,请问有什么方法让他disable,再请问一下怎么样让disable的menu重新enable
...全文
140 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
byf2002 2004-04-04
  • 打赏
  • 举报
回复
以上的解答都是有问题的。
实际上,只需要将CFrameWnd:: m_bAutomenuEnable设置为FALSE,如果该数据成员为TRUE(缺省值),工作框将自动地禁止没有ON_UPDATE_COMMAND_UI或者ON_COMMAND的菜单项。

这一代码最好加在构造函数中,例如我的主框架是CMainFrame
所加的代码就是

CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
m_bAutoMenuEnable = FALSE;
}

这样,你就会发现右键点击menu的property中disable开始起作用了。
vcforever 2004-04-04
  • 打赏
  • 举报
回复
响应你的菜单项的UPDATE_COMMAND_UI消息!
在消息处理函数中使用pCmdUI->Enable(false);
enoloo 2004-04-04
  • 打赏
  • 举报
回复
CCmdUI.
xxhfortrue 2004-04-04
  • 打赏
  • 举报
回复

EnableMenuItem()
1 , docudel.zip
This example shows how to clear the document history on the start menu.
2 , BatteryAPIdemo.zip
This example demonstrates how to "To get information about the battery status with out having to use the SysInfo.ocx from MS"
3 , DisableXexam.zip
This example easily demonstrates how to remove the "X" from your forms.
4 , manc-sleep.zip
This example demonstrates how to pause for a specified duration in seconds using the 'Sleep' win32 API function.
5 , camp-api.zip
An example of editing the "win.ini" file to execute programs when Windows loads.
6 , win32api.exe
This will install the Win32API.txt on your system. This file holds all API declarations for Windows. Must 下载.
7 , transparentblt.zip
This demonstrates how to display an image transparently on the form. An excellent example.
8 , MessageBoxDemo.zip
Manipulate Message Boxes using API. These include a self-closing message box, and a form-centered message box.
9 , menucol.zip
This shows how to add "columns" to your menus. An excellent example.
10 , changeborder.zip
Have you ever wanted to change the border style during runtime? Now you can using SetWindowLong. This example demonstrates greatly how you can accomplish this.
11 , capmousedemo.zip
This example demonstrates how to Set capture on the mouse to detect when it enters and leaves a specific portion of your form.
12 , apilines.zip
This example demonstrates how to draw lines using API.
13 , killapp.zip
This is a bas file to close any window with just it's caption.
14 , combohgt.zip
This demonstrates how to change the height of a combobox's drop-down height using API.
15 , bat-os.zip
This demonstrates how to retrieve information about Battery Powered machines.
16 , display.zip
This will open the Screen Resolution Dialog so you can manipulate it.
17 , ciasystray.zip
This shows you how to add your icon to the system tray without any third-party controls.
18 , taskbar.zip
This demonstrates how to Hide and Show the taskbar.
19 , wpchanger.zip
This shows how to change Windows' Desktop Wallpaper
20 , discad.zip
This shows how to disable control alt and delete by tricking the computer into thinking that the screensaver is running.
21 , windowfrompoint.zip
Get a window's handle from the current cursor position.
22 , api.zip
api function collection
23 , benchmark.zip
This program is very usefull program which gets the details of your computer and have an ability of changing some system details.
24 , menustructure.zip
This program will retrieve the full menu structure of a Form, up to three levels, and allow the user to modify it.
25 , crackPassword.zip
This is a very unusual program which will let you read behind those ******* in password fields and recover captions from Dialogs, Labels, Command Buttons, TextBoxes...
26 , hotkey_source.zip
Hotkey Manager Beta Version: Manages and implements hotkey in Windows 95/98/NT.
27 , rjsoftapisamples.zip
The samples included in this project use the few API
28,sysmetrics.zip
This is a windows information viewer. You can use this sample to find or select an open window, and view information about the window, such as its hwnd, size, and parent window.
29,launcher.zip
This is an ActiveX DLL that causes a client app to wait for another app to finish. The library takes care of launching the new app and doing all of the synchronization. It also returns the exit code for the process.
30,servcont.zip
It enables you to start and stop NT Services through the Win32 API, change the startup type and the security account associated with it. Included is a test harness so that people can see how it works. The code has been tested under NT4 SP6a
31,passdemo.zip
This is a very good example of how to use the registry to save data. It shows how to create, store and save a password to the registry and also encrypts it to keep out prying eyes.
32,delay.zip
This is a rough translation of the GetTickCount API and includes three different ways to pause an application.
33,cdromsystray.zip
This excellent program which was sent to us annoymously adds an icon to the systray (bottom right on the start menu bar) and allows you to control the opening and closing of the CDROM.. Easily adaptable, and if you wrote this and want to be credited
34,rgbdemo.zip
Very small, very fast. Complete source included to demonstrate how to translate a long to red, green and blue values
35,sleep2.zip
This is a small project showing how to use the Sleep API call from within your program to pause for a set period of time. Its much better than looping round as it uses very little CPU time
36,threads.zip
This application is only used to show how a multithreaded program is structured through the 'eyes' of VB. If you follow the logic of the program it does teach a lot about multithreading and the necessary techniques to do this in a 'Thread Safe environmen
37,callback.zip
This small project is for the more advanced VB users and shows an undocumented VB function and an undocumented Win32 API function. Demonstrated in the project how to use these two functions in order to raise events in a class from a module
38,ctaskmanager.zip
This application contains the same basic functionality as the task manager in Windows. It allows you to see the loaded windows on your system as well as the class, position and process ID for each window. Remember that every process running on a system
39,cprocessfinished.zip
This little routine will test if a shelled process has finished executing and return true or false. Its bits of code like that we would like more of, so please send them.
40,apimsg.zip
API Message Box
41,freespc.zip
Get a Drive's Free Space
42,drvinfo.zip
Get Drive Information (S/N, Label, Format)
43,nodisk.zip
Show Message When There is No Disk in a Drive
44,fullpath.zip
Add Full Paths to a TreeView
45,disksrch.zip
Search for Disk in a Removable Drive
46,drvtype.zip
Determine Drive Type
47,findcd1.zip
Find the First CD-ROM
48,xxsShell32.zip
Shell32 functions and subs wrapper for VB developers.
49,api2.zip
This application is designed to help VB Developer to find Windows API Easely.
50,qsvb.zip
QuickSilver for Visual Basic, aims to provide a wrapper for all important Windows API functions by a simple class. All the operations are included as properties and methods that can used with the same ease as any other part of your dream project.
51,CPUInfo.zip
This code will quickly tell you a lot of your system information like computer name, IP address, OS, Service Pack, Processor Vendor, Processor Type, Processor Speed (Raw and Normal), RAM (Total and Available).
52,Callbacks.zip
It is nice little application, which demonstrates WinAPI Callbacks. It hides and restors all Yahoo chatting window in a single click.
53,ShellTrayIcon.zip
The CShellTrayIcon class allows your VB application to set, change and delete icons in the system's tray (note: the official term for the tray is the taskbar notification area). The class raises an event in your application when the user clicks an icon in the tray.
54,EventCtl.zip
This little control greatly simplifies the business of subclassing a form to get at the extra events that the Visual basic designers left out. i.e.:
55,EuroCalc2.zip
In place conversion between every one of the European Monetary Union member currencies and the Euro.
56,Edge.zip
In my program i have used few API functions to set 3D,Sunken,etched effects to the images of your image control.Another example shows how to change your label control to a 3D command button almost functionally.
57,Prjfloat.zip
I have used two APIFuctions 'Setwindowword' and 'Setparent' to make the child window float
freely and with in the parent window. Open with vb5 and vb6.
58,FilterTextBox.zip
This program shows how to filter out characters from TextBox control.Uses GetWindowLong and SetWindowLong APIs.
59,SysControl.zip
This is a program that will let you show, hide, alter text, capture a picture, change the parent, kill, close, enable, disable, get info on, minimize, maximize, restore, capture a picture of, make them stay-on-top, send a message to, edit the window style, and flash the title bar on almost any target!
60,LBApi.zip
This program uses Sendmessage API function for additem,removeitem,clear,selcount,listcount etc, with a horizontal scroll bar.(List/combo)
61,winnanny.zip
U can use Winnanny to restrict unauthorised people from running programs u don't want them to on your pc .It Uses simple api functions to do this.
62,ReadWriteIni.zip
Creates .ini file, writes to it and reads from it. Demo project shows how to write usernames and passwords. For clarity's sake I made it write user color preferences.
63,capture.zip
This program captures the active window and displays it to a Picture box.
64,TransIco.zip
An update to my previous code : Added a couple of features some ppl asked me for...like the ability to change the text colour of the icon and also keep the background transparent after a desktop refresh.
65,shutdown.zip
Shut Down Windows with Windows Shutdown Dialog.This is the real thing , not Kill , It is a real API Call, I hope you find it useful.
66,alarm.zip
A VB alarm clock.
67,clcViewWinInfo.zip
ViewWinInfo is a windows information viewer. You can use this sample to find or select an open window, and view information about the window, such as its hwnd, size, and parent window.
68,ptinrect.zip
Use the PtInRect API function to create an annoying program.
69,fliphorizvert.zip
Flips a picture using the StretchBlt API function.
70,animation.zip
Use BitBlt to crate flickerless animation

16,467

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧