Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Blitting problems on win98

Posted on 2004-04-22
6
Medium Priority
?
208 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
4 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

876 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