본문 바로가기
VisualStudio.C++.C#/코딩팁,함수활용,단편

C++. Win32 API. MFC. SetCapture(), ReleaseCapture()

by i.got.it 2020. 9. 25.

SetCapture() , ReleaseCapture()는 win32 api , MFC CWnd 멤버함수 모두 제공됨. 

 

기능 : 마우스가 활성 윈도우 영역을 벗어난 경우에도 마우스 이벤트 받을 수 있게 하는것. 

 

 

HWND SetCapture( HWND hWnd );

Sets the mouse capture to the specified window belonging to the current thread.SetCapture captures mouse input either when the mouse is over the capturing window, or when the mouse button was pressed while the mouse was over the capturing window and the button is still down. Only one window at a time can capture the mouse.

If the mouse cursor is over a window created by another thread, the system will direct mouse input to the specified window only if a mouse button is down.

 

 

ReleaseCapture()

SetCapture()했던것을 다시 해제 하는것. 본인 코드에서 SetCapture() 사용 다했다면 ReleaseCapture() 해줘야 함. 

 

header file : winuser.h

 

docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setcapture

 

SetCapture function (winuser.h) - Win32 apps

Sets the mouse capture to the specified window belonging to the current thread.

docs.microsoft.com

 

CWnd::SetCapture() 

Return Value

A pointer to the window object that previously received all mouse input. It is NULL if there is no such window. The returned pointer may be temporary and should not be stored for later use.

Remarks

When CWnd no longer requires all mouse input, the application should call the ReleaseCapture function so that other windows can receive mouse input.

While mouse input is captured, no WM_NCHITTEST or WM_SETCURSOR messages are sent to the active window.

 

 

 

CWnd Class

 

docs.microsoft.com

 

연관 

드래그 드롭 구현 시 필수 활용됨. 

 

 

MFC. CListCtrl. 리스트 컨트롤.

InsertColumn int InsertColumn( int nCol, const LVCOLUMN* pColumn); int InsertColumn( int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1); InsertItem i..

igotit.tistory.com

 


첫 등록 : 2020.09.25

최종 수정 : 

단축 주소 : https://igotit.tistory.com/2625

 


 

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5