?
Solved

loading bitmaps on windows 98

Posted on 2003-11-11
7
Medium Priority
?
330 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
[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
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 375 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.
Suggested Courses

649 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