.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Capture Canvas with Mouse pointer

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :WPF

I am currently creating an application which will capture Canvas control (i.e. Screenshot of canvas control) and save it as an image. For this I am using RenderTargetBitmap class. I am able to capture canvas control but I also want to capture mouse pointer. Is there any way I can capture canvas control with mouse pointer?

Code I am currently using is as below

 Dim r As New RenderTargetBitmap(cnv.ActualWidth, cnv.ActualHeight, 96, 96, PixelFormats.Default)
 Dim dv As New DrawingVisual
 Dim dc As DrawingContext = dv.RenderOpen

 dc.DrawRectangle(New VisualBrush(cnv), Nothing, New Rect(New Size(cnv.ActualWidth, cnv.ActualHeight)))

 Image1.Source = r

Gaurav Khanna

View Complete Post

More Related Resource Links

How to capture ReportViewer Mouse Events


I have a ReportViewer which I'm pulling into a C# WPF project, and would like to be able to capture the row a user clicks on in the reportViewer, but have had no success tapping into the mouse event handlers.   Does anyone know how to accomplish this?  

This MSDN link seems to imply that ReportViewer(winforms) supports mouse click events such as Click, DoubleClick..etc.  http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer_events.aspx, but I've not had any luck.

If mouse events are not currently supported, does anyone know when they will be, and whether properties such as SelectedItem or SelectedIndex would also be exposed?

Thanks for the help.

Why would a control not respond to mouse clicks when added to a custom canvas


   I have a custom UserControl that contains a grid and toolbar.  When I add this control to a custom drag canvas, it does not respond to MouseClick events.
   I suspected the custom drag panel as it overrides UIElement.OnPreviewMouseLeftButtonDown and sets e.Handled = true but commenting out line that sets e.Handled to true does not allow control process mouse clicks.
   If, however, I derive my custom control from Popup, it sees mouse clicks as toolbar button commands are executed. 
   What am I observing?

Mouse Capture Loss


I have canvas that captures the mouse so scroll the canvas when the mouse is outside of it. The problem is that every once in a while the mouse capture is lost or a simulated click like effect is generated. That is, if the mouse is over another application then that application will receive a click(even though the mouse button was never released).


Capture is started when mouse button is pressed and released when the mouse button is released. I am using timers to scroll the canvas while the mouse is outside the canvas.


There is only one this.CaptureMouse() and one this.ReleaseMouseCapture() used. One in the OnMouseDown and the other in the OnMouseUp. Therefore I don't see any reason why I would lose capture and a mouse down(or possibly up) would be sent until the actual mouse buttons were clicked.

I cannot repeat the problem consistently and seems to be time based. I have noticed that with some applications running in the background it seems more likely they will "reset" the mouse in the sense that the mouse capture is lost more often(as if they are trying to take it over which causes a "glitch" in my app.


Free Mouse from screen capture


The mouse cursor is trapped on the screen. That is, you cannot move it past the edges. For my application I would like to do so. I'm sure there is some simple flag to remove the mouse boundaries but I can't find it.



How to highlight datagrid or GridView row on mouse over?

This article will show how you can Ajax with GridView to display popup messages when mouse moves over certain column. In the demo project I have added first column as an image column with a help icon in it. This kind of implements a feature that if you want more information about the row you can move mouse over this icon, a asynchronous request is sent to server for data about that row and when call returns the returned message is show as a popup message.

Form Filler: Build Workflows to Capture Data and Create Documents


Learn how to create a workflow that uses InfoPath forms and other office documents for passing data to targeted activities and for use in Office documents.

Rick Spiewak

MSDN Magazine June 2008

Netting C++: EEK!-Time to Design the Mouse


This month begins the design of the actual mouse class for EEK!

Stanley B. Lippman

MSDN Magazine December 2007

Highlight gridview row on mouse hover in asp.net

The article Highlight gridview row on mouse hover in asp.net was added by uniquesaiful on Sunday, June 06, 2010.

Gridview control is a customizable and flexible control used to display data in tabular format. It has some nice features. But lacks of some client side features that makes web users happy. We can easily add these features with few lines of code. For

Buttons with Mouse-Over Behaviors - Redux

I recently posted some CSS and HTML snippets for a buttons collection I was using for a Menu style UI Scott Koon from www.LazyCoder.com posted a comment with a better way (thanks Scott). This way I don't have to set the CSS Class for each button. Just contain them in a div. Here is the [...] Read More......(read more)

Capture event from HierarchicalDataSource


I have a custom hierarchical data source based on the msdn example (http://msdn.microsoft.com/en-us/library/system.web.ui.hierarchicaldatasourcecontrol.aspx).  An event can be raised in the DataSourceView.  If that occurs, I want to display a message on the web page.

The example is that I have a page with a TreeView control which uses a custom hierarchical datasource.  If the user selects a node that they are not allowed to select, the underlying datasource will throw and error.

I want to capture this and add a message to the page.  The Page_Error event is raised, but there are no eventargs.

Anybody know how to capture such an event? 

An alternative approach, although not quite specific enough, is to set a flag during the datasource load event (indicating the datasource is loading) and test for this flag in the Page_Error routine.

Issue with Web capture webpart configuration


I have a requirement to display a specific are of page.
I think we can do it by using web capture webpart. when i try to modify the properties of webcapture webpart it prompts an message"Cannot create or modify Web Capture. Make sure that your browser supports ActiveX controls , that you have enabled them, and that you have installed the Web Capture ActiveX control".
I have installed "owc11" coponent but of no use. i am using IE 7...

can anyone please suggest how to solve this issue?


Capture Url and do redirect



I am writing a http module, Want to find out how can i capture a URL and the do a redirect in case of certin conditions met?

What pattern do I use to capture an entire C# method definition with all modifiers, method name and

Hello all,Given a C# method named MyMethod, what pattern do I use to capture the entire definition, including modifiers, method name and opening and closing braces, irrespective of bracket styles, given that the method will probably contain 1-n other pairs of braces, embedded or not, etc? In this case, I don't care about the actual method definition, I just need to capture it all in one chunk.    a. public int MyMethod(int parm){            if (...) {            }       }    b. public int MyMethod(int parm)       {            if (...) {            }       }Thanks in advance for any ideas and/or suggestions!

SendInput fails to control mouse in x64

I am currently working on a project in which I'm trying to make a program which can input mouse movements to click and drag objects. I've imported user32.dll and created my inputs exactly as the help info and pinvoke.net instruct so as to be able to send mouse inputs. Nevertheless, whenever I implement the SendInput function, it always returns that it successfully inserted 0 events into the keyboard and mouse input stream and when I run GetLastError, it gives me error 1400 INVALID_WINDOW_HANDLE. I've tried the same code on two different systems, both running in x64. One is XP and the other is Windows 7. Neither works. If you're interested in the code, it's basically a 64-bit version of Johnny Chung Lee's Wiimote Whiteboard program. I've made a few modifications, but the main gruntwork of the program is the same as his original. His stuff can be found here: http://johnnylee.net/projects/wii/
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend