Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Question about wxConfigBase

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Question about wxConfigBase
#3119
Posted by: mooncake 2003-12-25 11:53:54
Is that wxConfigBase save or get records from config.ini which i named the file as config.ini?

But it seems like not.  Then, how the wxConfigBase work?  Where it saves the data to?  Where to get the data from?

Thank you.
Meow~
Message2. Re: Question about wxConfigBase
#3120
Posted by: upCASE 2003-12-25 20:05:12
Hi!
You'll need wxConfigBase since all other config classes are derived from it. Use wxIniConfig for ini files on Windows, or wxFileConfig for UNIX config files (which are similar to ini files).
Include the headers for both classes. Read the API for information on where the files get stored (you can specify a local and a system wide location). Normally system wide should mean something like WIN/SYSTEM on Windows. Be aware that Microsoft advised that one shouldn't use ini files anymore a long time ago and use the registry instead. For platform compatiblitiy I suggest that you choose wxFileConfig, because ini files won't work on UNIX, or to #fidef the things you need. This is what wxWindows does under the hood. Normally it would choose ini files for win 3.1, reg for Win9X/2000/XP and files for UNIX if you use wxConfig (the "normal" wx config class).

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: Question about wxConfigBase
#3121
Posted by: mooncake 2003-12-25 20:17:49
Hi,
   i have not found about wxIniConfig, i just found wxConfigBase... @@"
it seems like wxIniConfig already included in wxConfigBase...
Meow~
Message4. Re: Question about wxConfigBase
#3122
Posted by: upCASE 2003-12-26 03:15:43
Hi!
wxIniConfig is included in wxConfig, not wxConfigBase. wxConfigBase is the main class from which all other classes are derived, while wxConfig is a class that manages the config classes. wxConfig doesn't let you decide what class actually is use. Instead it uses the standard class for the specific platform.

Quoting from the docs:
<wx/config.h> (to let wxWindows choose a wxConfig class for your platform)
<wx/confbase.h> (base config class)
<wx/fileconf.h> (wxFileConfig class)
<wx/msw/regconf.h> (wxRegConfig class)
<wx/msw/iniconf.h> (wxIniConfig class)

So, to use wxIniConfig you'll have to include <wx/confbase.h> and <wx/msw/iniconf.h> and then use an instance of wxIniConfig to work with.
Under Windows using wxConfig it would use wxRegConfig by standard.
As I said, the standard and advised form to use is the registry. But trust me, one can use ini files the way I described it. If it doesn't work out: Post and I'll post a little example using other then the standard config classes.

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message5. Re: Question about wxConfigBase
#3123
Posted by: mooncake 2003-12-26 22:11:37
Hi, but i dont know what is the functions of wxiniconfig, so that i dont know how to call the class and use it...

Could it be said that, use wxConfig this class?

thank you...
Meow~
Message6. Re: Question about wxConfigBase
#3127
Posted by: upCASE 2003-12-27 19:19:58
Hi!
The member fucntions of all wxConfig classes are basically the same since they all derive from wxConfigBase.

A small example

#include <wx/confbase.h>
#include <wx/msw/iniconf.h>
...
...
wxIniConfig *config = new wxIniConfig("Bla","Blabla",".\\Preferences.ini","",wxCONFIG_USE_LOCAL_FILE);
wxString value;
config->SetPath("/SomeSection");
config->Read("MyKey", &value);
wxMessageBox("The value of MyKey in section SomeSection is: "+value);
...
...

Preferences.ini would look like this
[SomeSection]
MyKey=TheValueOfMyKey

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message7. Re: Question about wxConfigBase
#3130
Posted by: mooncake 2003-12-27 19:38:10
Oic... is like that... no wonder...

Thank you Upcase... :)
Meow~
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥1,290.00 ·
 
 
¥918.00 ·
 
 
¥890.00 ·
 
 
¥294.00 ·
 
 
¥430.00 ·
 
 
¥1,380.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0