redrawing an image??

I have an image which is put in a static control after a button is pressed. When I re-size the application window the image disappears.

What can I do to stop this from happening??
ross_nolanAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
plarocheConnect With a Mentor Commented:
Your code doesn't work because your bitmap goes away. Try this:

if (doc->desk != NULL)
{
  CBitmap bm;
  CStatic* box = (CStatic*)CDesktopView::GetDlgItem
    (IDC_PIC2_STATIC);
  bm.LoadBitmap(IDC_PIC2_STATIC);
  box->SetBitmap(bm.Detach());
}

0
 
wyhjinCommented:
Please add the image to that static control again in the on-paint messge handler.
0
 
ross_nolanAuthor Commented:
I have already tried calling the buttons click method from the on_paint method, but kept getting an assertion error!!

Any ideas??
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
migelCommented:
You can manually update static window by InvalidateRect and UpdateWindow functions
0
 
wyy_cqCommented:
CStatic can be the bitmap container.
when you create the static control you need to set the SS_BITMAP flag .
and you need to load a bitmap and call CStatic::SetBitmap(...)

the code:
CBitmap bm;
bm.LoadBitmap(...);
static.SetBitmap(bm.Detach());

0
 
ross_nolanAuthor Commented:
Sorry but I tried the followinf code and it didn't work:

if (doc->desk != NULL)
{
  CBitmap bm;
  CStatic* box = (CStatic*)CDesktopView::GetDlgItem
    (IDC_PIC2_STATIC);
  bm.LoadBitmap(IDC_PIC2_STATIC);
  box->SetBitmap((HBITMAP )bm.operator HBITMAP());
}

Any ideas???
0
 
migelCommented:
Can you check position of the static control? May be with main window resizing  static has been moved outside parent client area?
0
 
ross_nolanAuthor Commented:
Sorry I get this error message when I put in the bm.Detach() method in the SetBitmap method as a parameter:

'SetBitmap' : cannot convert parameter 1 from 'void *' to 'struct HBITMAP__ *'

Any ideas????
0
 
plarocheCommented:
Cast the return value of Detach() with a HBITMAP....
0
 
ross_nolanAuthor Commented:
I tried adding in the return value of HBITMAP to the Detach() method but there was no difference

Please help!!
0
All Courses

From novice to tech pro — start learning today.