event-handling

WMI and Win32_DeviceChangeEvent - Wrong event type returned?

风格不统一 提交于 2019-12-07 10:54:20
问题 I am trying to register to a "Device added/ Device removed" event using WMI. When I say device - I mean something in the lines of a Disk-On-Key or any other device that has files on it which I can access... I am registering to the event, and the event is raised, but the EventType propery is different from the one I am expecting to see. The documentation (MSDN) states : 1- config change, 2- Device added, 3-Device removed 4- Docking. For some reason I always get a value of 1. Any ideas ? Here's

Is it possible to prevent file dialog from appearing? Why?

巧了我就是萌 提交于 2019-12-07 10:10:29
问题 Suppose I have input[type=file] element and I want to intercept onclick event and prevent file dialog from appearing if conditions are not met. Is it possible? And why, if - not? 回答1: Soufiane's code requires that you have a Javascript library called jQuery on your page. If you don't have it, you can get it at http://www.jquery.com or use something in plain Javascript: HTML <input type="file" id="openf" /> JS: document.getElementById('openf').onclick = function (e) { e.preventDefault(); };

jQuery removing elements with event handlers

余生长醉 提交于 2019-12-07 08:07:48
问题 I have a list of products, where I need to update the innerHTML of a #container dynamically. My question is, if I do something like in this answer: Jquery Remove All Event Handlers Inside Element $("#container").find("*").off(); So, I remove all the event handlers for all the children, and then I update the html: $("#container").html(responseFromAJAX); How will this affect on the performance? I mean, is this a good way, to remove all the old elements and handlers, and clean up memory, or I

How do you test that a Range in Excel has cells in it?

爷,独闯天下 提交于 2019-12-07 06:54:49
问题 I've found a problem in Excel/VBA in the Worksheet_Change Event. I need to assign Target.Dependents to a Range, but if it has no dependents it brings up an error. I tried testing Target.Dependents.Cells.Count but that didn't work. Any Ideas? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 OR Target.Dependents.Cells.Count = 0 Then Exit Sub Dim TestRange As Range Set TestRange = Target.Dependents I've also tried "Target.Dependents Is Nothing". 回答1: Short answer,

Downcasting non-template base class to templated derived class: is it possible?

断了今生、忘了曾经 提交于 2019-12-07 06:43:05
问题 I'm implementing an event system for a game. It uses an event queue, and a data structure to hold all registered event handlers for a given event type. It works fine so far registering handlers, but when it comes to unregistering them (something that will take place when a game object is destroyed, for instance) I'm having a bit of trouble regarding templates and casting. I've defined an EventHandler as some sort of functor, partially based on Szymon Gatner's article on http://www.gamedev.net

How to sort in a WPF ListBox?

房东的猫 提交于 2019-12-07 06:38:23
问题 The C# 4.0 WPF application, see the code below, shows on startup: abd after clicking the Sort button with btnSort_Click() click event handler: How can I sort in order aaa, bbb, ccc? C# code: public MainWindow() { InitializeComponent(); listBox1.Items.Add("ccc"); listBox1.Items.Add("aaa"); listBox1.Items.Add("bbb"); } private void btnSort_Click(object sender, RoutedEventArgs e) { listBox1.Items.SortDescriptions.Add( new System.ComponentModel.SortDescription("Content", System.ComponentModel

How to remove and re-attatch EventHandler to controls in c#?

余生长醉 提交于 2019-12-07 05:46:22
问题 I've read this answer. It just tell me how to remove the click event from a button control. I want to know how to change the code (especially the GetField("EventClick"... part!) so I can do the same thing with other controls. For example, I want to remove the TextChanged event of a TextBox . And I also want to know how to re-attach the event handler. public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { if

ASP.NET determine which button was clicked inside an updatepanel in page load event

独自空忆成欢 提交于 2019-12-07 05:35:47
问题 I'm trying to get my head around a page lifecycle issue of an ASP.NET UserControl. What I have is an updatepanel with two buttons in it. Now, in the Page_Load event I need to make a check to see which of the two buttons was clicked. I do know that I should use the click event for this, but this is a case of quite a complex page cycle with dynamically added controls and so on, so forth, so that is not an option, unfortunately :-( I've tried to check on the Request.Form["__EVENTTARGET"] value,

How can I listen for “remember me” reauthentication events in Symfony2?

早过忘川 提交于 2019-12-07 05:32:20
问题 Using “normal” — not “remember me” authentication — I can set a success and failure handlers, adding this to the security.yml file: form_login: # ... success_handler: authentication_handler failure_handler: authentication_handler But I couldn't find a way for listening for “remember me” reauthentication, when a user's session is expired and a “remember me” cookie is used to reauthenticate again. Any ideas on how can I achieve this? 回答1: Create a Listener for the security.interactive_login

Is it efficient to use epoll with devices (/dev/event/…)?

隐身守侯 提交于 2019-12-07 05:30:25
问题 I am working on a monothreaded process applet which creates a proxy virtual device (more precisely a virtual Xbox 360 pad); I do manage to create it with the uinput interface, I set it up properly and it works just fine. In order to feed commands to this virtual device , I read events from another real interface (in this case a PS3 pad), and I open the real device file with these flags: fd = open("/dev/input/event22", O_RDONLY); // open the PS3 pad The main loop is something like (minus error