Click here to Skip to main content
15,918,742 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Very aggravating problem with VC++ Pin
Peter Andersson19-Dec-00 12:12
Peter Andersson19-Dec-00 12:12 
GeneralRe: Very aggravating problem with VC++ Pin
l a u r e n21-Dec-00 19:41
l a u r e n21-Dec-00 19:41 
GeneralRe: Very aggravating problem with VC++ Pin
Julien19-Dec-00 16:35
Julien19-Dec-00 16:35 
GeneralRe: Very aggravating problem with VC++ Pin
Josh Knox21-Dec-00 5:04
Josh Knox21-Dec-00 5:04 
GeneralRe: Very aggravating problem with VC++ Pin
Julien21-Dec-00 11:01
Julien21-Dec-00 11:01 
GeneralA error occur when calling the StretchBlt function.Please help me. Pin
Huabing Yan19-Dec-00 1:04
Huabing Yan19-Dec-00 1:04 
GeneralRe: A error occur when calling the StretchBlt function.Please help me. Pin
Christian Graus19-Dec-00 11:09
protectorChristian Graus19-Dec-00 11:09 
GeneralThank you! I have succeeded. Pin
Huabing Yan19-Dec-00 14:58
Huabing Yan19-Dec-00 14:58 
The flowing is my right code.
The cause of the error is that i call CreateCompatibleBitmap to create the compatible bitmap without the bmInfo.bmWidth and bmInfo.bmHeight.And there are other causes.
The right code is:


void Paint(CDC* pDC,HPALETTE hPalette,HBITMAP hBitmap,LPRECT lpRect)
{
CDC * hDC;
CDC MemDC;
CPalette m_Palette;
CPalette * m_pPalette;
CPalette * m_tmpPalette;

BITMAP bmInfo;

CBitmap m_Bitmap;
CBitmap *m_pBitmap;
CBitmap *m_tmpBitmap;

hDC = pDC;
static int xx=0;

//Get the BITMAP message of the hBitmap;

Sleep(1000);

GetObject(hBitmap,sizeof(BITMAP),&bmInfo);

//Create the compatialbe bitmap for the m_Bitmap;
if(!m_Bitmap.CreateCompatibleBitmap(hDC,
bmInfo.bmWidth,
bmInfo.bmHeight))
{
::MessageBox(NULL,"Error!","Error",MB_OK);
}

//Set the HBITMAP to the hBitmap;
if((m_tmpBitmap=m_Bitmap.FromHandle(hBitmap))==NULL)
{
::MessageBox(NULL,"Error--FromHandle!","Error",MB_OK);
};

if(MemDC.CreateCompatibleDC(hDC))
{
if(hPalette)
{
m_tmpPalette=m_Palette.FromHandle(hPalette);
m_pPalette=(CPalette *)hDC->SelectPalette(m_tmpPalette,FALSE);
}

m_pBitmap = (CBitmap *)MemDC.SelectObject(m_tmpBitmap);

if(m_pBitmap==NULL)
{
::MessageBox(NULL,"Error--SelectObject!","Error",MB_OK);
}
hDC->SetStretchBltMode(COLORONCOLOR);
if(!hDC->StretchBlt(lpRect->left,lpRect->top,
(lpRect->right-lpRect->left),
(lpRect->bottom-lpRect->top),
&MemDC,0,0,bmInfo.bmWidth,
bmInfo.bmHeight,SRCCOPY|DSTINVERT))
{
char tt[266],tmpstr[10];
char * p;
strcpy(tt,"Error--StretchBlt!");
p=_itoa(xx,tmpstr,10);
strcat(tt,p);
::MessageBox(NULL,tt,"Error",MB_OK);
xx=0;
}
else
{
xx++;
}
m_tmpBitmap->DeleteTempMap();
MemDC.SelectObject(m_pBitmap);


if(hPalette)
{
m_tmpPalette->DeleteTempMap;
hDC->SelectPalette(m_pPalette,FALSE);
}
}
}



This articles come from Code Project.
Thank you!
GeneralSuperGrid Pin
18-Dec-00 23:57
suss18-Dec-00 23:57 
GeneralRe: SuperGrid Pin
19-Dec-00 2:37
suss19-Dec-00 2:37 
GeneralProblem with Access file and Class Wizard Pin
Wolfram Steinke18-Dec-00 23:05
Wolfram Steinke18-Dec-00 23:05 
GeneralRe: Problem with Access file and Class Wizard Pin
Steve Driessens19-Dec-00 2:01
Steve Driessens19-Dec-00 2:01 
GeneralRe: Problem with Access file and Class Wizard Pin
19-Dec-00 2:22
suss19-Dec-00 2:22 
GeneralCreating Single instance Application Pin
18-Dec-00 17:24
suss18-Dec-00 17:24 
GeneralRe: Creating Single instance Application Pin
Kannan18-Dec-00 18:15
Kannan18-Dec-00 18:15 
GeneralRe: Creating Single instance Application Pin
Bartosz Lizak20-Dec-00 0:06
Bartosz Lizak20-Dec-00 0:06 
Questionhow to use timers in a non MFC class? Pin
Joan M18-Dec-00 11:21
professionalJoan M18-Dec-00 11:21 
AnswerRe: how to use timers in a non MFC class? Pin
Bartosz Lizak18-Dec-00 21:54
Bartosz Lizak18-Dec-00 21:54 
GeneralRe: how to use timers in a non MFC class? Pin
Erik Funkenbusch19-Dec-00 11:21
Erik Funkenbusch19-Dec-00 11:21 
GeneralRe: how to use timers in a non MFC class? Pin
Bartosz Lizak19-Dec-00 23:51
Bartosz Lizak19-Dec-00 23:51 
GeneralWinamp Style Ticker... Pin
18-Dec-00 9:20
suss18-Dec-00 9:20 
GeneralRe: Winamp Style Ticker... Pin
Bartosz Lizak18-Dec-00 22:07
Bartosz Lizak18-Dec-00 22:07 
GeneralMessageBeep(...) for specified length of time Pin
David Wulff18-Dec-00 5:16
David Wulff18-Dec-00 5:16 
GeneralRe: MessageBeep(...) for specified length of time Pin
18-Dec-00 9:06
suss18-Dec-00 9:06 
GeneralIP of Linksys Router (Cable) Pin
Todd Hoop18-Dec-00 3:47
Todd Hoop18-Dec-00 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.