Solved

Paint problem

Posted on 2003-11-15
3
198 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
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 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.

772 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