반응형
http://www.devpia.com/forum/BoardView.aspx?no=438217&page=1&Tpage=6&forumname=vc_qa&stype=&ctType=&answer=&KeyR=title&KeyC=
클립보드에 Text 설정하기
===========================================================================
HGLOBAL hMem;
if( OpenClipboard() )
{
if( EmptyClipboard() )
{
hMem = GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE,
sizeof("원하는텍스트") );
if( hMem )
{
LPTSTR pClipData = (LPTSTR) GlobalLock(hMem);
pClipData[0] = 0;
strcpy( pClipData, "원하는텍스트" );
SetClipboardData( CF_OEMTEXT, hMem );
GlobalUnlock( hMem );
}
CloseClipboard();
GlobalFree( hMem );
}
}
클립보드 열고 -> 메모리생성해서 거기다 데이타 복사주해고 -> 클립보드 닫고, 메모리해제
클립보드는 락,언락을 해주어야 합니다..푸힛~리소스를 공유하기 때문이죠.
==========================================================================
http://www.devpia.com/forum/BoardView.aspx?no=438217&page=1&Tpage=6&forumname=vc_qa&stype=&ctType=&answer=&KeyR=title&KeyC=
비트맵 화면에 뿌려주가
==========================================================================
HDC hdc;
PAINTSTRUCT ps;
HBITMAP hBit,hOldBitmap;
HDC hMemDC;
BITMAP bmp;
if(::OpenClipboard(m_hWnd)){
hBit=(HBITMAP)GetClipboardData(CF_BITMAP);
CloseClipboard();
hdc=::GetDC(m_hWnd);
hMemDC=CreateCompatibleDC(hdc);
hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBit);
GetObject(hBit,sizeof(BITMAP),&bmp);
BitBlt(hdc,0,0,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCCOPY);
SelectObject(hMemDC,hOldBitmap);
DeleteDC(hMemDC);
::ReleaseDC(m_hWnd,hdc);
}
===========================================================================
http://www.devpia.com/forum/BoardView.aspx?no=438217&page=1&Tpage=6&forumname=vc_qa&stype=&ctType=&answer=&KeyR=title&KeyC=
클립보드에 데이터 복사 및 가져오기
===========================================================================
programming windows , charles petzold의 p679 내용 입니다.
<클립보드에 복사>
HGLOBAL hGlobal = GlobalAlloc(GHND | GMEM_SHARE, (lstrlen(pText) + 1) *sizeof(TCHAR));
PTSTR pGlobal = GlobalLock(hGlobal);
lstrcpy(pGlobal, TEXT("Hello"));
GlobalUnlock(hGlobal);
OpenClipboard(윈도우 핸들);
EmptyClipboard();
SetClipboardData(CF_TCHAR, hGlobal);
CloseClipboard();
<클립보드에서 가져오기>
OpenClipboard(윈도우 핸들);
HGLOBAL hGlobal = GetClipboardData(CF_TEXT);
char a[1024];
if(hGlobal)
{
PTSTR pGlobal = (char*)GlobalLock(hGlobal);
lstrcpy( a,pGlobal);
GlobalUnlock(hGlobal);
}
CloseClipboard();
클립보드에 Text 설정하기
===========================================================================
HGLOBAL hMem;
if( OpenClipboard() )
{
if( EmptyClipboard() )
{
hMem = GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE,
sizeof("원하는텍스트") );
if( hMem )
{
LPTSTR pClipData = (LPTSTR) GlobalLock(hMem);
pClipData[0] = 0;
strcpy( pClipData, "원하는텍스트" );
SetClipboardData( CF_OEMTEXT, hMem );
GlobalUnlock( hMem );
}
CloseClipboard();
GlobalFree( hMem );
}
}
클립보드 열고 -> 메모리생성해서 거기다 데이타 복사주해고 -> 클립보드 닫고, 메모리해제
클립보드는 락,언락을 해주어야 합니다..푸힛~리소스를 공유하기 때문이죠.
==========================================================================
http://www.devpia.com/forum/BoardView.aspx?no=438217&page=1&Tpage=6&forumname=vc_qa&stype=&ctType=&answer=&KeyR=title&KeyC=
비트맵 화면에 뿌려주가
==========================================================================
HDC hdc;
PAINTSTRUCT ps;
HBITMAP hBit,hOldBitmap;
HDC hMemDC;
BITMAP bmp;
if(::OpenClipboard(m_hWnd)){
hBit=(HBITMAP)GetClipboardData(CF_BITMAP);
CloseClipboard();
hdc=::GetDC(m_hWnd);
hMemDC=CreateCompatibleDC(hdc);
hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBit);
GetObject(hBit,sizeof(BITMAP),&bmp);
BitBlt(hdc,0,0,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCCOPY);
SelectObject(hMemDC,hOldBitmap);
DeleteDC(hMemDC);
::ReleaseDC(m_hWnd,hdc);
}
===========================================================================
http://www.devpia.com/forum/BoardView.aspx?no=438217&page=1&Tpage=6&forumname=vc_qa&stype=&ctType=&answer=&KeyR=title&KeyC=
클립보드에 데이터 복사 및 가져오기
===========================================================================
programming windows , charles petzold의 p679 내용 입니다.
<클립보드에 복사>
HGLOBAL hGlobal = GlobalAlloc(GHND | GMEM_SHARE, (lstrlen(pText) + 1) *sizeof(TCHAR));
PTSTR pGlobal = GlobalLock(hGlobal);
lstrcpy(pGlobal, TEXT("Hello"));
GlobalUnlock(hGlobal);
OpenClipboard(윈도우 핸들);
EmptyClipboard();
SetClipboardData(CF_TCHAR, hGlobal);
CloseClipboard();
<클립보드에서 가져오기>
OpenClipboard(윈도우 핸들);
HGLOBAL hGlobal = GetClipboardData(CF_TEXT);
char a[1024];
if(hGlobal)
{
PTSTR pGlobal = (char*)GlobalLock(hGlobal);
lstrcpy( a,pGlobal);
GlobalUnlock(hGlobal);
}
CloseClipboard();
반응형
'공부 > 컴퓨터' 카테고리의 다른 글
[MFC] 조합키 눌러진것 알아 내기 (0) | 2004.09.23 |
---|---|
새폴더 , 새폴더(1), 새폴더(2) 만들기.... (0) | 2004.09.21 |
[운영체제] Process, Program, Thread 등의 설명 (0) | 2004.09.15 |
[MFC] 웹문서의 이미지와 텍스트를 하나의 문서로 저장 ( mhtml ) (0) | 2004.09.08 |
[MFC] CListCtrl에서 헤더 클릭으로 소팅 시키기. (0) | 2004.09.08 |