[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

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??
0
ross_nolan
Asked:
ross_nolan
  • 4
  • 2
  • 2
  • +2
1 Solution
 
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
 
migelCommented:
You can manually update static window by InvalidateRect and UpdateWindow functions
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
plarocheCommented:
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
 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now