|
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.
|
|
|
|
|
I don't understand. can you give example?
codez would be appreciated very much.
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.
|
|
|
|
|
Luc Pattyn wrote: codez would be appreciated very much.
You don't need codez to read anymore, you just need one of these[^]
|
|
|
|
|
Hmm. I don't think I like that very much, reminds me of doctor Black, who got murdered in the library with the kindlestack.
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.
|
|
|
|
|
Thanks, now I have to clean coffee off my monitor.
|
|
|
|
|
What? you can't take a little joke without a joke icon warning you beforehand?
You'd better read some MSDN stuff then.
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.
|
|
|
|
|
We don't get the joke icon in the email! And they call you an MVP!
|
|
|
|
|
Sorry, let me help[^].
If need be, ask Google for help.
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.
|
|
|
|
|
i haz codez
<br />
<br />
Eyes->Init(OPEN);<br />
Eyes->SetTarget(WORD* tehWords);<br />
<br />
while(Knowledge <= 0)<br />
{<br />
Eyes->Read(tehWords++);<br />
}<br />
<br />
|
|
|
|