I am dealing with a problem reported in my company's scheduling application written in C#. We have a list of events in a Listview on the right of the scheduling grid, and you can scroll through that list and drag and drop events onto the grid. This works great in XP, Vista, 7, etc -- but not when you're using remote desktop. When using remote desktop, you have to double-click the event so you can drag it onto the grid, even though the RD and the application have focus, as well as the Listview.
My boss told me that remote desktop just doesn't work well for a drag and drop operation, but I haven't really been able to find any proof of that. I've tried a variety of ways to solve this problem, including resetting the focus &/or selections, adding an extra call to the click event, and nothing has worked. I have DragLeave, MouseMove, MouseDown, and MouseUp events to play around with. The code does register the MouseMoves just fine... it just seems to swallow that first click. Has anyone experienced anything like this? Any ideas?
Have you checked that the control loses focus when using it remotely ?
Did you try something like the code below ?
public override void OnMouseEnter(MouseEventArgs e)
{
this.Focus();
}
Related
This is for WinForms.
I am having a strange problem that is driving me absolutely batty. I have a tab control for which standard system events, and only standard system events, are not firing. The specific event I was trying to get to fire was the TabIndexChanged event. It doesn't matter whether I add this programmatically or with the designer.
Note: Mouse events will fire. Keypress events will fire. All other events that I have tried will fire.
System events on OTHER controls will fire.
It isn't a single tab control that is having a problem either. If I drag a new tab control onto the form it will also have this problem.
I do not really have any code to show here because it would just be the event as generated by the designer and a Console.WriteLine message to see if it is firing (this line outputs for other events). What I am hoping for is some insight as to what could cause this problem.
The entire program is quite large, so I cannot really clip the whole thing into this forum so that individuals can hunt for a specific problem. My hope is that somebody might be able to point me to what might cause this behavior. I am thinking that maybe something got screwed up when editing in design mode, but I just do not know what to look for. I am relatively new to C# and programming is a hobby for me.
Thank you for your time,
FC
You need to try the property SelectedIndexChanged; to expose that property, with the property window open, click once outside the tabbed container then click one of the small tabs once, don't click inside the tab area. Find the property, type in an event name and then double click it.
I'm completely new to C# and the .NET framework so forgive me if this is a silly question.
Is there any way of viewing a list of all of the events that have happened on a Windows system as a result of keystrokes and mouse movements etc.? So for example when I click on the Start menu, the Start menu is displayed or when I click the "Apply" button within a settings sub-menu, the settings are applied.
Is there any part of the .NET framework that will allow me to view all of these events/actions and record them via a C# program? Any help would me greatly appreciated! Thanks in advance.
UI Automation API is what you need. For listening automation events there are few kinds of handlers: AutomationEventHandler, StructureChangedEventHandler and 2 others.
There is another way for native windows: global mouse and keyboard hooks. See SetWindowsHookEx function.
C# in visual studio designer gives you the ability to respond to all kinds of events, like mouse moves and clicks. If you click on the object you want events from, then go to the events pane, you will see a list of all the events for that object. double click in the textbox next to it and it will auto-generate an event handler in your code. When the event is triggered, it will go to this method and do any code you provide there; IE log the action however you choose.
I have a strange problem and I can't seem to figure out a solution.
I have a windows forms application written in C# .net4.0.
In this application, there's a panel where i draw a chart on.
This chart is drawn on the "Paint" event of the panel.
There's also a button which launches another application on top of this application which displays other information
All of this works fine, untill I close the opened application.
When I Close it, i see my first application again but parts of it haven't been repainted.
It seems that the panel with the chart repainted correctly, the rest of it's container panel didn't.
I removed the "Paint" event of the Panel with the chart as a test and then, everything worked fine (offcourse no chart was drawn)
Strangly, I only do have this problem when the programs are in an RDP session.
On my local pc, everything works/refreshes fine.
If anybody can help me on this, it would be very much appreciated!!
For clarity I have added screenshots below:
we have a lot of rendering problems on RDP too.
Try setting the values mentioned here:
http://blog.tedd.no/2011/04/28/optimizing-rdp-for-casual-use-windows-7-sp1-remotefx/
Also we have implemented additional refreshes when using our application over rdp, although weird, it seems to help. We haven't found a really good and clean solution yet.
You can also alter RDP behavior in the options menu when you start the RDP session. We are using transparency, for example, and had to turn of bitmap caching.
I am doing a UI automation for a WPF application using the Microsoft UI Automation library and it works well.
However my app has four screens in a TabControl. Even when I click the tab item through code its child control tree isnt populated. The only control I can see is the "thumb" Control. Same happens when I see the control tree with UISpy.
However if the window is clicked then all the controls appear. As a Workaround I am simulating a mouseclick through code and it works. I wanted to know if there is some better way of doing it.
I ran into a problem similar to this. What was happening was some data was being retrieved on threads and the controls were not generated at the point automation peers were generated. I would suggest if you have access to the code base for the application you are attempting to automate looking into whether threading is being used. In my specific case it was because BeginInvokes were used to retrieve the data, I switched them to Invokes and it worked fine.
Also from what I could tell the reason the controls were being show on mouse over was because the tool tip generated a popup and caused the automation peers to be updated.
Why don't you click the control using mouse events if that is what works.
(Now, if you still are having that problem..)
How to simulate Mouse Click in C#?
I'm using a checkbox on a winform app. If you mouseover the checkbox an orange highlight appears showing that that control has the focus. If you tab to that control this doesn't happen though the 'Enter' event is fired. My question is, how do I manually set that orange highlight on the checkbox when it has focus, is it a style attribute?
Thanks, R.
My understanding is that this cannot be done via the CheckBox control's properties in C#. The behavior you see is how the control is designed: that's what the checkbox does when the mouse cursor is over it, which is not the same as it having the focus.
Your best bet would be to try to send the CheckBox control the right Windows Message via Win32 interop -- although truthfully it may prove challenging to do even via Win32 calls, since there doesn't appear to be a windows message that will easily create the behavior you want.
It's possible you could fake the control into thinking that the mouse is over it, but I'm not sure it's worth the effort for a visual effect that's probably not essential.
Nonetheless, you could take a look at the:
Button-specific Windows Messages on MSDN. (Checkboxes are technically buttons.)
Mouse-specific Windows Messages.
And there's plenty of questions about using SendMessage on SO.
Sorry I couldn't offer a working solution, but maybe a Win32 ninja will swoop in and correct me.