Solved

redrawing an image??

Posted on 1998-11-21
10
207 Views
Last Modified: 2013-11-20
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
Comment
Question by:ross_nolan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +2
10 Comments
 

Expert Comment

by:wyhjin
ID: 1325101
Please add the image to that static control again in the on-paint messge handler.
0
 

Author Comment

by:ross_nolan
ID: 1325102
I have already tried calling the buttons click method from the on_paint method, but kept getting an assertion error!!

Any ideas??
0
 
LVL 12

Expert Comment

by:migel
ID: 1325103
You can manually update static window by InvalidateRect and UpdateWindow functions
0
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!

 
LVL 2

Expert Comment

by:wyy_cq
ID: 1325104
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
 

Author Comment

by:ross_nolan
ID: 1325105
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
 
LVL 12

Expert Comment

by:migel
ID: 1325106
Can you check position of the static control? May be with main window resizing  static has been moved outside parent client area?
0
 
LVL 3

Accepted Solution

by:
plaroche earned 70 total points
ID: 1325107
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
 

Author Comment

by:ross_nolan
ID: 1325108
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
 
LVL 3

Expert Comment

by:plaroche
ID: 1325109
Cast the return value of Detach() with a HBITMAP....
0
 

Author Comment

by:ross_nolan
ID: 1325110
I tried adding in the return value of HBITMAP to the Detach() method but there was no difference

Please help!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question