|
If you're using MFC, look up EnableMenuItem in the CMenu class documentation.
If you're not using MFC, just look up EnableMenuItem.
Jason Henderson "I can picture in my mind a world without war, a world without hate. And I can picture us attacking that world, because they'd never expect it."
- Jack Handey
|
|
|
|
|
Hi Jason,
I don't have MSDN installed on this computer, I only remember off the top of my head its something like :
EnableMenuItem((i think its the menuID?), Flags);
Can you or someone shed some light to get this done with MFC?
Thank you for your help!
|
|
|
|
|
Jay Hova wrote:
don't have MSDN installed on this computer
You can find it online at msdn.microsoft.com[^].
It is the one most valuable resource you need as a programmer. BTW - Your compiler came with a copy of MSDN.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
BOOL EnableMenuItem(
HMENU hMenu, // handle to menu
UINT uIDEnableItem, // menu item to update
UINT uEnable // options
);
or
// MFC CMenu
UINT EnableMenuItem(
UINT nIDEnableItem,
UINT nEnable
);
Jason Henderson "I can picture in my mind a world without war, a world without hate. And I can picture us attacking that world, because they'd never expect it."
- Jack Handey
|
|
|
|
|
I have only been programming for a month, so please be patient.
right now i am using the code i found on the msdn.microsoft.com site
CMenu* mmenu = GetMenu();<br />
CMenu* submenu = mmenu->GetSubMenu(0);<br />
submenu->EnableMenuItem(ID_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
I get the error that GetMenu doesn't take 0 parameters?
Can someone tell me whats wrong. I used similar code if not the same, to get a couple other menu options checked/unchecked and it worked fine. Don't understand why it doesn't work.
Oh yeah, I have no idea why msdn is not installed on this computer? its not my own.
|
|
|
|
|
You are mixing CWnd::GetMenu/CWindow::GetMenu and ::GetMenu
Win API: HMENU GetMenu( HWND hWnd );
From your mainframe class try calling GetMenu()...
Brian
|
|
|
|
|
I am calling this from my main class...
I don't get it. I have almost the same exact code right beneath it and it works. (this is the code that checks the menu options)
Thanks for helping
|
|
|
|
|
Hi,
I have a dynamically created ListBox in my MFC app.
After selecting a Item and Pressing Enter key, In the PreTranslateMessage() routine i try to get the GetCurSel()
But the index returned is -1.Pls help in this regard.
Thnks in advance
Ram
|
|
|
|
|
One possible reason is that windows calls PreTranslateMessage() before updating the control.
Kuphryn
|
|
|
|
|
Hi everyone!
I'm searching for source code of the video codec (h.263 compatible).
...actually i found one OpenMash project, but i don't know how to use their codec in VC++ application
If anybody know some sources & examples of video compression/decompression
source etc. please give me know
Pawel Olszewski (pandora_@wp.pl)
|
|
|
|
|
I have a program that needs to open and close and open and close several modal dialgos one after the other.
My first modal dialog goes great, but when I call the second one's doModal, it immediately closes.
I bet this is somehow related to a WM_QUIT remaining in the message-queue or something like that, but I can't really put my finger on it.
Can someone help ?
Thanks
|
|
|
|
|
Some more investigation brough up this solution:
After the first (and any other doModal()), do:
while (PumpMessage()) {};
AfxGetThreadState()->m_nDisablePumpCount--;
this will eat all messages up to and including the WM_QUIT (which increases m_nDisablePumpCount), we then ammend this counter and continue. (This counter is what causes the abrupt closure of any window to attempt and open.
Is there a cleaner solution (except for overriding PumpMessage and handling things different from inside there) ?
|
|
|
|
|
Read MSDN article Q138681.
|
|
|
|
|
Hi All,
I Need Help Regarding The Storing of Data in ASCII format
How To store TEXT Data in ASCII Format and In which Format
Ascii Data to be Stored
and What are The Precautions to Be Taken Storing The Data
In ASCII Format.
Thanks In Advance
|
|
|
|
|
|
One down side to storing data in plain ASCII is that it's readable using a simple text editor like Notepad.
Another limitation is that you're limited to the ASCII set of characters, which means if you want to store binary data, you'll need to convert it to ASCII (which causes a 2x increase in size) before storing it.
If you're looking for a general article on serializing data, you might find this set[^] of articles helpful.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Check out CStdioFile, it will do what you want.
Also you can use regular C++ iostreams (e.g., ifstream and ofstream) to be more "standard" or if you aren't using MFC. MSDN has docs for all of these.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Does anyone know if there is a STL algo to remove duplicate items in a vector?
I have a vector of string values that I would like to make unique. The vector will eventually be sorted. Is there a quick stl way of doing this?
On a similar not, I tried using std::set to filter duplicate strings, but I found this to be extremely slow.
I Dream of Absolute Zero
|
|
|
|
|
There is no faster way of doing this because if you think about it you have to check the string does not exist yet. Set is pretty much the fastest way of doing that unless you want to use a hash table. Yes, there is a hash table in some versions of the stl.
If you say the vector will then be sorted, you were right to use set in the first place.
|
|
|
|
|
cheers for that, dude.
I Dream of Absolute Zero
|
|
|
|
|
Is this the type of thing you want? Especially if sorting may be required
sort(source.begin(),source.end());
unique_copy(source.begin(),source.end(),back_inserter(dest));
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Can't you check for duplicates as the items are added?
|
|
|
|
|
DavidCrow wrote:
Can't you check for duplicates as the items are added?
Thats why I was using the std::set as it only allows unique entries, but it was very slow on the insertions.
Having read the above replies, I may not have a choice on the performance and may have to stick with a set instead of buffering in a vector and then removing dups.
I Dream of Absolute Zero
|
|
|
|
|
That is what set does, except it does it in an efficient way.
|
|
|
|
|
RChin wrote:
On a similar not, I tried using std::set to filter duplicate strings, but I found this to be extremely slow.
You may find that using std::hash_set instead of std::set will be faster for storing strings, provided you have a good hash function.
- Mike
|
|
|
|