Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Blitting problems on win98

Posted on 2004-04-22
6
Medium Priority
?
207 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
[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
  • 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

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.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

715 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