Solved

Paint problem

Posted on 2003-11-15
3
201 Views
Last Modified: 2010-04-02

Iam using StretchDiBits to convert the DIB bitmap to Device context of

my window. It has some problem , sometimes it fails to paint the form DC

whenever i move the mouse over it get repainted.

I even tried using SetDIBitsToDevice , but it didn't  help

Is there i need to do , make this work , here is the code


ret=SetDIBitsToDevice(dc,mRect.left,mRect.Top,mWidth,mHeight,0,0,0,mHeight,pBits,bInfo,DIB_RGB_COLORS);
0
Comment
Question by:Manjesh
[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
3 Comments
 
LVL 1

Accepted Solution

by:
georgiek50 earned 100 total points
ID: 9790532
I am not sure if this is what you are talking about but I have a routine in my code that reads a bitmap and then cuts it up into the desired squares getting bitmap handles for each (this is after I've called LoadImage for the DIB)

void cMainSkin::LoadPartialBitmap(void)
{
      // Function to get a handle for each button bmp

      HDC hdcMain, hdcMem, hdcMem2;
      
      
      // Get main window DC and create a memory DC
      hdcMain = GetDC(hwndMain);
      hdcMem  = CreateCompatibleDC(hdcMain);
      hdcMem2 = CreateCompatibleDC(hdcMain);

      // Run a loop seven times for each button
      for (int i = 0; i < 7; i++)
      {
            // Create a compatible bitmap
            hButtonPartialBitmap[i] = CreateCompatibleBitmap(hdcMain, iButtonWidth[i][0],
                                                                                     iButtonHeight[i][0]
                                                                                    );

            // Select the bitmap into the second memory DC
            SelectObject(hdcMem2, hButtonPartialBitmap[i]);

            // Select the button bitmap into the first memory DC
            SelectObject(hdcMem, hButtonBitmap);

            // Copy the desired part of the bitmap into the second memory DC
            BitBlt(hdcMem2, 0, 0, iButtonWidth[i][0], iButtonHeight[i][0],
                     hdcMem, iButtonSourceX[i][0], iButtonSourceY[i][0],
                     SRCCOPY);
      }

      // Release DC
      ReleaseDC(hwndMain, hdcMain);

      // Delete memory DC
      DeleteDC(hdcMem);
      DeleteDC(hdcMem2);
}
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10249233
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: georgiek50 {http:#9790532}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: 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

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

688 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