Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Very aggravating problem with VC++ Pin
Josh Knox19-Dec-00 10:46
Josh Knox19-Dec-00 10:46 
GeneralRe: Very aggravating problem with VC++ Pin
19-Dec-00 11:17
suss19-Dec-00 11:17 
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 
/*--------------------------------------------------------------*/
/*This function displays the captured bitmap in the window.It */
/*uses the palette of the captured bitmap so that colors are */
/*correct. */
/*--------------------------------------------------------------*/
void Paint(CDC* pDC,HPALETTE hPalette,HBITMAP hBitmap,LPRECT lpRect)
{
CDC * hDC;
CDC MemDC;
CPalette m_Palette;
CPalette * m_pPalette;

BITMAP bmInfo;

CBitmap m_Bitmap;
CBitmap *m_pBitmap;

hDC = pDC;
static int x=0;

//Get the BITMAP message of the hBitmap;
GetObject(hBitmap,sizeof(BITMAP),&bmInfo);

//Create the compatialbe bitmap for the m_Bitmap;
if(!m_Bitmap.CreateCompatibleBitmap(hDC,
(lpRect->right-lpRect->left),
(lpRect->bottom-lpRect->top)))
{
::MessageBox(NULL,"Error!","Error",MB_OK);
}

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

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

m_pBitmap = (CBitmap *)MemDC.SelectObject(&m_Bitmap);

if(m_pBitmap==NULL)
{
::MessageBox(NULL,"Error--SelectObject!","Error",MB_OK);
}
int x=bmInfo.bmWidth;
int y=bmInfo.bmHeight;
//The flowing will occur a error.
//But i can't find out why.
if(!hDC->StretchBlt(lpRect->left,lpRect->top,
(lpRect->right-lpRect->left),
(lpRect->bottom-lpRect->top),
// &MemDC,0,0,x,
// y,SRCCOPY))
&MemDC,0,0,bmInfo.bmWidth,
bmInfo.bmHeight,SRCCOPY))
{
char tt[266],tmpstr[10];
char * p;
strcpy(tt,"Error--StretchBlt!");
p=_itoa(x,tmpstr,10);
strcat(tt,p);
::MessageBox(NULL,tt,"Error",MB_OK);
x=0;
}
else
{
x++;
}

// StretchBlt(hDC,ps.rcPaint.left,ps.rcPaint.top,
// (ps.rcPaint.right-ps.rcPaint.left),
// (ps.rcPaint.bottom-ps.rcPaint.top),
// hMemDC,0,0,bmInfo.bmWidth,
// bmInfo.bmHeight,SRCCOPY);


if(hPalette)
hDC->SelectPalette(m_pPalette,FALSE);

//Detect whether the CDC work.
// CBrush br(RGB(0,255,0));
// hDC->FillRect(lpRect,&br);
}
// EndPaint(hWnd,&ps);
}

This articles come from Code Project.
Thank you in advance!
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 
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 

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.