Post List

2014년 12월 25일 목요일

[MFC] Window7 이상에서 File Drag & Drop이 안될 때

Window 7 이상부터는 보안정책 때문에 File Drag and Drop의 구현이 안될때가 있다.
이유는 UIPI ( User Interface Priviege Isolation) 때문에 해당 작업이 걸러진다.
낮은 보안정책 Process (Explorer) 에서 높은 보안정책 Process (작업중은 프로그램) 으로의 많은 윈도우 메세지가 필터링 된다.
File Drag and Drop 도 그중 하나에 해당한다.

기본적인 Drag and Drop에 대한 구현 설명은 생략한다.

메세지처리를 하기 전에 반드시 거치는 PreTranslateMessage 함수를 override 하여 ChangeWindowMessageFilter 함수를 이용하는 방법이 있다.

for (int i = 0; i <= WM_DROPFILES; i++)
{
    ChangeWindowMessageFilter (i, MSGFLT_ADD);
}

 위와 같이 하면 정상적으로 동작한다. 하지만 너무 많은 메세지를 처리한다고 판단되면 File Drag and Drop의 경우 아래 3개만 바뀌도 동작한다.

ChangeWindowMessageFilter (WM_DROPFILES, MSGFLT_ADD);
ChangeWindowMessageFilter (WM_COPYDATA, MSGFLT_ADD);
ChangeWindowMessageFilter (0x0049, MSGFLT_ADD);




참조 : http://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/

댓글 없음:

댓글 쓰기