|
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 />
|
|
|
|
|
without some serious side-effects from Read() to Knowledge, that loop may never terminate...
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.
|
|
|
|
|
Hi There !!!
Let's find someone who could help me on this problem.
I have created on VS2005 under Windows Vista a new Visual C++ ATL Server Web Service Project with:
Blob Cache
Session Services (Memory-backed session-state service)
I compiled the project sucessfully. Then, i opened IExplorer and access de URL to generate the WSDL.
The WSDL of the web service was generated with sucsess.
This is my problem:
With this simple and basic project, i changed the configuration properties to support Common Language Runtime Suport, Old Syntax (/clr:oldSyntax)
The compilation of the project was made successfully.
The problem was when i go to access the web service to generate the WSDL via web browser.
I access the URL (something like: http://localhost/ATLWS1/ATLWS1.dll?Handler=GenATLWS1WSDL) on IExplorer, and the web browser hangs and no result is returned.
Just a page indicating that "Internet Explorer cannot display the webpage".
There some dependency or configuration missing to support CLR ?? I tried the same scenario on Windows XP and this works fine.
|
|
|
|
|
Full question: Should every class have one or more interface base classes which are the only means of accessing that class?
Yes would be my answer! My opinion is that no class should ever keep a direct reference to any other class, they should only ever use interfaces, but I'm having trouble persuading some of my colleagues that this is useful.
Does anyone have a link to a persuasive coding standards style document that explains why this is a good idea?
Does anyone disagree with this opinion?
|
|
|
|
|
LetsMond wrote: Does anyone disagree with this opinion?
Yes, I do. It is in direct conflict with the KISS Principle[^]
That said, I have certainly utilized that type of design to guarantee proper use of an object. You just need to make sure it is required rather than just being an opinion.
|
|
|
|
|
I disagree that following this approach makes things more complicated. You will end up with more code but, looking at any individual class, it makes it much simpler and easier to work out what's going on if you can assume that it will only access other classes via the interfaces it holds and that it will only be accessed via the interfaces it supports.
|
|
|
|