Capture a scrolling window contents screenshot - c#

I need to capture a screenshot of the scrolling window's client area, using .NET. My first priority is capturing web page screenshots. But this can be not the only one use case. For example it can be also a text area in the Notepad.
Some applications (FastStone Capture, PicPick) can emulate user behavior to reach hidden part of a scrollable area and capture it. I'm looking for something like this or recommendations for alternative way to get the same result.

You can get windows to redirect a WM_PAINT to an offscreen buffer with WM_PRINT and WM_PRINTCLIENT. This is better than screenscraping because it makes sure that obscured parts of a window(behind other windows) is painted anyway. If your target window scrolls by scrolling a child window position, WM_PRINT should apply. Just maybe it also helps your scenario.

I've continued my search and founded IECapt, — an open source tool which can take a web page screenshot using IE inside of it. It has С++ and .NET versions. Also there are Qt/WebKit-based analog from the same author: http://cutycapt.sourceforge.net.
This tools is not a direct answer for my question, but both of them solve the original problem by 90%.

Have you looked at Snagit? http://www.techsmith.com/download/accessories/default.asp
Also, here's a c# utility that seems to do what you're asking for: http://www.codeproject.com/KB/graphics/IECapture.aspx

Related

How would you create a page like WP's Mail app's Compose screen?

I'm new to WP dev (and pretty much C# and Silverlight in general) and I've been playing with Textboxes. I found pretty quickly that you can't really scroll a TextBox control.
I've seen some solutions to this on various blogs and StackOverflow posts, and the most popular one seems to be to embed the TextBox in a ScrollViewer, then use some code to make the current input line always visible, like this:
scrollViewer.ScrollToVerticalOffset(textBox.ActualHeight);
This works okay if you have a relatively small TextBox, but if you want to make one that takes up quite a bit of space, you run into problems where the keyboard covers up the bottom section, you can't scroll to the top unless you manually move the cursor up there, etc.
Now the Compose page of the Mail application seems to do this perfectly: a nice big space for text entry where the keyboard never blocks the input, you can freely scroll through the entire pane, it just works really. I've tried various combinations of scrollviewers and textboxes but I haven't had any success in matching its behavior.
Any help?
The default apps are not written in C# using controls accessible in SDK or on the net.
Replication of mail viewer and composer has been tried before rather un-successfully. (Based on similar posts of AppHub - old WP7 forum)

Taking screenshot of a partially hidden window in a programmatic way

Is it possible to get a screenshot of a window that is not on the top, i.e. if it is partially hidden by another window, without bringing it to the top?
Unfortunately, it's not trivial to take a screen-shot in C# at all, you can create a graphics object based on the current window or viewport and capture that, but its not what you're asking for.
This
Screenshot of Hidden Window
might help, but you'd have to do this with Interop code anyway.
I dare say that it's not a common thing that is supported as really, one program has no business knowing what's being displayed in another program; it's potentially a nasty exploit.
You dont need to take screenshot, if it is your application you can use Control.DrawToBitmap(Bitmap bitmap, Rectangle targetBounds); of the form object.
If it is other application window, you can try un-managed way to get the UI of window. I dont remember all the methods but I have tried and it was working. Probably GetWindow and SendMesage with WM_PRINT / WM_PRINTCLIENT

How to add an extra button to the window title bar, so it will be work as standard?

Firstly I want mention that I have already read all articles on SO on subject, but still have no answer for my question. Also my question slightly different than others.
Today a I have a look on Skype window. There is one extra button on it's title bar. But this button acts as native system button. Just look on glowing, it spreads out of the window. So I have the reasonable question. According to that we can see on the picture below, there is standard way to add extra button on title bar. But all answers on subj leads to hooking of WM_NCPAINT event and manual drawing of extra button. This approach is work but it could not yield such beautifull glowing as on the picture.
Does anybody knows the way to add standartized button on window's title bar?
Thanks in advance!
In Vista and Windows 7 there is a new thing called the Desktop Window Manager. This is used to draw the "Aero glass" window titlebars, and do the glow effects. The old Windows XP approach of implementing WM_NCPAINT handlers doesn't work with this new system, so you have to use a whole new API.
I'm sure I've seen some articles on doing what you're asking about, but can't find them right now. Some pages that might give you some leads are:
http://msdn.microsoft.com/en-us/magazine/cc163435.aspx
http://msdn.microsoft.com/en-us/library/aa969540(v=VS.85).aspx
http://delphihaven.wordpress.com/2010/04/19/setting-up-a-custom-titlebar/
Yes, this can be (and undoubtedly is) done by hooking WM_NCPAINT and painting their button in response to it. The "glowing" is just a matter of picking the appropriate color and shading (and possibly doing a bit of alpha blending to have some "glow" show up close to the button).

How to place a control over the task bar in windows using c#

i googled a lot and found out some info about the band object from which we can make the ad-in for the task bar, can i get some more tutorials from scratch & some sample programmes.
is there any other alternative way is there to place a control over the windows task bar apart from band objects?
Thanks in advance
If you want to place a textbox in the taskbar like the Google Desktop search bar, then you're not actually trying to place the control over the taskbar, you want to place it within the taskbar.
The proper solution here is a Desk Band. You can find an MSDN article explaining those here. I'm not really sure why you say that you want to avoid band objects. That's the right way to do this.
There's even a sample implementation in C# available on Code Project: Extending Explorer with Band Objects using .NET and Windows Forms
To make a window overlap the Taskbar you can set it's TopMost property to true. But then you will have to control the positioning yourself, and it will also overlap anything else beneath it, but it is a solution at least :)

Windows Forms advanced visual effects

I have an design idea about the appearence of a small program , which is basically a windows form with a combo and one button.What i would like to do is the following.When i click on the .exe of the program to start it , i would like to have an non-standart start up of the window.To be more specific i will give you an example - i click on the .exe , upon which some dots appear in a random matter all over the screen , after those points appear they start moving in a spiral way so finally they merge into the standart square windows form shape.So my question is - is there a free API or anything similar with the help of which its easily doable or there would be a lot of work needed from myself to create those API's ?
Thanks in advance
This will be extremely difficult to do.
It will also be very annoying for the end-users.
In short I see two options:
Render your form to a bitmap and render peices of the bitmap to a full-screen layered window. You'll have to call UpdateLayeredWindow repeatedly to get the animation working but that should be a good lead. I could see getting 10-20 fps with this method.
Take a screenshot of the desktop, create a full screen borderless topmost window, render the screenshot, then render your animation on top. This will prevent any other windows from recieving input while the animation is playing.
Either way your users will hate you.
As SLaks has already said, that will be pretty annoying for the end-users.
If you ask whether it is doable, I would say yes, everything is doable in programming, it all depends on the effort you're ready to put into.
As a very simple algorithm, here are some steps I would go through for your achievement:
Create a System.Windows.Forms.Form;
Set Form.ShowInTaskBar= false;
Set the Form.TransparencyKey property;
Set the Form.ControlBox= false;
Set Form.TopMost= true;
Drop a PictureBox control on your Form;
On the Form.Load event, take a screenshot of the current desktop and set it as the image of your PictureBox.
Then, build an animated GIF, and superpose it to your form.
You will most likely appreciate, I guess, the following link which discusses about C# Winforms Animation.
Disclaimer: This is an arbitrary algorithm off the top of my head. Besides, I illustrated the steps I would go through in order to achieve such objective, though I have never ever performed WindowsForms animation.
Althouth this might be cool to program, users are conservatives and "always anxious" about program startups, so, as already mentioned, this might become pretty annoying for the end-users.
I hope this helps you through anyway!

Categories