|
hi guys,
i have been battling with this code for the last 2 days and i still cant get on top of it. all i want is to save all of the lines that i have in my listbox to a specified ini file. i think i am getting real close but i am getting this one error that i dont know what it means.
if(listBox1->Items->Count>0)<br />
{ <br />
IniFile ^iniFile = gcnew IniFile("C:\\wefne\\ndf");<br />
iniFile->writeSection("Options", "Startfile", "D:\\Sasdsa\\asdas\\__sdfsdf.txt");<br />
<br />
IniFile ^iniFile1 = gcnew IniFile("D:\\Student\\sdfsd\\sds.ini");<br />
for(int i=0; listBox1->Items->Count-1; i++)<br />
{<br />
<br />
<br />
iniFile1->WritePrivateProfileString("Last Variables", "listBox1_Items" + i.ToString(), listBox1->Items[i], L"D:\\Student\\sdfsd\\sds.ini");<br />
}<br />
the error i am getting is error C2039: 'WritePrivateProfileString' : is not a member of 'IniFileHandling::IniFile
i am using Visual Studio Express 2008
thanks in advance
|
|
|
|
|
Yane87 wrote: error C2039: 'WritePrivateProfileString' : is not a member of 'IniFileHandling::IniFile
That message is very clear. The object in your code iniFile1 is of type IniFile and you are attempting to call a method of the class named WritePrivateProfileString which does not exist as a method of that class.
|
|
|
|
|
for(int i=0; listBox1->Items->Count+1; i--)
{
// Get the string contained in each item.
listBox1->GetItemText;
String^ itemString = (String^) listBox1->Items[i];
//String itemString = listBox1->GetItemText( listBox1->Items[i]);
iniFile1->writeSection("Last Variables", "listBox1_Items" ,/*+ i.ToString(), itemString */listBox1->Items[i], );
}
here is some new code that i have, the for loop seems to be fine. but the problem is getting the items from the listbox and converting them to text. then ´gettiing the text and putting it into an ini file.
does anyone have any suggestions? i am not exactly expecting the code done for me, but some tips would be greatly apprectiated. thanks
|
|
|
|
|
It seems likely that you need to obtain a beginner programmers book or enroll at University or something. Trying to learn how to program using internet forums is very unproductive and illogical. Furthermore I would certainly NOT recommend C++/CLI as a beginner language.
|
|
|
|
|
Mate if you dont know the answer to the question just keep your stupid comments to yourself. Or just be man enough to admit it that you dont know the answer. I ended up finding the problem and fixing it anyway, not bad for a beginner ha??
Just for your info I am a University student, and I do have a beginners book. But contrary to what you might think, you cant find the answer to all the questions in a book.
|
|
|
|
|
f*** off a**hole
Yane87 wrote: Mate if you dont know the answer to the question just keep your stupid comments to yourself. Or just be man enough to admit it that you dont know the answer.
> From: Yane87
>
> Mate you are a joke. I do know how to program and I am enrolled at a very good University. I am just stuck on one little problem and I am asking for help just like anyone else on this forum. What gives you the right to go and try to put me down with such comments. If you know the answer to the question I posted answer it, if not just keep your dirty little mouth shut.
modified on Friday, June 26, 2009 10:54 AM
|
|
|
|
|
std::list < xlong > ClientConfig:: GetHistory(int id)
{
....
doing something
....
return 0;
}
When the above code is compailed in VS 2005 (VC++), following is the error
error C2664: 'stlp_std::list<_Tp>::list(const stlp_std::list<_Tp> &)' : cannot convert parameter 1 from 'int' to 'const stlp_std::list<_Tp> &'
with
[
_Tp=xlong
]
Reason: cannot convert from 'int' to 'const stlp_std::list<_Tp>'
with
[
_Tp=xlong
]
Constructor for class 'stlp_std::list<_Tp>' is declared 'explicit'
with
[
_Tp=xlong
]
resdata.cpp
I tried to return xlong value, but still getting the same error
Can any once help to fix the same
|
|
|
|
|
int ClientConfig::GetHistory(int id)
{
... do something...
return 0;
}
|
|
|
|
|
In my CLI program, when I say:
CHAR *Buffer = new CHAR[ 4096 ];
.
strncpy( Buffer, OtherBuffer, 1024 );
.
.
CString Message = Buffer;
the CString cuts off the string after 256 characters.
Why does it do this, and what can I do about it?
|
|
|
|
|
Richard Andrew x64 wrote: Why does it do this, and what can I do about it?
The why is most like dependent on what is in the source buffer. The most obvious guess is that it contains a null byte at 257
|
|
|
|
|
When I put using namespace System::Drawing; into my ref class header file, it says that "'Drawing' is not a member of 'System'"
I have manually added a reference to the System.Drawing.dll , but it still can't find the Drawing namespace.
What could be wrong?
|
|
|
|
|
Nevermind, I rebuilt the project, and now it works.
Seems the problem had to do with the pre-compiled header not being rebuilt.
|
|
|
|
|
Hi, sorry if this has already been answered somewhere, I wasn't able to locate it. I'm trying to dynamically assign one buttons "ButtonClick" event handler to another.
ex: Button2->Click = Button1->Click;
Except I get this error:
error C3918: usage requires 'System::Windows::Forms::Button::Click' to be a data member
I know this means I need to do something like "gcnew EventHandler(this, &Button1_Click);", which is how button 1 is setup, but is there anyway to assign that event dynamically to Button2? Thanks!
|
|
|
|
|
Hi,
My C++/CLI is not fluent, so I'll give you principles only.
All code is dynamic, it runs at run-time. Even the stuff you "design" using Visual Designer gets turned into real code, which sits hidden in some project files (look in your solution pane, there will be files you did not create yourself).
Then, whatever does it for button1 would also do it for button2, just create similar statements; do put them in one of your own files, possibly in your form's constructor, right after the call to InitializeComponents.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Ok, but to setup Button2 like Button1 I would have to hard code the function name which I want to use as the event handler function (eg: Button2->Click += gcnew EventHandler(this, &BUTTON1_EVENT_FUNCTION);) I cannot do this, as I'm trying to set Button2 to whatever the last button used was, so I would like to avoid having to hard code EVERY possible function in some sort of switch statement for Button2. I just want to be able to set its EventHandler in run time.
|
|
|
|
|
TheBerk wrote: I cannot do this, as I'm trying to set Button2 to whatever the last button used was, so I would like to avoid having to hard code EVERY possible function in some sort of switch statement for Button2. I just want to be able to set its EventHandler in run time.
How button 2 is created? Is that created at run time? If you want to attach a event handler at run time, reflection is the way to go. Is that what you are talking about?
|
|
|
|
|
I create the Button2 in the designer just like normal button, and assign its event handler to a default function, but later on in runtime I want to change its even handler based on user interaction (So set Button2->Click to the same thing as Button1-Click). I'm not really sure what reflection is, do you have a link to some thing I can take a look at? Thanks!
|
|
|
|
|
Hi,
IMO you cannot easily copy an event handler reference, however if they are all buttons, you can just remember the last button clicked and then simulate a click for that button again. Here is an example using C#:
Button lastButton=null;
void buton1_Click(object sender, EventArgs e) {
lastButton=sender as Button;
...
}
void buttonRepeat_Click(object sender, EventArgs e) {
if (lastButton!=null) lastButton.PerformClick();
}
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Yeah, that's something I've thought about, but this is something along the development process I'm going to be doing a lot, and I don't want to have to create a whole bunch of hold member variables for each button like this I make. I've made this utility function to take care of assign different buttons, but that event handler is leaving me at a loss.
System::Void vtkview::AssignPrevButton(System::Windows::Forms::Button^ pMainButton, System::Windows::Forms::Button^ pSelectedMenuItem)
{
if(pMainButton->;Text != pSelectedMenuItem->;Text)
{
pMainButton->Text = pSelectedMenuItem->Text;
pMainButton->Image = pSelectedMenuItem->Image;
}
}
Thanks for the help!
|
|
|
|
|
Hi guys, could someone please shed some light on how to delete a single Registry Value but leaving the Key that contains it untouched.
Thanks
|
|
|
|
|
"The following code example shows how to create a subkey under HKEY_CURRENT_USER, manipulate its contents, and then delete the subkey. "
link[^]
|
|
|
|
|
just i want to know how to modify item ans subitem in listview
|
|
|
|
|
wael_r wrote: just i want to know how to modify item ans subitem in listview
We can't make you know anything, you have to learn. So, given the abundance of documentation and sample code freely available on the internet for your subject, what is keeping you from learning this?
|
|
|
|
|
I'm currently doing small programmes in linux enviornment by using g++ compiler.
|
|
|
|
|
have you tried reading? i know i know how ever thought reading would come in handy... but honestly it comes in handy sometimes.
|
|
|
|