Solved

loading bitmaps on windows 98

Posted on 2003-11-11
7
326 Views
Last Modified: 2010-04-02
it happens that, when i dinamically try to load a bitmap with the "CStatic::SetBitmap" instruction, it returns succesful on windows 2000. if i operate on windows 98 it fails because the bitmap never change. how can i do? is that a problem of service pack or there is no way to solve the problem? thanks
0
Comment
Question by:merlic
7 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9721066
Please show your code. What does this mean "bitmap never change"?
0
 

Author Comment

by:merlic
ID: 9721168
CBitmap bmpDiagn;
switch(value)
{
case 0:
    if(bmpDiagn.LoadBitmap(IDB_DIAG_0))
        ((CStatic*)GetDlgItem(IDC_BMP_DIAGN))->SetBitmap((HBITMAP)bmpDiagn);
    break;
case 1:
    if(bmpDiagn.LoadBitmap(IDB_DIAG_1))
        ((CStatic*)GetDlgItem(IDC_BMP_DIAGN))->SetBitmap((HBITMAP)bmpDiagn);
    break;
case 2:
    if(bmpDiagn.LoadBitmap(IDB_DIAG_2))
        ((CStatic*)GetDlgItem(IDC_BMP_DIAGN))->SetBitmap((HBITMAP)bmpDiagn);
    break;
}

even if "value" is 0, then 1, then 2, the bitmap always shows the image statically assigned with "Picture Properties". on window 2000 the same code allows to change the 3 images...
0
 
LVL 13

Expert Comment

by:SteH
ID: 9721423
Attention: Like this you have  a memory leak: SetBitmap returns the old HBITMAP and this should be freed with ::DestroyObject ().

Have you looked whether the load was succesfull under Win98?
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!

 

Author Comment

by:merlic
ID: 9721783
yes, LoadBitmap returns TRUE under both O.S.! this is the reason i don't understand where i mistake...
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 125 total points
ID: 9762988
try this:

static CBitmap bmpDiagn;  // or otherwise make it persist
...etc...

That CBitbap destructs at the end of the fn.  That means it releases its handle.  I don't know why it would work in one OS but not another, but there you go.

If that doesn't work, see if dragging another window over the dialog (and thus forcing a redraw) causes the new bitmap to be displayed.  If so, then use Invalidate() on the STATIC control.

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9784162
hi merlic,
Do you need more help?  Please communicate with the Experts who are helping you.  Thanks!
-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9785487
Hi merlic,
Was that the problem? Did that work?
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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

713 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