|
When I press on a menu item, I want its text that says "Search" to change to "Start". Is this a very trivial question?
I tried:
void CFormViewMDIView::OnChecking()
{
GetDlgItem(ID_CHECKING)->SetWindowText("abc");
}
where the ID of the menu item is ID_CHECKING, but it crashed. AM i on the right track? WHat am I doing wrong?
? thanks,
ns
|
|
|
|
|
|
I tried the MSDN sample code. It works. I couldnt implement
// Look for "Open" menu item from the File menu. Insert a new
// menu item called "Close" right after the "Open" menu item.
// ID_CLOSEFILE is the command id for the "Close" menu item.
pos = FindMenuItem(submenu, "&Open...\tCtrl+O");
if (pos > -1)
submenu->InsertMenu(pos + 1, MF_BYPOSITION, ID_CLOSEFILE, "&Close");
because if its a new menu item, then how do you specify ID_CLOSEFILE? I have only seen a way to name a menu iD through the propertiesd window, in which case the menu item is already on the menu. SO I am puzzled greatly.
The other question is:
I want to change the title of the toplevel menu, not a submenu. I tried:
CMenu* mmenu = GetMenu();
// Look for "File" menu.
int pos = FindMenuItem(mmenu, "&File");
if (pos == -1)
return;
UINT id = GetMenuItemID(pos);
ModifyMenu(id, MF_BYCOMMAND, id, "&Save Selection");
but errors in compile. Besides for a toplevel item, id = -1.
Hwo do I modify this to get the correct behavior?
Thanks,
ns
|
|
|
|
|
To change the titlew of the toplevel menu I tried:
CMenu* mmenu = GetMenu();
mmenu->ModifyMenu(ID_CHECKING, MF_BYCOMMAND, 0, " Selection");
Invalidate();
On the second press of the ID_CHECKING menu item, the caption changes to Selection" but part of the old (longer) caption remains painted on the screen. Also it looks like the new caption is on a totally new button. I made an educated guess at the parameters
Also tried mmenu->ModifyMenu(ID_CHECKING, MF_BYCOMMAND,ID_CHECKING, " Selection");
but same peculiar result. Helpp!!!
Thank you in advance,
ns
|
|
|
|
|
I'm writting code which fills up a character array with numeric values which will later be converted in to character values for use with an encryption function. The problem I'm having is that the array values do not seem to be making it into the array, and I'm pulling my hair out trying to figure what's going wrong. Source Code Follows
int nElementCount = 0;
int nElementValue = 0;
char szStringArray[] = "\0";
while ( nElementCount < 255 )
{
szStringArray[nElementCount] = nElementValue;
nElementCount++;
nElementValue++;
}
MessageBox(NULL, szStringArray, "Debug Message", MB_OK);
As can see the code is pretty straight forward, but I just seem to not be able to get values into the array. It's probably something simple that I'm missing due to newbie-itis. If someone could point out what's wrong with my code and how to fix it, I'd appreciate it.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now...
[Shog9 on Kid Programmers]
|
|
|
|
|
|
Sorry for the prev reply, but I just watched ugggh Event Horizon on TV [roughly 40% of the latter 60%] and am still not fully normal yet
John Aldrich wrote:
char szStringArray[] = "\0";
Change that to :-
char szStringArray[256] ;
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Just made that change. My dubug statement is still showing no values in the array. is there another check I can do to see if there actually are values?
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now...
[Shog9 on Kid Programmers]
|
|
|
|
|
John Aldrich wrote:
Just made that change. My dubug statement is still showing no values in the array. is there another check I can do to see if there actually are values?
That's because nElementValue is initially 0 and you assign it as the first value of your array. Strings are 0-terminated. Thus your MessageBox won't come up because it sees a null string. Start with nElementValue = 32. 32 is space and 32 upwards is legal characters and stop at 127. otherwise you have all kinds of funny control chasracters which might end up as boxes in the text on screen or might have other bad side effects.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Hi All!
How do you get/set the checked state of an item in a menu?
thx!
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
|
Can you give example on use?
thx.
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
|
do u know what functions or MFC classes are used for sending email and what platform or special servers or software are needed to support them as min required?
includeh10
|
|
|
|
|
|
|
A quick question for the STL gurus...
I've got a std::list, where the only insertion method is push_back(). I'd like the inserts to be as fast as possible. Is it worth keeping an iterator to the end of the list and using insert( end_it, foo ), or would it be just as fast, or faster, to simply use push_back( foo )?
I'm guessing that the list is optimised so that a call to push_back doesn't involve trawling through the entire list to find the end, but I thought I'd better check.
Oh, and I'm using the STL supplied with VS 6 SP5
TIA,
Pete
|
|
|
|
|
Member functions of container are almost always either optimized or does not exists at all.
For that reason, a vector, for example, only have push_back and not push_front as it would not be efficient (would have to copy every items, every time with typical implementation).
A function that may not be optimized in some implementation is size for a list. This is the reason why empty member function should be used when we only want to knows if a STL container is empty (as this will be optimal for any container on any implementation).
Philippe Mori
|
|
|
|
|
moredip wrote:
Is it worth keeping an iterator to the end of the list and using insert( end_it, foo ),
Probably not. Perhaps you could shave off a few CPU cycles, but that's it.
or would it be just as fast, or faster, to simply use push_back( foo )?
Since any list insertion is O(1) and end() is also O(1) for a list, I think you know the answer.
|
|
|
|
|
Ok, that's what I thought.
Thanks chaps!
|
|
|
|
|
I'd say that keeping the iterator is slightly faster (one level of indirection less.) A quick look at the source code for std::list should let you know.
If you allow me to do a little advertising, my block allocator can prove useful in improving the performance of your code.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
what functions are used for:
1. create short cut file from original one?
2. update a dll file which is being used by system or other apps?
includeh10
|
|
|
|
|
1. Several of them. PJ Naughter has already done the work of bundling all the stuff into his CShellLink & CUrlShellLink v1.1.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thank u.
i downloaded the code and had a simple look.
actually i created a similar class myself last year from com interface.
i really don't understand why microsoft doesn't offer native c function to user, instead offer COM!
i use COM for several years, i really hate it!
C++ is not VB, we don't want to be silly.
includeh10
|
|
|
|
|