?
Solved

redrawing an image??

Posted on 1998-11-21
10
Medium Priority
?
220 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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

770 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