'MFC'에 해당되는 글 2건

  1. 2007/04/23 euni MFC 키 입력 처리하는 방법
  2. 2007/03/21 euni How to embed and automate a Microsoft Excel worksheet with MFC
메시지 처리 전에 입력 값(키, 마우스 등)을 가로 채는 법
- PreTranslateMessage 을 구현한다.

ex)
http://support.microsoft.com/kb/601935/ko

HowTo : MFC Dialog상의 WebBrowser 컨트롤에서 키 입력 처리하는 방법

MFC에서 Dialog based로 어플리케이션을 만들고 만든 Dialog에 WebBrowser 컨트롤을 추가하면 특정 Web Page에서 [Enter]키를 누른 경우의 동작이 IE와 다른 경우가 있다. 이를 해결하기 위해서는 리소스 파일에서 디폴트로 만들어지는 [OK]버튼을 없애고 WebBrowser 컨트롤의 IOleInPlaceActiveObject의 TranslateAccelerator 메서드를 콜하여 키 입력 문제를 해결할 수 있다.

1. 리소스 파일을 편집하여 [OK]버튼 및 OnOK 함수를 없앤다.
2. MFC Dialog 클래스의 PreTranslateMessage 함수내에서 IOleInPlaceActiveObject의 TranslateAccelerator 메서드를 호출한다.


BOOL CWebCtrlDlg::PreTranslateMessage(MSG* pMsg)
{
  if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
  {
     TRACE("WM_KEYDOWN & VK_RETURN\n");
     IDispatch *pDisp = NULL;
     IOleInPlaceActiveObject *pActive = NULL;
     pDisp = m_ctrlWeb.GetDocument();
     HRESULT hr = pDisp->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pActive);
     pDisp->Release();

     if (S_OK == hr) {
          hr = pActive->TranslateAccelerator(pMsg);
          pActive->Release();
     }

     return hr;
  }

  return CDialog::PreTranslateMessage(pMsg);
}


크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
2007/04/23 17:09 2007/04/23 17:09
TAG ,
How to embed and automate a Microsoft Excel worksheet with MFC

http://support.microsoft.com/kb/184663/EN-US/


APPLIES TO
Microsoft Excel 2000 Standard Edition
Microsoft Visual C++ 5.0 Professional Edition
Microsoft Visual C++ 6.0 Professional Edition
Microsoft Foundation Class Library 4.2
Microsoft Office XP Developer Edition
Microsoft Office 2000 Developer Edition
Microsoft Excel 2002 Standard Edition
Microsoft Excel 97 Standard Edition

Keywords: kbprogramming kbautomation kbhowto kbinterop KB184663
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
2007/03/21 11:22 2007/03/21 11:22
TAG , ,