|
hello
tried to make a screencapture of a panel with controls on it and "connections" at the background (created using paint() procedure). DrawToBitmap does only the visible part of the panel, so i came up with the following code after a while. problem is that the invisible part of the panel turns up black in the resulting jpeg picture. Does anyone have any suggestions for me?
protected virtual void mnuRptClicked(object sender, EventArgs e)
{
this.AutoScrollPosition = new Point(0, 0);
int w = 0,h = 0;
foreach(Control c in this.Controls )
{
if(c.Left + c.Width > w) w = c.Left + c.Width + 100;
if(c.Top + c.Height > h) h = c.Top + c.Height + 100;
}
if(w == 0) w = this.DisplayRectangle.Width;
if(h == 0) h = this.DisplayRectangle.Height;
Bitmap b = new Bitmap(w,h);
Graphics bg = Graphics.FromImage(b);
int bgHdc = (int)bg.GetHdc();
SendMessage(this.Handle , WM_PAINT, bgHdc, 0);
SendMessage(this.Handle, WM_PRINT, bgHdc, (int)(
DrawingOptions.PRF_OWNED |
DrawingOptions.PRF_CHILDREN |
DrawingOptions.PRF_CLIENT)
);
bg.ReleaseHdc();
bg.Dispose ();
b.Save(Application.StartupPath + @"\captured.jpg", ImageFormat.Jpeg);
b.Dispose ();
}
|
|
|
|
|
|
PrintWindow only gives me the visible part of the panel, and it also gives me the scrollbars !
|
|
|
|
|
Sorry I didnt realise you were in a scrollable panel, I thought you were trying to print a window behind some other window, or off screen.
|
|
|
|
|
anyone else a suggestion?
|
|
|
|
|
Hello, i am having trouble with serial communication in C#. I have created a screen form and am trying to send and receive characters from a controller. I already have the controller programmed and it is working correctly. I can send and receive data using the windows terminal. But whenever i press a button on my form or controller keypad C# gives me the following error:
Cross-thread operation not valid: Control 'ekraan' accessed from a thread other than the thread it was created on.
I have little experience with C#, so any pointers on how to clear the error would be handy
Here is the code example:
//
TY
modified on Tuesday, September 9, 2008 3:52 AM
|
|
|
|
|
The error you are getting is related to the way that the serial port works. The DataReceived event is not raised on the main thread. In general, this is a good thing since it allows you to perform all the processing on the incoming serial data without blocking the UI thread. However as with all things multi-threaded, that means that you can no longer interact with controls directly from the event handler (or any other routines the handler calls). You will need to use this.BeginInvoke to get back to the main thread.
public void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string strResult = sp.ReadExisting();
ekraan.Text += strResult;
}
becomes:
public void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
this.BeginInvoke(new Action<string>(UpdateData), sp.ReadExisting());
}
private void UpdateData(string message)
{
ekraan.Text += message;
}</string>
|
|
|
|
|
Thx for replying.
However, i now get the following error:
No overload for 'UpdateData' matches delegate 'System.Action'
It says that the erroneus part is that: new Action (UpdateData)
Do i need do declare some additional "system.######" -s?
TY
|
|
|
|
|
see this link[^]
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
I mistyped that line. It should be:
this.BeginInvoke(new Action<string>(UpdateData), sp.ReadExisting());
|
|
|
|
|
Thanks
|
|
|
|
|
Ok, i am still having some trouble with the code. I have a controller on the other side with a thermometer and keyboard etc.
I am sending the temperature from there to my form. It normally works fine.
The only time it gives me an error is when the first thing i do is click "show temperature" on my screen form. Then the error that occours is the following:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
If the first button i press is not "show temperature" then it works fine. I have a keyboard on screen as well.
Could it be that the forst time data is in some kind of wrong format? How to make sure that the window handle will be created before BeginInvoke?
Sample code:
... }
modified on Thursday, November 13, 2008 6:31 AM
|
|
|
|
|
It also says the following:
Target InvocationException was unhandled.
Exception has been thrown by the target of an invocation.
|
|
|
|
|
Hi,
I have some class libraries, which I dont want the client to use.
How can we secure our dll in such a way that if someone else adds our dll to his project then it gives some error or may e do not allow to add it.
|
|
|
|
|
|
i wrote a simple server that sends it's public key to the client using (RSACryptoServiceProvider),
rsa.ToXmlString(false) . at client it creates an xml file. i want the client to read the xml file and get the key.
I'm expecting support
|
|
|
|
|
prasadbuddhika wrote: i want the client to read the xml file and get the key
If its sent as an xml file you can read it as such.
prasadbuddhika wrote: I'm expecting support
Thats a bit rude - heard of a little word called PLEASE?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
prasadbuddhika wrote: i wrote a simple server that sends it's public key to the client using (RSACryptoServiceProvider),
rsa.ToXmlString(false)
. at client it creates an xml file. i want the client to read the xml file and get the key.
And what's your question? All you've done is made some statements, so we can't figure out what you want.
prasadbuddhika wrote: I'm expecting support
I'm expecting Salma Hayek to come round to my house tonight and perform unspeakable acts on me that will leave me cross eyed for a fortnight. That's not likely to happen either.
|
|
|
|
|
How to display image in datagrid in windows application.
Plz help me out...
Thanks
V K Gupta
|
|
|
|
|
i found this link[^]
may be you can compare it in c#
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
Hi,
I did that before, but while doing a database + C# application.
I show the image in both grid(smaller) and picturebox(larger)
Try search for <b>store image in database</b> here in codeproject.
It doesn´t look that good showing it only in the grid!!!
If you aren´t building a database, and just want to put image in a grid, i tell you that is not the best display for it.
Good Luck
nelsonpaixao@yahoo.com.br
|
|
|
|
|
I am using listview control in details view in vs2003.
Here, how i m using
foreach(DataRow dr in dtAddress.Rows)
{
ListViewItem Lv;
Lv = lvAddress.Items.Add(dr["Address"].ToString());
Lv.SubItems.Add("value for In");
Lv.SubItems.Add("value for Out");
.
.
}
View got generated like this
---------------------
StationID IN Out
---------------------
A 0 1
B 2 0
. . .
.
.
& so on, working fine.(Getting in vertical way)
But I want to show this in other way, like this.(Horizontal way)
StationID A B . .
In 0 2
Out 1 0
for this i am doing like this
int i = 0;
foreach(DataRow dr in dtAddress.Rows)
{
lvAddress.Columns.Add(dr["StationID"].ToString(), 70, HorizontalAlignment.Left);
}
I got the all station as Column Name, but how to add corresponding In, Out fields.
Thanks & regards
Humdum
|
|
|
|
|
Hi Guys,
Is it possible to create a similar sort of dialog using C#?
http://www.bartdesmet.net/images/shutdownblocking02.jpg
Although, I've been working with C# for a while, I have no idea where to get started on this.
Any help, guys?
Damn, it feels good to be back here after this while. :p ...after a year of working with Linux Scripts, Java and Oracle, I'm seriously out of touch.
|
|
|
|
|
Well, you can set the transparency key and opacity which might acheive what you want. If not you'll have to look up using Layered Windows
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
float aspectRatio = 1280 / 1024;
Console.WriteLine(aspectRatio.ToString());
RESULT?
1
float aspectRatio = 1280 / 800;
Console.WriteLine(aspectRatio.ToString());
RESULT?
1
float aspectRatio = 1280 / 500;
Console.WriteLine(aspectRatio.ToString());
RESULT?
2
Any idea why this might be?
|
|
|
|