How to override wxProcess::OnTerminate - events

How can i override wxProcess::OnTerminate function to receive events about process teminating with wxWidgets?
I tried to create class overriding wxProcess and function OnTerminate, but there is no events about it.
How can i override it?
Thanks!

You can either override OnTerminate() in your derived class or handle EVT_PROCESS event. The two are exclusive, i.e. if you override the method you won't get the event. And if you just want to handle the event, there is no need to override anything.

Related

Processing child Control Events in Windows Forms Components in C++

I am a noob to Windows Forms so this is likely a remedial question. I have a child component with a button and a text field. I want to use multiple instances of these in a parent component or form. At runtime, when the user clicks one of the buttons, I want the parent to get the event to decide what to do with the associated text.
Coming from the long lost world of Borland C++ Builder, during design time, I would simply double-click on the buttons and handlers in the parent would be created which I could just elaborate the code. With Windows Forms, the component controls are not clickable (at design time) from the parent and are "frozen". It is not obvious to me how to pass any child button clicks to a parent. I've tried things like changing the button modifier from private to public but that doesn't help. How is this best accomplished.
Note I am using C++ as I am sharing header file definitions with an associated C++ embedded app.
-Bob
UPDATE:
My apologies, I thought I was still in my C# search :(
This is slightly complicated if you actually want to bubble up an event, or very easy if you use methods.
Methods:
In your child container, add a constructor or property that takes in and stores the parent. Then in the button handler, call this.Parent.ButtonClicked(this); and of course in the parent, add a ButtonClicked(ChildType child) method. That should get you there that way.
Custom Event:
To use events, you need to add a few things. Firstly, add a custom EventArgs class as such:
class ChildClickedEventArgs : EventArgs
{
// include a ctor and property to store and retrieve the child instance.
}
Then add a public delegate for it:
public delegate void ChildClickedEventHandler(object sender, ChildClickedEventArgs e);
Then to your child class, add a ButtonClicked event:
public event ChildClickedEventHandler ChildClicked;
And finally, a helper method to raise it:
private OnButtonClicked()
{
if (this.ChildClicked != null)
{
this.ChildClicked(this, new ChildClickedEventArgs(this));
}
}
Then when you add the child class to the parent, add an event handler for each, and you can handle your custom event for your custom control.
Alternatively:
If you can expose the Button in your child class, simply do the above but register it to this.child.Button.Clicked, saving adding the event handler yourself.

Catching pressing "Back" button in mvvmlight

How can i move
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
to the viewmodel and still be able to control "back'ing"? In the codebehind, i can use e.Cancel = true;, but how to use it in the viewmodel?
You can't bind something that isn't bindable per say. All you can do is either create a fake binding using a Behavior<T>, but not much point in that.
Instead you could just simply forward the event in the ViewModel, doing something like:
e.OnCancel = ViewModel.OnBackKeyPress();
And then have OnBackKeyPress() return a bool.
The very first idea that i got - is to leave it in codebehind, and send message to viewmodel, so it should shange its state. But i'd still prefer to bind event to VM.

Flex 4 Alternative to partAdded() in an ItemRenderer

I'm working on an application which uses a List and some itemRenderers. I have a button displayed in the "selected" state automatically set by the List component. This button is supposed to dispatch a custom event when clicked. Problem is, I don't know how to add my event listener, and I don't want to use 'click=""' because it's kinda dirty IMHO.
/
If it was a SkinnableContainer, I could override the partAdded() but I couldn't find anything similar in the ItemRenderer or the DataRenderer.
Any hints?
Thanks !
You may use the button creationComplete event to add the listener.
Or, for complex itemRenderers I usually create my own that extends SkinnableComponent and implements IDataRenderer. You can then override partAdded/partRemoved functions. Note that you will also need to define and support the skin states (hovered, selected...).

RaisePropertyChanged for Windows Phone

I'm starting to use the MVVMLight framework and have a question about binding to properties in the ViewModel. I found that I have to call the RaisePropertyChanged method in the setter for the property in order for the View to be updated. And I have to call RaisePropertyChanged from through the dispatcher otherwise I get a thread access error.
public string Lat { get { return _lat; } set
{
_lat = value;
Deployment.Current.Dispatcher.BeginInvoke(() => RaisePropertyChanged("Lat"));
} }
This works but its a lot of code to get auto binding properties. Is there a helper to handle this more cleanly?
Raising PropertyChanged events is mandatory when you want to bind UI elements to properties on your model classes, independently of whether you're using MVVM Light or not. In fact it's easier with MVVM Light as it provides the RaisePropertyChanged method, which you would otherwise have to code yourself. :)
Using Dispatcher.BeginInvoke() is only needed if the set accessor of your property can be invoked from a thread different from the UI thread. Otherwise it's OK to call RaisePropertyChanged directly.

SharePoint Webparts and Ajax

Please, I am new to webparts and I need help!!
I have a custom web part that I created. I added MS Ajax to it using an UpdatePanel which works fine. I add all my controls to the CreateChildControls method. As soon as I add a UpdateProgress control my page breaks with the following error:
Script controls may not be registered before PreRender
I do not use the OnPreRender event as what other posts suggest. Please, if anyone can give me advice it will be very much appreciated.
Thanks
I encountered similar problem before, try to call EnsureChildControls method inside your on init method override. It should be called by system automatically, but sharepoint likes to forget about it from time to time.
Like this:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
EnsureChildControls();
}
You might have forgotten to call the base method of an overrided event, which is not necessarily the OnPreRender event.
Check if the OnInit or OnLoad events are calling their base.On[...] method, e.g.:
protected override void OnLoad(EventArgs eventArgs)
{
base.OnLoad(eventArgs);
// your code...
}

Resources