?
Solved

Paint problem

Posted on 2003-11-15
3
Medium Priority
?
202 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 400 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.

762 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