c#을 활용하여 윈도우 어플리케이션을 개발 하던 도중 ,
html 페이지를 보여주야 되는 경우가 생겼으며, html내에 있는 flash 컨텐츠가 종료 되었을 때 어플리케이션도 같이
종료가 도어야 하는 상황이 발생 하였습니다.
그래서 구글링 하던 도중 좋은 예가 있어서 이렇게 올려 봅니다.
c#에서 javascript 이벤트를 catch하여 application 단에서 처리를 할 수 있을거 같습니다.
아레주소 눌러 보시면 보다 자세한 내용 보실 수 있습니다.
다음은 주요 소스 입니다.
결론적으로 WebBrowser를 확장해서 처리를 하더군요 . 아래 소스 보시면 이해 되실거라 생각 됩니다.
//Extend the WebBrowser control
public class ExtendedWebBrowser : WebBrowser
{
// Define constants from winuser.h
private const int WM_PARENTNOTIFY = 0x210;
private const int WM_DESTROY = 2;
AxHost.ConnectionPointCookie cookie;
WebBrowserExtendedEvents events;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_PARENTNOTIFY:
if (!DesignMode)
{
if (m.WParam.ToInt32() == WM_DESTROY)
{
Message newMsg = new Message();
newMsg.Msg = WM_DESTROY;
// Tell whoever cares we are closing
Form parent = this.Parent as Form;
if (parent!=null)
parent.Close();
}
}
DefWndProc(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
public class ExtendedWebBrowser : WebBrowser
{
// Define constants from winuser.h
private const int WM_PARENTNOTIFY = 0x210;
private const int WM_DESTROY = 2;
AxHost.ConnectionPointCookie cookie;
WebBrowserExtendedEvents events;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_PARENTNOTIFY:
if (!DesignMode)
{
if (m.WParam.ToInt32() == WM_DESTROY)
{
Message newMsg = new Message();
newMsg.Msg = WM_DESTROY;
// Tell whoever cares we are closing
Form parent = this.Parent as Form;
if (parent!=null)
parent.Close();
}
}
DefWndProc(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
댓글 1개
14년 전
감사요
게시판 목록
팁게시판
디자인과 관련된 유용한 정보를 공유하세요.
질문은 상단의 QA에서 해주시기 바랍니다.
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 102 | 21년 전 | 2228 | ||
| 101 | 21년 전 | 2559 | ||
| 100 | 21년 전 | 1732 | ||
| 99 | 21년 전 | 1588 | ||
| 98 | 21년 전 | 1633 | ||
| 97 | 21년 전 | 2137 | ||
| 96 | 21년 전 | 1874 | ||
| 95 | 21년 전 | 2388 | ||
| 94 | 21년 전 | 3588 | ||
| 93 | 21년 전 | 1588 | ||
| 92 | 21년 전 | 1757 | ||
| 91 | 21년 전 | 3167 | ||
| 90 | 21년 전 | 2347 | ||
| 89 | 21년 전 | 3172 | ||
| 88 | 21년 전 | 2874 | ||
| 87 | 21년 전 | 3298 | ||
| 86 | 21년 전 | 5115 | ||
| 85 | 21년 전 | 2532 | ||
| 84 | 21년 전 | 4826 | ||
| 83 | 21년 전 | 2495 | ||
| 82 | 21년 전 | 3115 | ||
| 81 | 21년 전 | 7609 | ||
| 80 | 21년 전 | 3830 | ||
| 79 | 21년 전 | 3217 | ||
| 78 | 21년 전 | 4690 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기