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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 77 | 21년 전 | 2934 | ||
| 76 | 21년 전 | 6231 | ||
| 75 | 21년 전 | 4471 | ||
| 74 | 21년 전 | 5768 | ||
| 73 | 21년 전 | 3652 | ||
| 72 | 21년 전 | 5963 | ||
| 71 | 21년 전 | 3122 | ||
| 70 | 21년 전 | 2842 | ||
| 69 | 21년 전 | 2652 | ||
| 68 | 21년 전 | 2461 | ||
| 67 | 21년 전 | 2665 | ||
| 66 | 21년 전 | 2681 | ||
| 65 | 21년 전 | 3811 | ||
| 64 | 21년 전 | 2820 | ||
| 63 | 21년 전 | 2418 | ||
| 62 | 21년 전 | 2287 | ||
| 61 | 21년 전 | 3056 | ||
| 60 | 21년 전 | 3115 | ||
| 59 | 21년 전 | 2494 | ||
| 58 | 21년 전 | 2581 | ||
| 57 | 21년 전 | 2963 | ||
| 56 | 21년 전 | 2264 | ||
| 55 | 21년 전 | 2735 | ||
| 54 | 21년 전 | 2112 | ||
| 53 | 21년 전 | 2344 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기