Solved

Paint problem

Posted on 2003-11-15
3
194 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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now