|
Hi,
plz plz help me i am struggling to display image in a picture box.. i am developing applicaiton where i have to call VC++ dll function to display image in picturebox of C# form.For that I should pass device context of picture box where i have to display image.But the problem is there is no device context for the picturebox....
I tried various method by converting picturebox to graphics object, and getting deivice context (objGfx.GetHdc()) and also pinvoke GetDC() (from user32.dll ) but to make my life miserable both are not working or I am making some silly mistake. Some sample code or link to the article where above problem is explaned will be helpful.
handle123
|
|
|
|
|
Try passing the device context of the image:
<br />
Image img = picturebox.Image;<br />
Graphics graphics = Graphics.FromImage(img);<br />
IntPtr hdc = graphics.GetHdc();<br />
<br />
<br />
graphics.ReleaseHdc(hdc);<br />
graphics.Dispose();<br />
<br />
picturebox.Refresh();<br />
_________________________________
nur Idioten brauchen einen Führer
|
|
|
|
|
thanks for reply... I tried as you told but program is crashing at line
Graphics graphics = Graphics.FromImage(img);
because 'img' is undefined value and not set to anything because picturebox is empty initialy. )
|
|
|
|
|
Do you know the expected dimensions of the image?
<br />
picturebox.Image = new Bitmap(width, height);<br />
_________________________________
nur Idioten brauchen einen Führer
|
|
|
|
|
I think i can use width and hieght of the picturebox.... i did the same but it is still not showing any image in picturebox... I am sending you the code snippet i have written.I am wiriting this code in the wndproc of the form ... I am not writing OnPaint()... ???
pictureBox1.Image = new Bitmap(pictureBox1.Height,pictureBox1.Width);
Image image = pictureBox1.Image;
gfx = Graphics.FromImage(image);
objFusion.m_hdc = gfx.GetHdc();
Int32 a = DrawLiveImage(objFusion.ConHandle,3,objFusion.m_hdc,ref rect);
if(a !=0)
{
MessageBox.Show(a.ToString());
}
gfx.ReleaseHdc(objFusion.m_hdc);
gfx.Dispose();
pictureBox1.Refresh();
here objFusion is the object where other VC++ dll calls are done and DVRDrawLiveImage is the function in a dll, this dll we are using to draw images in picture box which we are getting from Digital Video recorder.We get video image frames and we need to draw that in a picturebox.
|
|
|
|
|
good day.. jz wna know how i can show the list of tables in a database using listbox?? and once i click on a specific table, its contents will be shown on a datagrid.. btw, m using sql server.. thanks in advance!!
|
|
|
|
|
|
Hi,
Can we embedd the windows application created in C# .NET in MFC ActiveX Container application.
Thanks
TusharM.
|
|
|
|
|
does anyone know the function for the system beep? i would appreciate the help, thx in advance
IM PROUD TO BE A GMAIL;
|
|
|
|
|
|
thx
IM PROUD TO BE A GMAIL;
|
|
|
|
|
hello mr
like c and c++ , an 'escape sequences' available in c#.for instance
"\n" represents 'new line' that means it creates a new empty line and make cursor wait at starting of next line.
like wise in c# for beep u need to send an escape sequence for beep
in c#
console.writeline("this is beep" + "\t");
the beep sound can be heard after the message appeared
in vb.net
console.writeline("this is beep")
beep
|
|
|
|
|
im using whidbey and i found a function...
console.beep();
'and i thought it was \a for the beep
IM PROUD TO BE A GMAIL;
|
|
|
|
|
Hi!
i read some data within a file. the data is an array of DWORDS (unsigned longs).
each DWORD is an pointer to data that is also within the same file.
Such pointer is a DWORD like i mentioned before. For example i get a value like this (HEX) 74150000 (DEZ) 1947533312.
My Problem is that the FileLength is only 6364. Maybe i understand this wrong?
have i only to take a part of the dword value as address?
thanks for hints!
|
|
|
|
|
|
oh, sry.
i allready use ReadUInt32() and store the data in a variable of type uint.
|
|
|
|
|
It looks like a byte-ordering problem. Your bytes 74 15 00 00 probably represent 0x00001574 (5492 decimal).
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
omg
Your are right. I forgot to convert from big to little endian!!!
Thank you!!!
|
|
|
|
|
any body ...
how i can make botton that clear the last letter in the rishbox or in any text box .
please send the code......
thanks very much
|
|
|
|
|
Refer the following code.
private void button1_Click(object sender, System.EventArgs e)
{
this.richTextBox1.Focus();
SendKeys.Send("{BACKSPACE}");
}
|
|
|
|
|
Sorry...I just forgot to add the namespace. It is System.Windows.Forms . Same as RichTextBox or TextBox . Be sure of adding
using System.Windows.Forms;
|
|
|
|
|
Another solution:
private void button1_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = this.richTextBox1.Text.Remove(this.richTextBox1.TextLength - 1, 1);
}
www.troschuetz.de
|
|
|
|
|
It will cause Undo Buffer Reset as there is a bug in RichTextBox.Text .
Please note that the Undo property does not work correctly if text is retrieved from the richTextBox using richTextBox.Text property
refer mocrosoft site for the bug detail
http://support.microsoft.com/default.aspx?kbid=812943
|
|
|
|
|
THX for the info.
I tried the code snippet on a WinNT computer that is obviously not affected by the bug.
www.troschuetz.de
|
|
|
|
|
Yeah, u r right. This occurs under XP.
If you override the Text property and get and set the Text using API calls (i.e.WM_GETTEXT ). The bug gets fixed.
|
|
|
|