Solved

loading bitmaps on windows 98

Posted on 2003-11-11
7
321 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
Comment Utility
Please show your code. What does this mean "bitmap never change"?
0
 

Author Comment

by:merlic
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:merlic
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi merlic,
Was that the problem? Did that work?
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now