U E D R , A S I H C RSS

5인용C++스터디/더블버퍼링


    • ?
    • ?

>??

, () . , .

? . 틈틈 (Idle) .

해하 . . (Gang) 화 . .



~cpp 
#include "resource.h"

HBITMAP hBit, hBaby;

TCHAR szGang[]="Gang Version 1.0\r\n\r\n  :  \r\n"

" :  형\r\n  : \r\n협 :  ";

int my;

 

void DrawBitmap(HDC hdc,int x,int y,HBITMAP hBit)

{

HDC MemDC;

HBITMAP OldBitmap;

int bx,by;

BITMAP bit;

 

MemDC=CreateCompatibleDC(hdc);

OldBitmap=(HBITMAP)SelectObject(MemDC, hBit);

 

GetObject(hBit,sizeof(BITMAP),&bit);

bx=bit.bmWidth;

by=bit.bmHeight;

 

BitBlt(hdc,0,0,bx,by,MemDC,0,0,SRCCOPY);

 

SelectObject(MemDC,OldBitmap);

DeleteDC(MemDC);

}

 

void OnTimer()

{

RECT crt;

HDC hdc,hMemDC;

HBITMAP OldBit;

HFONT font, oldfont;

RECT grt;

int i,j;

 

GetClientRect(hWndMain,&crt);

hdc=GetDC(hWndMain);

 

if (hBit==NULL) {

    hBit=CreateCompatibleBitmap(hdc,crt.right,crt.bottom);

}

hMemDC=CreateCompatibleDC(hdc);

OldBit=(HBITMAP)SelectObject(hMemDC,hBit);

 

DrawBitmap(hMemDC,0,0,hBaby);

SetBkMode(hMemDC,TRANSPARENT);

 

font=CreateFont(30,0,0,0,0,0,0,0,HANGEUL_CHARSET,3,2,1,

    VARIABLE_PITCH | FF_ROMAN,"");

oldfont=(HFONT)SelectObject(hMemDC,font);

 

my--;

if (my==20) {

    KillTimer(hWndMain,1);

}

 

SetTextColor(hMemDC,RGB(192,192,192));

for (i=-1;i<=1;i++) {

    for (j=-1;j<=1;j++) {

       SetRect(&grt,10+i,my+j,400+i,my+300+j);

       DrawText(hMemDC,szGang,-1,&grt,DT_WORDBREAK);

    }

}

 

SetTextColor(hMemDC,RGB(32,32,32));

SetRect(&grt,10,my,400,my+300);

DrawText(hMemDC,szGang,-1,&grt,DT_WORDBREAK);

 

SelectObject(hMemDC,oldfont);

DeleteObject(font);

 

SelectObject(hMemDC,OldBit);

DeleteDC(hMemDC);

ReleaseDC(hWndMain,hdc);

InvalidateRect(hWndMain,NULL,FALSE);

}

 

LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)

{

HDC hdc,hMemDC;

PAINTSTRUCT ps;

HBITMAP OldBit;

RECT crt;

 

switch(iMessage) {

case WM_CREATE:

    hBaby=LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP1));

case WM_LBUTTONDOWN:

    SetTimer(hWnd,1,70,NULL);

    my=310;

    return 0;

case WM_TIMER:

    OnTimer();

    return 0;

case WM_PAINT:

    hdc=BeginPaint(hWnd, &ps);

    GetClientRect(hWnd,&crt);

    hMemDC=CreateCompatibleDC(hdc);

    OldBit=(HBITMAP)SelectObject(hMemDC, hBit);

    BitBlt(hdc,0,0,crt.right,crt.bottom,hMemDC,0,0,SRCCOPY);

    SelectObject(hMemDC, OldBit);

    DeleteDC(hMemDC);

    EndPaint(hWnd, &ps);

    return 0;

case WM_DESTROY:

    if (hBit) {

       DeleteObject(hBit);

    }

    DeleteObject(hBaby);

    PostQuitMessage(0);

    KillTimer(hWnd,1);

    return 0;

}

return(DefWindowProc(hWnd,iMessage,wParam,lParam));

}


. 행해 . .



편하 한 폰트 . . .

. Fade In, Fade Out 환 효 . 휘해 .

~cpp 
public:
	CBitmap MemBitmap;
	CDC MemDC;
	CPoint Position;

~cpp 
CTestView::CTestView()
{
	// TODO: add construction code here
	Position = CPoint(0, 0);

}

~cpp 
void CTestView::OnDraw(CDC* pDC)
{
	CTestDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	MemDC.FillSolidRect(0, 0, 1024, 768, RGB(255, 255, 255));
	MemDC.SelectStockObject(NULL_BRUSH);
	for(int i = 5 ; i <= 10 ; i++)
	{
		MemDC.Ellipse(Position.x - i, Position.y - i,
			Position.x + i, Position.y + i);
		MemDC.Rectangle(Position.x + 10 - i, Position.y + 10 - i,
			Position.x + 10 + i, Position.y + 10 + i);
	}
	//pDC->StretchBlt(0, 0, 102, 77, &MemDC, 0, 0, 1024, 768, SRCCOPY);
	pDC->BitBlt(0, 0, 1024, 768, &MemDC, 0, 0, SRCCOPY);
	// TODO: add draw code for native data here
}

~cpp 
int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	CDC *pDC = GetDC();
	MemDC.CreateCompatibleDC(pDC);
	MemBitmap.CreateCompatibleBitmap(pDC, 1024, 768);
	MemDC.SelectObject(&MemBitmap);
	ReleaseDC(pDC);
	SetTimer(1, 1000, NULL);
	
	
	
	// TODO: Add your specialized creation code here
	
	return 0;
}

void CTestView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	Invalidate();
	Position.x += 2;
	Position.y += 1;
	
	CView::OnTimer(nIDEvent);
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:18
Processing time 0.0337 sec