|
On my Vista (Ultimate) a standard use has read/write permission to both the APPDATA and USERPROFILE directories.
This is a standard install (no modifications made to user rights.
In any event, if the settings are truly "for all users" then a standard user should not be able to modify them. Settings that affect all users should require additional privilege, while settings that affect only the specific user should be allowed (and should be in the USERPROFILE directory.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Are those "per user" locations? If so, the logged on user having write rights to it is a given.
For "per machine" I would think "FOLDERID_ProgramData" would be a good candidate since the users group has "special permissions" to "read/write" but lack the "delete" by default.
|
|
|
|
|
I'm playing with the new mfc features from the mfc update. I have a new wizard-generated application. Somehow the state of the docking panes is stored in the registry (I can find it there) but for the life of me i can't figure out where in the code this functionality is implemented or more importantly how to turn it off. Any ideas?
|
|
|
|
|
To prevent your app from restoring the dockstate, in the constructor for your CMainFrame add:
EnableLoadDockState(FALSE);
|
|
|
|
|
|
CString a("2e3");<br />
double b = atof(a);
do right in VC++6.0 but wrong in VC++2008
CString a("2e3");<br />
double b = _tstof(a);
do right in VC++2008 but wrong in VC++6.0

|
|
|
|
|
It all depends if either _UNICODE or _MBCS are defined. Please check out MSDN for more information on this topic.
Regards,
Mihai Moga
|
|
|
|
|
Thats the TCHAR mapping for atof/_wtof. By default vc2008 defines TCHAR as a native type. You can use it in vc6, you just need to do so explicitly.
|
|
|
|
|
I am trying to figure out how to convert text in a CString to a double. I found this tutorial:
http://www.codeproject.com/KB/string/cstringmgmt.aspx#Converting%20a%20CString%20to%20an%20integer
and it contains this example code for converting to an integer
CString hex = _T("FAB");
CString decimal = _T("4011");
ASSERT(_tcstoul(hex, 0, 16) == _ttoi(decimal));
I don’t even see an integer declared in that fragment, much less how to convert the CString to an integer or decimal.
Here is what I need:
CString source = _T("1.2e6");
double target;
target = source.FormatAsDouble();
Obviously that does not work. But what will?
Thanks for your time
|
|
|
|
|
Rats, I miss typed and the edit did not seem to work.
This is what I want to do:
CString source = _T("1.2e6");
double target;
target = source.FormatAsDouble();
Thanks for your time
|
|
|
|
|
Hi, you should try like this:
CString source = _T("1.2e6");
double target = _tstof( source );
Regards,
Mihai Moga
|
|
|
|
|
I just compiled and ran that code, it works. But you already knew that.
Thank you Mihai.
The string to be converted will be extracted from a user dialog. The user may make an error in entering the number. Is there a method that will validate the string as being properly formatted or in some other way detect an input error to I can tell the user?
Thanks again.
Thanks for your time
|
|
|
|
|
Hi, for this task you should check out Ben Hanson's CFilterEdit[^] class. I use in one of my projects and I am gratefull to the author.
Regards,
Mihai Moga
|
|
|
|
|
RE: CFileterEDit, That class does look good. I downloaded it and the demo.
The file BaseEdit.h contains this reference:
#include <boost/regex.hpp>
This include file in not contained in either of the downloads. BaseEDit.h is the only file containing this include and it has no previous includes that lead me to the file.
Where do I find this file?
Thanks for your time
|
|
|
|
|
In order to recompile that project, you should consider downloading the boost::regex library from Boost's Official Page/[^].
Regards,
Mihai Moga
|
|
|
|
|
Hello Mahai,
I have installed the Boost environment, I have added FloatEdit and BaseEdit to my project, and they will compile. Now I see method
double CFloatEdit::GetValue () const
in file FloatEdit.cpp
But I don't see how to apply it to my dialog box.
One of the fields that I want filtered has the ID:
IDC_X_POSITION_EDIT
and string in the box can be accessed via the variable name as follows:
GBE_x_position_string.GetWindowTextW( str );
That puts the value into CString names str.
Can you tell me how to use this FloatEdit to check the inputs to this field?
Thanks for your time
|
|
|
|
|
Well, FloatEdit will do it for you, it filters data so that you would have a valid floating value/string. It's enought to subclass you CEdit control with this one.
Regards,
Mihai Moga
|
|
|
|
|
Thanks for your reply, but while the documentation tells that than I can use this class to filter the data, I am not able to see how to apply the class to do that. How do I use it?
Given that the text edit tool in my dialog has the id of
IDC_X_POSITION_EDIT
and the assigned variable of
GBE_x_position_string
with example usage: GBE_x_position_string.GetWindowTextW( str );
and variable str containg the string from said edit text tool:
Will you show me the line of code that invokes a method of FloatEdit to
1. validate the string as suitable for converting to float or double
and/or
2. provide the foat or double equvalent.
Thanks for your time
|
|
|
|
|
Hint: atof returns 0.0 whenever the conversion fails.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
But what if the value entered is 0.0. That may well be a valid entry. I could compare the source string with "0.0" to account for that one case, but that just seems ugly.
Thanks for your time
|
|
|
|
|
No it's NOT ugly and it is the way my suggestion pointed to. You have to deal only with 1 case and that's much more simpler than the general validation. Anyway you have to accomplish carefully your task. For instance 0 is a valid entry too (and, depending on your level of user-noise tolerance, also 0.00 , 0.000 ,... are).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello Pallini,
I really do appreciate the time you spent answering my question. But we do disagree on something. Elegant is something like this.
CString source = "1.23e6";
double target;
int status;
status = source.ConvertToFloat( &target );
If atof returns 0.0 in the double variable for an error, this it must also write 0.0 to the variable when the text is 0, or 0.0, or any of several other conditions as you have noted. In this event, either before the convert or after, we must have additonal code to check for any text string that would result in 0.0 to determine if we have an error, or if we really have a 0. Having to writing extra code to do that is indeed downright ugly.
Maybe I have missunderstood you. If so please help me out.
Thanks for your time
|
|
|
|
|
No, you haven't misunderstood me.
I mean atof , returning 0 on error, gives you the support to implement the elegant solution you proposed: it's a starting point.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Unfair vote[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Already balanced, sir.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|