2009년 7월 29일 수요일

CString ASCII 변환 Key 찾기

 

CString을 한글자씩 잘라내 char* 로 변환 __toascii를 사용 ASCII로 변환

Key 13의 수량을 찾아 Enter key 를 확인한다.

 

CString strcomment;

 

for(int nSize = 0 ; nSize < strcomment.GetLength() ; nSize++)
 {
   CString strTemp = strcomment.Mid(nSize, 1);
   char* chrTemp;
   chrTemp = (LPSTR)(LPCTSTR)strTemp;
   int iAscii = __toascii(*(chrTemp));
   if(iAscii == 13)
    nCount = nCount+1;
 }

2009년 7월 28일 화요일

CDC 배경 삭제 이미지

 

dc 의 특정 색을 배경으로 삭제하고 사용 할 때

 

/// CRect rect  : DC rect

/// barSize : memDC. Size

/// COLOREEF : rgbBKColor (RGB 0, 0, 0) 배경 색상

 

 

pDC->TransparentBlt(rect.left, rect.top, rect.width(), rect.hight(), &memDC, 0, 0, barSize.cx, barSize.cy, rgbBKColor);

CDC bitmap Image 사용

DC에 그린 내용을 bit map Image 로 변환하여 제어한다.

 

CDC* pDC = GetDC(); /// 화면 DC

 

CDC memDC;

memDC.CreateCompatibleDC(pDC);  /// 메모리 DC

 

HBITMAP memBM = ::CreateCompatibleBitmap(pDC->m_hDC, stSize.x, stSize.y); /// Bitmap 생성

SelectObject(memDC, memBM);  /// 메모리 DC 에 Bitmap 적용

 

memDC.FilsolidRect(0, 0, stSize.x, stSize.y, RGB(200, 200, 200) ); /// 메모리 DC 에 그리기

 

pDC->SetStretchBltMode(COLORONCOLOR);  /// Color 변경없이

/// 이미지 늘리기

pDC->StretchBlt(10, 10, stSize.x-10, stSize.y-10, &memDC, 0, 0, m_stSize.x, stSize.y, SRCCOPY  );

 

/// 생성 객체 소멸

DeleteObject(memDC);

DeleteObject(memBM);

ReleaseDC(pDC);