Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating a textbox from ISampleGrabberCB
    primarykey
    data
    text
    <p>I currently have a working program which displays a preview from my webcam and uses the ISampleGrabberCB interface.</p> <p>Using the <code>SampleCB</code> my program converts the image to a bitmap and then processes the image for a barcode which is then decoded. This works perfectly when I show the result using a <code>MessageBox</code> however when I wish to edit a textbox on my main form with this result I get a few errors when I start my program.</p> <p>I am trying to update my text box using the following code within the <code>ISampleGrabberCB</code> interface:</p> <pre><code>public int SampleCB(double sampletime, IMediaSample sample) { if (sample == null) { return -1; } try { int length = sample.GetActualDataLength(); IntPtr buffer; BitmapData bitmapData = new BitmapData(); Form1 f1 = new Form1("", "", ""); if (sample.GetPointer(out buffer) == 0 &amp;&amp; length &gt; 0) { Bitmap bitmapOfFrame = new Bitmap(width, height, pitch, PixelFormat.Format24bppRgb, buffer); } </code></pre> <p>The method changeTextBox1 is in my main form and is as follows:</p> <pre><code>public void changeTextBox1(string text) { textBox1.Text = text; } </code></pre> <p>The errors I get are firstly <code>A device attached to the system in not functioning properly</code> and then <code>no such supported interface</code>. This seems to only happen when I use the <code>Form1 f1 = new Form1("","","");</code> line.</p> <p>So as I said if i remove the line <code>Form1 f1 = new Form1("","","");</code> and replace <code>changeTextBox1(result.Text);</code> with <code>MessageBox.Show(result.Text.ToString());</code> this works.</p> <p>How would I go about updating the textbox instead of using a MessageBox?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload