Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image in picture box dissappears on resize

Status
Not open for further replies.

gvgeowiz

Programmer
Jul 8, 2004
3
US
My c# program is using a c++ dll to load an image from an avi clip and display it to a picture box via the picturebox.handle. To draw the picture I call the c++ function passing to it the picturebox.handle.
My problem comes when I need to resize the form (or when another window covers this). I have set the picturebox to resize with the form. I have events for Form_Resize and Form_Paint, which call the c++ function to draw the image. When I resize the form this is what I see in the stated order:
1. The picture box resizes properly
2. Then I seee the image drawn to the new size
3. Then the image dissappears.

Any suggestions, thanks!
 
The code is pretty simple and always works when I press button1. (also it works always in VB6, on resize as well) But I cannot get it to redraw using the form1_Resize event. The form and the picturebox redraw fine, but the image just flashes to the picturebox and then is gone. When I press button1 again the image draws just fine.
Is there a different event where I should place GT.ShowPic? It almost seems as if windows is calling another event after the form_resize event that causes the picturebox to go blank

private m_spath = "d:\\video\\testvideo.avi"
//Pic1 = a picturebox where I am trying to draw the image
private void button1_Click(object sender, System.EventArgs e)
{
//this method works great, it displays the image as expected
int lwdt=Pic1.Width;
int lhgt=Pic1.Height
//DisplayImg is a direct dll call
int lres = GT.ShowPic(m_spath, (int)m_lhwnd, lwdt, lhgt, m_lframe); //opens video(spath) and displays a frame(m_lframe) to the dc(m_lhwnd). The image is drawn in the dc starting at pixel 0,0, and drawn the specified height and width(lhgt,lwdt)
}

private void Form1_Resize(object sender, System.EventArgs e)
{
//resize Pic1 with the form
Pic1.Width=this.Width-Pic1.Left-10;
Pic1.Height=this.Height-Pic1.Top-30;
//display the image
int lwdt=Pic1.Width;
int lhgt=Pic1.Height
//DisplayImg is a direct dll call
int lres = GT.ShowPic(m_spath, (int)m_lhwnd, lwdt, lhgt, m_lframe); //see private void button1_Click fro details on parameters
}

 
It seems like I'm not anticipating/understanding some windows event. Because If, after a resize, I place a different window partially over my form and then move it more off my form, then part (yes only part) of the visible image appears. I've tried putting having form_paint and Pic1_paint and Pic_resize and form_resize all call GT.Show and none of these will redraw the image.

Help....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top