event-handling

VB.NET overload default functionality when user clicks the X (Close Program)

余生颓废 提交于 2019-12-19 10:15:45
问题 How do I go about overriding the default functionality when a user clicks the X in a VB.NET form-based application? I am currently handling the MyBase.Closing event... but since it's a DirectX app, I need to do some cleanup before allowing the form the close. 回答1: If you want to do some extra clean up before a form closes, do so in the form's Form Closing event. This event also allows you to cancel the form close through the event's FormClosingEventArgs.Cancel property. The event's

making a JPanel into a JOptionPane.OK_OPTION

 ̄綄美尐妖づ 提交于 2019-12-19 09:47:04
问题 currently i have a class which extends JPanel and basically shows some information about an object passed into its constructor. There are various labels and Image icons on the screen and has a BorderLayout set. This panel is triggered when the user left clicks on an ImageIcon from the main GUI and shows up on the screen. i was wondering, how (if there is a way) i could implement the JOptionPane.OK_OPTION onto the whole Panel so that i dont have to close the panel using Event handling, as the

Am I using the right approach to monitor the tasks I want to perform when a handle is created?

拥有回忆 提交于 2019-12-19 07:53:16
问题 Is there a generally-accepted best practice for creating an event handler that unsubscribes itself? E.g., the first thing I came up with is something like: // Foo.cs // ... Bar bar = new Bar(/* add'l req'd state */); EventHandler handler = new EventHandler(bar.HandlerMethod); bar.HandlerToUnsubscribe = handler; eventSource.EventName += handler; // ... // Bar.cs class Bar { /* add'l req'd state */ // .ctor public EventHandler HandlerToUnsubscribe { get; set; } public void HandlerMethod(object

Syntax to send two strings in eventArgs

拟墨画扇 提交于 2019-12-19 07:33:10
问题 In the following code I need to know the syntax of passing two strings when the event is raised. [PublishEvent("Click")] public event EventHandler<EventArgs<string>> MyEvent; Thanks, Saxon. 回答1: The cleanest way is to create your own class that derives from EventArgs : public class MyEventArgs : EventArgs { private readonly string _myFirstString; private readonly string _mySecondString; public MyEventArgs(string myFirstString, string mySecondString) { _myFirstString = myFirstString;

Ensure jQuery event handler execution order

倖福魔咒の 提交于 2019-12-19 07:08:23
问题 I think that event handlers are processed in the order that they are registered. (Is that correct?) If that is the case then if I attach an event handler at the beginning of my script, can I be absolutely certain that it will fire before subsequent handlers attached to the same event? Also do event namespaces have any effect on this? Are event handlers fired in series (one finishes before the next) or in parallel? I want to do this because my script relies on the viewport size, which changes

C#: String as parameter to event?

本小妞迷上赌 提交于 2019-12-19 05:45:28
问题 I have a GUI-thread for my form and another thread that computes things. The form has a richtTextBox. I want the worker-thread to pass strings to the form, so that every string is displayed in the textbox. Everytime a new string is generated in the worker thread I call an event, and this should now display the string. But I don't know how to pass the string! This is what I tried so far: ///// Form1 private void btn_myClass_Click(object sender, EventArgs e) { myClass myObj = new myClass();

Scroll Event of a JScrollPane

萝らか妹 提交于 2019-12-19 05:08:22
问题 It's strange that JScrollPane doesn't have a method addAdjustmentListener() . Yet adjustmentListener is said to be used with scrollbars. I want something to happen whenever the JScrollPane is scrolled in either way. How to achieve such a thing? 回答1: Why don't you get the actual scrollbars, and then add adjustment listeners to them? JScrollBar has a method called addAdjustmentListener() . And you can use getVerticalScrollBar() and getHorizontalScrollBar() to get a JScrollBar from a JScrollPane

Scroll Event of a JScrollPane

时光总嘲笑我的痴心妄想 提交于 2019-12-19 05:08:07
问题 It's strange that JScrollPane doesn't have a method addAdjustmentListener() . Yet adjustmentListener is said to be used with scrollbars. I want something to happen whenever the JScrollPane is scrolled in either way. How to achieve such a thing? 回答1: Why don't you get the actual scrollbars, and then add adjustment listeners to them? JScrollBar has a method called addAdjustmentListener() . And you can use getVerticalScrollBar() and getHorizontalScrollBar() to get a JScrollBar from a JScrollPane

Laravel 5.2 : Do something after user has logged in?

风格不统一 提交于 2019-12-19 05:06:30
问题 (I'm a beginner of Laravel) I'm using Laravel 5.2 . I have successfully enabled the Authentication; by doing the php artisan make:auth and stuffs. So my login is working. Now i need to do something once someone has logged in. For an simple example: LOGIN: Once a user has logged in, write a value into Session. For example: $request->session()->put('UserAgent', $ClientUserAgent); LOGOUT: Same thing to do, once a user has logged out, delete the custom Session value. For example: $request-

jQuery unload event only for close window not for Link navigation

本秂侑毒 提交于 2019-12-19 04:55:21
问题 I am using this code for logging out user when closes the page, but the user will logout also when clicking on other links (same website): $( window ).unload(function() { $.ajax({url:"?logout&leave=yes", async:false}) }); Is there any way to distinguish between link navigation and real page close? EDIT: I am currently implemented this solution, but it lacks to detect page reload $('a').click(function(){ var url = $(this).attr("href"); window.onbeforeunload = null; $(window).unbind(