|
I like to do a function in my Form that do a “print screen” on the whole form and saves it to a jpg-file.
_____________________________
...and justice for all
APe
|
|
|
|
|
|
You may take picture of whole form using DrawToBitmap function of Form and put it in a Bitmap object. After this you save it using save method of Bitmap object.
Following is a code snippet showing this-
------------------------Start Code----------------
Bitmap bmp1 = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
this.DrawToBitmap(bmp1, this.ClientRectangle);
bmp1.Save("C:\\FormImage.jpg");
-------------End Code-----------------------------
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hmmmm... I only get a printscreen of the form itself. Not its subforms...
_____________________________
...and justice for all
APe
|
|
|
|
|
Yes because in the previous code DrawToBitmap function of a particular Form was used, this will return image of only one form.
However if you have multiple Forms on screen and you want to take image of whole screen, you may try following code which uses CopyFromScreen function and it will return image of every thing which is on screen –
int wth, ht; //modify width and height as per need
wth= 1000;
ht= 900;
Bitmap bmp2=new Bitmap(wth,ht);
Graphics grp = Graphics.FromImage(bmp2);
Point x1=new Point();
Point x2=new Point ();
x1.X=0;
x1.Y=0;
x2.X=0;
x2.Y=0;
Size sz = new Size(wth, ht);
grp.CopyFromScreen(x1,x2,sz, CopyPixelOperation.SourceCopy);
This should give you what you want. Let me know the result .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Result:
_____________________________
...and justice for all
APe
|
|
|
|
|
|
|
Martin# wrote: Hope it helps!
Yes it did.
Thanks a bunch.
-- modified at 5:35 Tuesday 25th September, 2007
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
|
|
|
|
|
Hi all,
I have a class which inherit from System.WindowsForm.UserControl and an interface (with a method named Update)
I want to implement the Update method of my interface and not the user control method
is there a way to do that ?
like in C++ void Interface::Update() ?
Thanks in advance
|
|
|
|
|
You can have two update methods.
public void Update()
{
}
public void IMyInterface.Update()
{
}
MyControl control = GetControl();
control.Update();
((IMyInterface)control).Update();
The version called depends on what you have a reference to. If you have a reference to the class or one of its bases then the Update() method will be called, if you have a reference to the interface the IMyInterface.Update() will be called.
|
|
|
|
|
Hi
void DoThis()
{
try
{
DangerousCall();
}
catch( MyExpectedException e )
{
}
catch ( Exception e1 )
{
}
}
You can replace the catch all catch ( Exception e1 ) with a parameterless catch catch { ... } .
...snip...
catch( MyExpectedException e )
{
}
catch
{
}
Why? What does this give you? Can you get any exception info?
I've done a test and you can't use catch (Exception e) with catch { } as the compiler knows that is already a catch all in there. Confused .
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
No. The error is caught, but you can't get any detail about it. It has the effect of suppressing the error.
All exceptions derive from System.Exception, so catch {Exception e} will catch all exceptions regardless of type. You should only use catch {} if you deliberately want to suppress an exception if it is raised.
Paul
|
|
|
|
|
Thanks. So it effectively replaces Catch(Exception e) but gives you less information.
Why would you want to not know what caused a problem?
I understand why you want to swallow exceptions, not rethrow them, etc, I do it when interfacing to an external system which is up and down like a yo-yo, but I like to at least look at the exception to see why if failed, and then optionally log it.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Malcolm Smart wrote: Why would you want to not know what caused a problem?
Generally it is laziness. It is part of the anti-pattern known as try-catch-ignore.
However, there are "good" uses for it. And I put "good" in quotes because it stretches my incredulity a bit.
You could have used it in .NET 1.x before they had things like TryParse on DateTime and int to check if the parse operation completed successfully. You were probably not interested in why it went wrong, just that it did. TryParse just returns a boolean to say if the parsing failed or not.
|
|
|
|
|
Malcolm Smart wrote: Why would you want to not know what caused a problem?
I'm not saying that it is good practice to use it, only that the language supports it.
Paul
|
|
|
|
|
That depends on if you are using framework 1 or 2.
In framework 1, the difference is that catch(Exception) catches .NET exception, while a parameterless catch catches all exceptions.
In managed code you can only throw exceptions that derive from System.Exception , but if you call unmanaged code it may throw any object as an exception.
If you need to handle all exceptions in framework 1, you should use both a catch(Exception) and a parameterless catch , so that you get all available information.
In framework 2, anything thrown that doesn't derive from System.Exception is wrapped inside a System.Runtime.CompilerServices.RuntimeWrappedException object, so there is no longer any use for a parameterless catch . To specifically catch unmanaged exceptions you use catch(RuntimeWrappedException) , otherwise you can just use catch(Exception) to catch them too.
---
single minded; short sighted; long gone;
|
|
|
|
|
Good explanation. I think that's the clearest one I've seen in a while.
|
|
|
|
|
Thanks.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
I have a MS Outlook application developed in C#.net.
Now I want to access a users calendar in outlook and get the meetings
scheduled, mails send & receive, respond and send meeting requests, etc. In other
words anything that happens with calendering on Outlook desktop
client, I want to develop that in my .net application.
I guess there must be a way to talk to the back end server and retrieve
the info for seamless integration with any application. I mean
interfaces, functions or objects.
As you can see I have no clue how to go about it.
Any help will be highly appreciated.
Thanks in advance.
Senselva
|
|
|
|
|
Hi,
everything you need to know is on CDOLive:
http://www.cdolive.com[^]
____________________________________
There is no proof for this sentence.
|
|
|
|
|
Hi,
How to create the Google Suggest feature with ASP.NET 2.0 using C#. Please help me with Sample code. Thanks in Advance
Jebin
|
|
|
|
|
Use the keywords "auto complete" in CP, and you will see tons of articles about feature like Google Suggest
---------------------------------
Believe what you saw!
|
|
|
|
|
|
when i run the application (c#) to get the parameters list of the report ( sql2005.reporting service)
it shows an error:
=============================
"System.Net.WebException: The request failed with HTTP status 502: Proxy Error ( The ISA Server denied the specified Uniform Resource Locator (URL). ).
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at TFIReportClient.RPTWebReference.ReportingService.GetReportParameters(String Report, String HistoryID, Boolean ForRendering, ParameterValue[] Values, DataSourceCredentials[] Credentials) in ...."
=============================
so, what can i do?
|
|
|
|