Solved

loading bitmaps on windows 98

Posted on 2003-11-11
7
323 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

911 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

20 Experts available now in Live!

Get 1:1 Help Now