|
why ? just one number, I'd use the registry. One number lots of different ways, use CFile or Serialisation. Plenty of examples on the site. I'd offer one, but I'm holding a baby....
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
.. I'd use the registry
Why? The registry is already filled with unnecessary crap The bigger the registry, the slower Windows. I see a lot of applications do this. The application I'm currently working on, saves as little as possible in the registry. Ofcourse, you should write something there, but try to keep it as low and small as possible.
Your second suggestion seems very good to me. Use a CFile (CArchive) combined with Serialisation sounds really good, although it's a little overkill for one value.
I think CStdioFile is a good option here, as well as writing those values in a .ini file. See GetPrivateProfileString/GetPrivateProfileInt and WritePrivateProfileString/GetPrivateProfileInt.
Goodluck!
--
Alex Marbus
|
|
|
|
|
It depends. The only reason I could think to save *one* number is in order to remember a setting, like what mode the program is in. The registry is the 'correct' place to store such information.
It *IS* overkill to serialise one value. But I am guessing a likely reason for the project being asked about is to learn how it is done, hence I tried to point out some methods that would be useful for the sake of learning and not just the example. CStdioFile is another good suggestion here.
As for an .ini file, all the entries in the MSDN state clearly that these functions remain for reverse compatibilty only. .ini files are bare to even the most inexperienced user ,and basically suck. Just my opinion.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
The only reason I could think to save *one* number is in order to remember a setting, like what mode the program is in. The registry is the 'correct' place to store such information.
You are absolutely right, remembering a setting is a correct thing to do in the registry. From what I've understood from the original message, it's 'just a value', like an age or something.
As for an .ini file, all the entries in the MSDN state clearly that these functions remain for reverse compatibilty only
Oops, you're right Must have missed that one. Thanks for pointing me to that small, single line in the MSDN library Actually too bad the MSDN library only talks about other registry-related functions in this topic, and doesn't have a link to CFile, or just a general information-page that tells a littl' something about saving to memory, file and/or registry; when to use what.
--
Alex Marbus
|
|
|
|
|
Well the thing i would like to make was, a save and a load function like the ones in a text program (Word)
I dont really know where to start, i need som tutorials on this one.
And no, i dont just want to save one number it was only an example
thank
|
|
|
|
|
Hi,
I am using Stingray Objective Grid ver 7.0 for implementing Grid features in my VC++ application. I am using CGXSpinEdit class for implementing spin control feature in the Grid. The problem is that the spin buttons of a spin control cell are visible only if that cell is the current cell (Cell that has the focus). The moment the focus moves from the spin control cell, the spin buttons disappear and re-appear when focus is brought back to the cell. Is there any way in which the spin buttons can be made always visible??
Thanks,
Unni
|
|
|
|
|
I want to intercept the OnKeyDown event. But I can't get the nChar converted to a String like: "R", or something else. Does anyone now how to handle this?
Thanks in advance.
CString Dutch = "Double Dutch";
CString C = Dutch;
|
|
|
|
|
CString str;
str.Format("%c", nChar);
Phew that was exhausting...
|
|
|
|
|
I have created a Wizard inside a dialog WS_CHILD | WS_VISIBLE | WS_TABSTOP,
and what I've found is that I cant access the other controls placed inside the dialog and outside the wizard.
Could you tell me how to avoid this?
Thank you in advance.
|
|
|
|
|
Actually, in the parent dialog you should know as little as possible from the child dialogs. In the same way, in the child dialogs, you should know as little as possible from your parent dialog, except the fact that it is a CWnd-derived class.
When you need to have access on the controls on the parent-dialog, you are not developing object-oriented.. which is your own choice ofcourse
Maybe a better (read: more OO) way is to define a custom message (Let's say WM_DO_SUMPIN), send a message to your parent, and let him(/her?) do whatever is necessary.
#define WM_DO_SUMPIN WM_USER + 15 // Just some value
GetParent()->SendMessage(WM_DO_SUMPIN, wParam, lParam);
(In the parent's class: )
ON_MESSAGE(WM_DO_SUMPIN, SomeFunction);
void CParentClass::SomeFunction(WPARAM wParam, LPARAM lParam)
{
// We should do sumpin' here..
}
.. or do some good thinking why you actually want to do something with that control.
--
Alex Marbus
|
|
|
|
|
I have used the Spy++ and get a numerical id (the 78) and I want to know wich message is it, could you explain me how to do it?
Thank you very much.
|
|
|
|
|
Look in the Windows.h file,
78 = 0x004E which happens to be WM_NOTIFY.
|
|
|
|
|
I'm a novice, but I've taken a look at this file and I can't see nothing related to WM_NOTIFY, could you give me more info please?
thank you in advance.
|
|
|
|
|
Sorry I misinformed you WINUSER.H, my apologies.
Norm
|
|
|
|
|
Thank you very much! you has helped me a lot, this is very important in order to be more productive...
|
|
|
|
|
If you don't know exactly where to look, you could also type the name in the VC editor, in this case WM_NOTIFY, rightclick on it, and select "Go to definition of..".
You'll see where it's defined, and the actual value of it.
--
Alex Marbus
|
|
|
|
|
You can also look it up in VC if you're debugging. In the Watch window, enter "78,wm" (or whatever number) and VC will display the corresponding WM_* symbol.
--Mike--
http://home.inreach.com/mdunn/
Is history an illusion caused by the passage of time, or is time an illusion caused by the passage of history?
|
|
|
|
|
I am working on a game, and I want it to have network play capabilities,
LAN preferrably and without the MFC. It's a very small game, so it shouldn't be to advanced to implement. Does anybody have any idea how I can do this? I have never done a network game before.
Thanks in advance.
Erik
|
|
|
|
|
Good book to start with is the "Winsock 2.0 Programming" by Lewis Napper - Highly Recommended.
If there are more than 2 players, I would recommend client-server. Where the clients connect to a running server app. You could use Winsock API direct or use the MFC wrapper classes (CAsyncSocket & CSocket).
Another strategy would to use DCOM and connection points, here you could start with Professional ATL Programming by Richard Grimes - Good book.
If could be even possible with SOAP, I don't have even knowledge to advise you on this one.
Look around on this site in the Internet Section also look in www.codeguru.com.
Good Luck
|
|
|
|
|
Hi all,
I am writing an MFC app for my friend who finds it hard to open the CD ROM drive by pressing the buttons on the CD-DRIVE.
He has 3 drives, and I want individual ones to open by pressing the button Open.
Can I do this?
How?
Thanks
Ashman
PS: Please be detailed, Im rather dumb =)
|
|
|
|
|
You need to use the media control interface (MCI).
You can send strings or commands to the MCI to get things done.
Set CDAudio Door Open
Set CDAudio Door Close
I don't know how to address more than one CD this way.
Its different using the command API rather than the string API.
see also Microsoft knowledge base article: Q109371
Stephen
|
|
|
|
|
-Enter and ESC keys close the dialog how i can stop it .
-How i can load accelerator from resource to MFC\DIALOG
i use loadaccelerator function but it didn't work.
thank you ...
|
|
|
|
|
The best way is to try a keyboard Hook. That we you are totally in control of what's hapenning.
|
|
|
|
|
You stop it by overriding OnOK and OnCancel. You can make the buttons still work by checking the keystate with GetKeyState(VK_RETURN) (or VK_ESCAPE) and returning if they are down. Then your button works, but the key does not.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hi,
I have structure that looks similar to this:
struct MyInfo
{
CString m_str1;
CString m_str2;
COleDateTime m_dtm1;
CString m_str3;
MyInfo(const CString& str1, const CString& str2, const COleDateTime& dtm1, const CString& str3) :
m_str1(str1), m_str2(str2), m_dtm1(dtm1), m_str3(str3)
{ }
bool operator<(const MyInfo& info)
{
return (m_str1 < info.m_str1 ||
m_str2 < info.m_str2 ||
m_dtm1 < info.m_dtm1 ||
m_str3 < info.m_str3);
}
};
I have a map of MyInfo to CString values, like this:
std::map< MyInfo, CString > mapInfo;
I insert/update elements into the map using operator[], like this:
void accumulate(const CString& str1, const CString& str2, const COleDateTime& dtm1, const CString& str3, const CString& strValue)
{
mapInfo[MyInfo(str1, str2, dtm1, str3)] += strValue;
}
Notice that strValue is appended to whatever is already there.
Then later I iterate through every element in the map, but the problem is that I'm getting duplicate entries in the map (for the same MyInfo object). Why?
Thanks,
Alvaro
|
|
|
|