Solved

Blitting problems on win98

Posted on 2004-04-22
6
203 Views
Last Modified: 2010-04-01
My application has a custom UI like that of winamp.  What I do is blit to a DC them flip it to the HDC of my window.  This works great on win2000/xp but when I test the program on win98 the window turns black after a minute.  I have run boundschecker and cannot find any resource leaks or errors.  I'm pretty much using the C API's and have checked them all for compatibility and they seem fine.  Is there anything I'm missing here?
0
Comment
Question by:alsmorris
  • 2
6 Comments
 
LVL 6

Expert Comment

by:Mafalda
ID: 10897914
Are you sure that the video settings of both 2000 and 98 are similar ?
Maybe the black screen is caused by a video setting difference (including extra technologies installed like directx etc.)

If the environment is similar you would need to post the code so we could take a look at what you do.
0
 

Author Comment

by:alsmorris
ID: 10902358
Mafalda,

I'm not using DX just API's  here is the code.  it's called from a timer callback.



void CApplication::DrawBG()
{

      m_BitmapDC = ::CreateCompatibleDC(m_ParentDC);
      HBITMAP hOldBit = NULL;

      //top Left

      HBITMAP hBitmapTopLeft = (HBITMAP)::LoadBitmap(hInst,(LPCTSTR)IDB_APP_TOPLEFT);
      SIZE BitmapSizeTopLeft;

      BitmapSizeTopLeft.cx = 22;
      BitmapSizeTopLeft.cy = 27;
      

      hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapTopLeft);

      RECT rDraw;
      rDraw.left = 0;
      rDraw.top =0;
      rDraw.bottom = BitmapSizeTopLeft.cy;
      rDraw.right = BitmapSizeTopLeft.cx;
      
      
      ::BitBlt(      m_hDC,//      pDC,
                        0,
                        0,
                        BitmapSizeTopLeft.cx,
                        BitmapSizeTopLeft.cy,
                        m_BitmapDC,                              
                        0, 0,
                        SRCCOPY);      
      

      ::DeleteObject((HBITMAP)::SelectObject(m_BitmapDC,hBitmapTopLeft));


      //top right

      HBITMAP hBitmapTopRight = (HBITMAP)::LoadBitmap(hInst,(LPCTSTR)IDB_APP_TOPRIGHT);
      SIZE BitmapSizeTopRight;

      BitmapSizeTopRight.cx = 36;
      BitmapSizeTopRight.cy = 27;
      

      hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapTopRight);



      ::BitBlt(      m_hDC,//      pDC,
                        m_rUI.right - BitmapSizeTopRight.cx,
                        0,
                        BitmapSizeTopRight.cx,
                        BitmapSizeTopRight.cy,
                        m_BitmapDC,                              
                        0, 0,
                        SRCCOPY);      


      ::DeleteObject((HBITMAP)::SelectObject(m_BitmapDC,hBitmapTopRight));
      //top middle

      HBITMAP hBitmapTopMiddle = (HBITMAP)::LoadBitmap(hInst,(LPCTSTR)IDB_APP_TOPMIDDLE);
      SIZE BitmapSizeTopMiddle;

      BitmapSizeTopMiddle.cx = 9;
      BitmapSizeTopMiddle.cy = 27;
      

      hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapTopMiddle);
      int StartX = m_rUI.left + BitmapSizeTopLeft.cx;
      int StartY = 0;

      int nStrWidth =  (m_rUI.right - BitmapSizeTopRight.cx) - BitmapSizeTopMiddle.cx;
      

      ::StretchBlt(      m_hDC,
                              StartX ,
                              StartY,
                              nStrWidth,
                              BitmapSizeTopMiddle.cy,
                              m_BitmapDC,                              
                              0, 0,
                              BitmapSizeTopMiddle.cx,
                              BitmapSizeTopMiddle.cy,
                              SRCCOPY);      


      ::DeleteObject((HBITMAP)::SelectObject(m_BitmapDC,hBitmapTopMiddle));

      //Bottom Right
      HBITMAP hBitmapBottomRight = (HBITMAP)::LoadBitmap(hInst,(LPCTSTR)IDB_APP_BOTTOMRIGHT);
      SIZE BitmapSizeBottomRight;

      BitmapSizeBottomRight.cx = 99;
      BitmapSizeBottomRight.cy = 157;
      

      hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapBottomRight);



      ::BitBlt(      m_hDC,//      pDC,
                        m_rUI.right - BitmapSizeBottomRight.cx ,
                        m_rUI.bottom - BitmapSizeBottomRight.cy,
                        BitmapSizeBottomRight.cx,
                        BitmapSizeBottomRight.cy,
                        m_BitmapDC,                              
                        0, 0,
                        SRCCOPY);      


      ::DeleteObject((HBITMAP)::SelectObject(m_BitmapDC,hBitmapBottomRight));

//Bottom Left
      HBITMAP hBitmapBottomLeft = (HBITMAP)::LoadBitmap(hInst,(LPCTSTR)IDB_APP_BOTTOMLEFT);
      SIZE BitmapSizeBottomLeft;

      BitmapSizeBottomLeft.cx = 98;
      BitmapSizeBottomLeft.cy = 157;
      

      hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapBottomLeft);



      ::BitBlt(m_hDC,//      pDC,
                        0,
                        m_rUI.bottom - BitmapSizeBottomLeft.cy,
                        BitmapSizeBottomLeft.cx,
                        BitmapSizeBottomLeft.cy,
                        m_BitmapDC,                              
                        0, 0,
                        SRCCOPY);      
      ::DeleteObject((HBITMAP)::SelectObject(m_BitmapDC,hBitmapBottomLeft));

//Bottom Middle
      HBITMAP hBitmapBottomMiddle = (HBITMAP)::LoadBitmap(hInst,(LPCTSTR)IDB_APP_BOTTOMMIDDLE);
      SIZE BitmapSizeBottomMiddle;

      BitmapSizeBottomMiddle.cx = 17;
      BitmapSizeBottomMiddle.cy = 157;
      

      hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapBottomMiddle);

      StartX = m_rUI.left + BitmapSizeBottomLeft.cx;
      StartY = m_rUI.bottom - BitmapSizeBottomMiddle.cy;

      nStrWidth =  ((m_rUI.right - BitmapSizeBottomRight.cx) - BitmapSizeBottomMiddle.cx);
      
      ::StretchBlt(      m_hDC,
                              StartX ,
                              StartY,
                              nStrWidth -69,
                              BitmapSizeBottomMiddle.cy,
                              m_BitmapDC,                              
                              0, 0,
                              BitmapSizeBottomMiddle.cx,
                              BitmapSizeBottomMiddle.cy,
                              SRCCOPY);      

      ::DeleteObject((HBITMAP)::SelectObject(m_BitmapDC,hBitmapBottomMiddle));

//right

      HBITMAP hBitmapRight = (HBITMAP)::LoadBitmap(hInst,(LPCTSTR)IDB_APP_RIGHT);
      SIZE BitmapSizeRight;

      BitmapSizeRight.cx = 30;
      BitmapSizeRight.cy = 3;
      

      hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapRight);


      StartX = m_rUI.right - BitmapSizeRight.cx;
      StartY = BitmapSizeTopLeft.cy;
      int      nStrHeight = (m_rUI.bottom - BitmapSizeBottomRight.cy) - BitmapSizeTopLeft.cy;
      
      ::StretchBlt(      m_hDC,//      pDC,
                              StartX ,
                              StartY,
                              BitmapSizeRight.cx,
                              nStrHeight,
                              m_BitmapDC,                              
                              0, 0,
                              BitmapSizeRight.cx,
                              BitmapSizeRight.cy,
                              SRCCOPY);      


      ::DeleteObject((HBITMAP)::SelectObject(m_BitmapDC,hBitmapRight));

//left

      HBITMAP hBitmapLeft = (HBITMAP)::LoadBitmap(hInst,(LPCTSTR)IDB_APP_LEFT);
      SIZE BitmapSizeLeft;

      BitmapSizeLeft.cx = 21;
      BitmapSizeLeft.cy = 3;
      

      hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapLeft);


      StartX = 0;
      StartY = BitmapSizeTopLeft.cy;
      nStrHeight = (m_rUI.bottom - BitmapSizeBottomRight.cy) - BitmapSizeTopLeft.cy;

      ::StretchBlt(      m_hDC,//      pDC,
                              0 ,
                              StartY,
                              BitmapSizeRight.cx,
                              nStrHeight,
                              m_BitmapDC,                              
                              0, 0,
                              BitmapSizeRight.cx,
                              BitmapSizeRight.cy,
                              SRCCOPY);      
      //Cleanup
      ::DeleteObject((HBITMAP)::SelectObject(m_BitmapDC,hBitmapLeft));



      
      if (m_BitmapDC) {
            ::DeleteDC(m_BitmapDC);
            m_BitmapDC = NULL;
      }

}

void  CApplication::FlipScreen()
{


      ::BitBlt(      m_ParentDC,
                        0,
                        0,
                        m_nAppWidth,
                        m_nAppHeight,
                        m_hDC,                              
                        0, 0,
                        SRCCOPY);
      
}

0
 

Author Comment

by:alsmorris
ID: 10931501
Ok, I figured it out .. this seems to work on 98...

hOldBit = (HBITMAP)::SelectObject(m_BitmapDC,hBitmapTopLeft);

     RECT rDraw;
     rDraw.left = 0;
     rDraw.top =0;
     rDraw.bottom = BitmapSizeTopLeft.cy;
     rDraw.right = BitmapSizeTopLeft.cx;
     
     
     ::BitBlt(     m_hDC,//     pDC,
                    0,
                    0,
                    BitmapSizeTopLeft.cx,
                    BitmapSizeTopLeft.cy,
                    m_BitmapDC,                        
                    0, 0,
                    SRCCOPY);    
     
     /* WORKS ON 98 */

     ::SelectObject(m_BitmapDC,hOldBit);
     ::DeleteObject(hBitmapTopLeft);
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10966902
Closed, 500 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to convert c++ code to Android App 3 108
Fast access to array, using indexes, smart iterative search 2 118
Why isn't object file created? 6 69
How do i run a c++ file? 15 46
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

829 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