Winform에서 DaumMapAPI를 컨트롤하기 위해

 

그동안 WebBrowser 컨트롤을 이용해 띄워었습니다.

 

잘 동작하는줄만 알았지만

 

문제가 하나 있었습니다.

 

 

 

 WebBrowser 컨트롤이 Focus를 잃었다가 다시 얻으면 Wheel Event가 발생되지 않는 문제였습니다.

 

 

 

 

해결한 내용입니다.

 

우선 WebBrowser컨트롤을 상속받은 Class에서 WndProc(윈도우 프로시져) 메서드를 override합니다.

 

그 후 아래의 코드를 작성합니다.

 

Msg 528은 마우스 Button Click에 관한 내용입니다.

 

 

 

mshtml.HTMLDocumentClass hDoc;

 

        private void DaumMapAPI_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)

        {

            this.hDoc = (mshtml.HTMLDocumentClass)this.Document.DomDocument;

        }

 

 

 

        protected override void WndProc(ref Message m)

        {

            //Mouse Button Click할때 포커스 발생시키기

            if (this.hDoc != null && m.Msg==528&&this.hDoc.hasFocus()==false)

                this.hDoc.focus();

            base.WndProc(ref m);

        }

 

 

 

 

 

 

 

 

 

+ Recent posts