int readFromIni() {
int isitchecked;
isitchecked = GetPrivateProfileInt("checkbox1", "state", "0", "C:\\myapp\\myapp.ini");
...
and later in that code...
...
if (isitchecked==1) { SendMessage(CheckBox1, BM_SETCHECK, (WPARAM)BST_CHECKED ,(LPARAM)0);
return 0; else { SendMessage(CheckBox1, BM_SETCHECK, (WPARAM)BST_UNCHECKED ,(LPARAM)0); return 0; }
And it works.
Now when a specific button is pressed a function is called to get the state of all controls and set to the ini before the program is closed. I was so sure id be able to:
int writeToIni() {
WritePrivateProfileInt(etc, etc, etc)...
...
}
and i found out that theres no WritePrivateProfileInt function on the Win32API ???
"[Linker error] undefined reference to `WritePrivateProfileInt'"
...
I am about to die :(
Ok, theres a WritePrivateProfileString function but i have declared the vars as ints :( Not chars damned :(
Hey guys, get me outta this trap please :(
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh !#!*&*#!... I think i was not my clear in my last post, i was freaking out here...
The problem is: I need to get integers (0 or 1) from a ini file, and set it to some vars at the start of my app. Working.
After that, i have to set my checkboxes according to this vars. If var=1, CheckBox is checked, and 0 for unchecked. Working too.
I was using GetPrivateProfileInt for it, so of course i have declared ints to hold this values. int checkstate1, checkstate2, checkstate3, etc.
At this point, i should state that on any change of focus in my app, the state of the CheckBoxes is checked and the vars are updated with the control states (1 or 0, checked or unchecked). Working.
Later on my app, when the user clicks to close the app, i would like to save the current Controls state to the INI. My code should read the vars and set it to the INI. And at this point i found out theres no WritePrivateProfileInt but only a WritePrivateProfileString function.
What, a String!? Yes, it sucks :( All my vars are ints :( Then i dont know what to do... I mean, the question here is what would you do?
Any help would be appreciated and sorry if i sounded a little insane in my previous post, i need to get some sleep but the way things are going im gonna loose this job opportunity :\
KennyStress
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have reduced the code to a very simple example with only one control in order to expose my problem in a clearer way.
//char strCB1[2]; //This is declared at main.h
int ini_read() { //This is called from main.c before the controls are created.
GetPrivateProfileString("CheckBox1", "state", "1", strCB1, 2, "C:\\myapp\\myapp.ini");
return 0;
}
int VarsToControls() { //This is called from main.c after the controls are created.
if (strCB1==1) {
MessageBox (NULL, TEXT (strCB1), "strCB1 is equal to 1", MB_ICONERROR);
//Theres code doing stuff here, setting edit fields as enabled/disabled, etc//
}
else {
MessageBox (NULL, TEXT (strCB1), "strCB1 is not equal to 1", MB_ICONERROR);
//Theres code doing stuff here, setting edit fields as enabled/disabled, etc//
}
return 0;
}
Heres the thing: I always get the "strCB1 is not equal to 1" msgBox, and it shows me the value of strCB1 as 1 :(
/Kenny
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My code does things like that:
int readFromIni() {
int isitchecked;
isitchecked = GetPrivateProfileInt("checkbox1", "state", "0", "C:\\myapp\\myapp.ini");
...
and later in that code...
...
if (isitchecked==1) { SendMessage(CheckBox1, BM_SETCHECK, (WPARAM)BST_CHECKED ,(LPARAM)0);
return 0; else { SendMessage(CheckBox1, BM_SETCHECK, (WPARAM)BST_UNCHECKED ,(LPARAM)0); return 0; }
And it works.
Now when a specific button is pressed a function is called to get the state of all controls and set to the ini before the program is closed. I was so sure id be able to:
int writeToIni() {
WritePrivateProfileInt(etc, etc, etc)...
...
}
and i found out that theres no WritePrivateProfileInt function on the Win32API ???
"[Linker error] undefined reference to `WritePrivateProfileInt'"
...
I am about to die :(
Ok, theres a WritePrivateProfileString function but i have declared the vars as ints :( Not chars damned :(
Hey guys, get me outta this trap please :(
Oh !#!*&*#!... I think i was not my clear in my last post, i was freaking out here...
The problem is: I need to get integers (0 or 1) from a ini file, and set it to some vars at the start of my app. Working.
After that, i have to set my checkboxes according to this vars. If var=1, CheckBox is checked, and 0 for unchecked. Working too.
I was using GetPrivateProfileInt for it, so of course i have declared ints to hold this values. int checkstate1, checkstate2, checkstate3, etc.
At this point, i should state that on any change of focus in my app, the state of the CheckBoxes is checked and the vars are updated with the control states (1 or 0, checked or unchecked). Working.
Later on my app, when the user clicks to close the app, i would like to save the current Controls state to the INI. My code should read the vars and set it to the INI. And at this point i found out theres no WritePrivateProfileInt but only a WritePrivateProfileString function.
What, a String!? Yes, it sucks :( All my vars are ints :( Then i dont know what to do... I mean, the question here is what would you do?
Any help would be appreciated and sorry if i sounded a little insane in my previous post, i need to get some sleep but the way things are going im gonna loose this job opportunity :\
KennyStress
I have reduced the code to a very simple example with only one control in order to expose my problem in a clearer way.
//char strCB1[2]; //This is declared at main.h
int ini_read() { //This is called from main.c before the controls are created.
GetPrivateProfileString("CheckBox1", "state", "1", strCB1, 2, "C:\\myapp\\myapp.ini");
return 0;
}
int VarsToControls() { //This is called from main.c after the controls are created.
if (strCB1==1) {
MessageBox (NULL, TEXT (strCB1), "strCB1 is equal to 1", MB_ICONERROR);
//Theres code doing stuff here, setting edit fields as enabled/disabled, etc//
}
else {
MessageBox (NULL, TEXT (strCB1), "strCB1 is not equal to 1", MB_ICONERROR);
//Theres code doing stuff here, setting edit fields as enabled/disabled, etc//
}
return 0;
}
Heres the thing: I always get the "strCB1 is not equal to 1" msgBox, and it shows me the value of strCB1 as 1 :(
/Kenny