|
The problem has to do with the modified flag inside your document being set somehow. Read up on SetModifiedFlag, IsModified, and SaveModified.
It seems to me like the quickest solution is just to override SaveModified in your CDocument-derived class and make it return TRUE:
BOOL CYourDocument::SaveModified()
{
return TRUE;
}
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Works perfect, Thanks to both of you!
|
|
|
|
|
hi all,
I'm trying to do an strcmp() with a REG_SZ value.
I'm loading the REG_SZ into an unsigned char[] like this:-
unsigned char lpstrValueData[MAX_PATH];
dwRegStatus=RegQueryValueEx(hKey, "DisplayName", NULL, &dwType, static_cast<LPBYTE>(lpstrValueData), &dwcbData);
then, i want to compare it with a string...
strcmp(lpstrValueData, "MyString");
Perhaps obviously, this doesn't work becuase:-
error C2664: 'strcmp' : cannot convert parameter 1 from 'unsigned char [260]' to 'const char *'
so, i try this instead:-
strcmp( static_cast<const char *>(lpstrValueData), "MyString");
but this doesn't work either:-
error C2440: 'static_cast' : cannot convert from 'unsigned char [260]' to 'const char *'
which is wierding me out. A nasty C style cast like this works:-
strcmp( (const char *) lpstrValueData, "MyString");
so why doesn't static_cast like it?
The expression static_cast < type-id > ( expression ) converts expression to the type of type-id based solely on the types present in the expression. No run-time type check is made to ensure the safety of the conversion.
help!
#include <beer.h>
|
|
|
|
|
If you don't like the C cast syntax, you can resort to reinterpret_cast (which is basically the same). I sort of agree with you that static_cast whould be allowed here, but alas C++ rules are the way they are.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks Joaquín!
#include <beer.h>
|
|
|
|
|
Not too shocking since they are two totally different types.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
static_cast is a compiler time casting operator that insures type safety. So nothing is done at runtime when you use the static_cast.
reinterpret_cast is more like the C-style cast. It basically says that you are going to take responsibility for the casting that is done, and there is no type-safety checking performed with this cast.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Doesn't that depend on the type of casting performed?
E.g. Take the following C lines:
myInt = (int)myFloat;<br />
myCharPtr = (char *)myVoidPtr;
I would use static_cast for the first one, and reinterpret_cast for the second one.
If I would use
myInt = reinterpret_cast<int>myFloat; wouldn't that cause the compiler to intepret the bit-pattern of myFloat as the bit-pattern of an int, causing garbage to be assigned to myInt?
That leaves me with the other two casts:
const_cast: for casting way the const (wouldn't volatile_cast be a better name?)
dynamic_cast: for casting instance-pointers from one type to another, checking dynamically whether it is the correct type or not.
<marquee>Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
I have this weird problem where a call to CReBar::AddBar() crashes my
program.
This only happens in VC++ .Net in Release mode. If I run the code from the
debugger (F5) it doesn't happen. If I compile a debug version of the code it
doesn't happen either.
So basically I get a crash every time I compile a release build and I
execute the program from outside the debugger.
As you can imagine, I'm having a very hard time debugging this!
Has anyone seen this problem before? Any idea what might be causing this?
Any suggestion/idea is welcome. Thank you.
|
|
|
|
|
Anyone knows where can i remove those custom ie toolbars installed by other programs?? Is it somewhere in the registry?
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
|
Search MSDN for the following (all as 1 string):
tutorial custom toolbar buttons internet explorer bar
then select the article titled "Adding toolbar buttons" in the internet explorer SDK - this will tell you how to add & remove toolbar buttons from IE...
"No one goes to hell because of their sin, but because of rejecting God's method of salvation: His Son's life for yours..."
"It does not take a majority to prevail ... but rather an irate, tireless minority, keen on setting brushfires of freedom in the minds of men." --Samuel Adams
|
|
|
|
|
I'm trying to program a timer in MFC/C++ and I'm having trouble with my start-button. When I push the start-button it is supposed to call a function that reads the time (hour, minute, second) as a string and the start the countdown (which also should be seen on the screen) by seconds.
Is there someone who can give me an idea of how this would look like?
Thanks!;)
MFC beginner
|
|
|
|
|
|
One solution is to add a message handler for the button. Call the timer function inside that button handler.
Kuphryn
|
|
|
|
|
How to use RASENTRY to setup the entry to dial both the channels of ISDN. I want my dialer to dial both channels of ISDN after creating the Entry.
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Hi!
I am writing a custom edit control:
class MyEdit : public CWnd {
....
};
void MyEdit::OnKeyDown(UINT ch, UINT flags)
{
CString text;
GetWindowText(text);
text += (TCHAR)ch;
SetWindowText(text);
Invalidate();
}
The problem is: What I got is not conformed to what is expected and a beep every input char.
e.g: [Keyboard]-->[Result]
a A
F4 s
What happend? How could I solve it?
Thanks,
Sovann.
Why waste time learning while ignorence is instantaneous ? [Hobbes]
|
|
|
|
|
the UINT ch being passed in isn't an ascii value, it's a virtual key code.
Open up WinUser.h and find the line
#ifndef NOVIRTUALKEYCODES (line 316 here)
all the codes are defined there. It looks like you'll have to make your own conversion function
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
The first parameter of OnKeyDown is a virtual-key code, not an ascii code. You will need to translate the virtual-key into the character you typed.
Jason Henderson start page ; articles
henderson is coming
henderson is an opponent's worst nightmare
* googlism *
|
|
|
|
|
funny echo in here
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Hi all,
Maybe this question should not be posted here, but considering your experience, i´m sure to get helped here ;);)
My question is if there is any way to override the default criteria of windows 2000 Password Police "Passwords must meet complexity requirements" ???
I have already done this under Windows NT 4.0, by creating my own Passfilt.dll, but under Windows 2000 this criteria seems to be moved into some of the operating system components, so after installing my Passfilt.dll, the achieved result is just a COMPLEMENT of the default criteria, not an OVERRIDE.
Thank you in advance.
|
|
|
|
|
You can modify password options from the "Local Security Settings" control panel applet ( in control panel -> Administrative tools )
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Ok,
Maybe i couldn't make me clear. I really intend to use this policy, but with my own criteria !!! Because in my scenario the default criteria is TOO restrictive, see :
- Passwords may not contain your user name or any part of your full name.
- Passwords must be at least six characters long.
- Passwords must contain elements from three of the four following types of characters :
English upper case letters, English lower case letters,
Westernized Arabic numerals, Non-alphanumeric characters (special characters).
Once i don't need all of this complexity, i'd like to completely redefine this criteria by myself.
This could be implemented trought a Password Filter, wich is a .DLL that provides password policy enforcement and change notification. So once created and properly installed, my PassFilt.dll whould be an OVERRIDE to the above criteria, that was implemented by the original Passfilt.dll (distributed with SP2). Under NT 4.0, i have already done this, and it functions !!!
But in Win2k, when passwords are changed, LSA call my .DLL, but either uses the default criteria, wich now implemented "i don't know where" causing it to be more restrictive yet. (
Anyway thank you for the reply ;);)
?
|
|
|
|
|
hey i want to change the text in my tabctrl by getting the text there already and changing it. i was trying something like:
TCITEM item;
int index;
CString newText;
if (m_tabView.GetItem(i, &item)) {
CString tabText = item.pszText;
// some mods to the title
}
but it always crashes, and running in debug mode, which i know not alot about, i see that item.pszText is a bad ptr, and the CString, so why dooes this work? what am i doing wrong.
thanks,
luke.
|
|
|
|
|
You have to set the item.mask values to specify which items about the tab you want to get. Set the mask first and it should return the correct values for you.
item.mask = TCIF_TEXT;
This is from memory, so may not be 100%
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|
thanks, now i have
for (int i=0; i<4; i++) {
if (m_tabView.GetItem(i, &item)) {
CString blah = item.pszText;
AfxMessageBox(item.pszText);
and in release mode it brings up the right text for the first 2 tabs, then crashes, and in debug mode it doesn't even get into the if statement. and i have set item.mask = TCIF_TEXT;
but i'm not sure why it crashes after 2 in release mode(i have 4 tabs) and doesn't get into the if statement in debug. anyone?
thanks,
luke.
|
|
|
|