Click here to Skip to main content
15,896,269 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to write and save ini files like some apps do with their ini's Pin
ELY M.25-Dec-03 18:04
ELY M.25-Dec-03 18:04 
AnswerRe: how to write and save ini files like some apps do with their ini's Pin
Michael Dunn25-Dec-03 19:12
sitebuilderMichael Dunn25-Dec-03 19:12 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.25-Dec-03 21:24
ELY M.25-Dec-03 21:24 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
shultas26-Dec-03 4:27
shultas26-Dec-03 4:27 
AnswerRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.26-Dec-03 12:49
ELY M.26-Dec-03 12:49 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
shultas26-Dec-03 14:01
shultas26-Dec-03 14:01 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.26-Dec-03 14:44
ELY M.26-Dec-03 14:44 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
shultas26-Dec-03 16:10
shultas26-Dec-03 16:10 
Okay. Gotcha.

What I would do is this. Open up your classview and add a new member to the declaration of your CTESTINI2Dlg.
class CTESTINI2Dlg : public CDialog
{
.......
.......

protected:
HICON m_hIcon;
int topKeyValue; // <------ Add this in there

Then, expand the view for the CTESTINI2Dlg. Double click on the OnInitDialog() method.
Look for the following lines (at the end of this method)

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
topKeyValue = 0; // <----------- Add that in there

Then, double click on your OnAddStrings() method. This should go in there INSTEAD of the for{} loop. Get rid of that loop.

void CTESTINI2Dlg::OnAddstrings()
{
char sIniFile[MAX_PATH];
GetModuleFileName( NULL, sIniFile, MAX_PATH );
strcpy( strrchr( sIniFile, '\\' ) + 1, "strings.ini" );

CEdit* getstring = (CEdit*)GetDlgItem(IDC_EDIT4);
CString putstring;
getstring->GetWindowText(putstring);
CString KeyName;
topKeyValue++;
KeyName.Format("n%ld", topKeyValue);
WritePrivateProfileString("TEST", KeyName, putstring, sIniFile);
MessageBox("Added...");
}

Okay. What this does is add an integer variable to your CTESTINI2Dlg class named topKeyValue. Then, in your OnInitDialog() code, topKeyValue = 0; that is initializing it to 0 when the program starts up. Then, in your OnAddstrings() method, topKeyValue++ increments the member variable by one, formats it in the KeyName.Format string, and writes that number accordingly. Each time you press the add strings button, topKeyValue gets incremented by 1, thus allowing you to write a new line into the file!

So, what are you trying to do, screw with someones MIRC INI files? Wink | ;-)
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.26-Dec-03 18:42
ELY M.26-Dec-03 18:42 
AnswerRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.26-Dec-03 16:01
ELY M.26-Dec-03 16:01 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
shultas26-Dec-03 17:03
shultas26-Dec-03 17:03 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.27-Dec-03 5:22
ELY M.27-Dec-03 5:22 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
shultas28-Dec-03 10:08
shultas28-Dec-03 10:08 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.29-Dec-03 5:01
ELY M.29-Dec-03 5:01 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.29-Dec-03 5:20
ELY M.29-Dec-03 5:20 
GeneralRe: how to write and save ini files like some apps do with their ini's Pin
ELY M.29-Dec-03 6:34
ELY M.29-Dec-03 6:34 
GeneralPostMessage Problem Pin
percyvimal25-Dec-03 18:00
percyvimal25-Dec-03 18:00 
GeneralRe: PostMessage Problem Pin
Monty225-Dec-03 20:39
Monty225-Dec-03 20:39 
GeneralCSingleLock Pin
Anonymous25-Dec-03 17:10
Anonymous25-Dec-03 17:10 
GeneralRe: CSingleLock Pin
Michael Dunn25-Dec-03 19:15
sitebuilderMichael Dunn25-Dec-03 19:15 
GeneralRe: CSingleLock Pin
Anonymous25-Dec-03 20:30
Anonymous25-Dec-03 20:30 
Questiondifference between ATL, MFC, and .NET Common Class? Pin
torrentmoon25-Dec-03 14:45
torrentmoon25-Dec-03 14:45 
AnswerRe: difference between ATL, MFC, and .NET Common Class? Pin
peterchen25-Dec-03 23:38
peterchen25-Dec-03 23:38 
GeneralRe: difference between ATL, MFC, and .NET Common Class? Pin
torrentmoon25-Dec-03 23:55
torrentmoon25-Dec-03 23:55 
GeneralRe: difference between ATL, MFC, and .NET Common Class? Pin
Jörgen Sigvardsson26-Dec-03 6:10
Jörgen Sigvardsson26-Dec-03 6:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.