Solved

loading bitmaps on windows 98

Posted on 2003-11-11
7
324 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

810 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