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년 전
감사요
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 30 |
아우겐나이스
|
21년 전 | 4110 | |
| 29 |
아우겐나이스
|
21년 전 | 4485 | |
| 28 |
아우겐나이스
|
21년 전 | 3508 | |
| 27 | 21년 전 | 5889 | ||
| 26 | 21년 전 | 3168 | ||
| 25 | 21년 전 | 6146 | ||
| 24 | 18년 전 | 3704 | ||
| 23 | 21년 전 | 3698 | ||
| 22 | 21년 전 | 4286 | ||
| 21 | 21년 전 | 3877 | ||
| 20 | 21년 전 | 4284 | ||
| 19 | 21년 전 | 6730 | ||
| 18 | 21년 전 | 4776 | ||
| 17 | 21년 전 | 7023 | ||
| 16 | 21년 전 | 4215 | ||
| 15 | 21년 전 | 2681 | ||
| 14 | 21년 전 | 5015 | ||
| 13 | 21년 전 | 3439 | ||
| 12 |
Recluse
|
21년 전 | 3917 | |
| 11 |
아우겐나이스
|
21년 전 | 3600 | |
| 10 |
Recluse
|
21년 전 | 3441 | |
| 9 | 21년 전 | 4060 | ||
| 8 | 21년 전 | 5231 | ||
| 7 | 21년 전 | 4804 | ||
| 6 | 21년 전 | 5757 | ||
| 5 | 21년 전 | 4163 | ||
| 4 | 21년 전 | 4897 | ||
| 3 | 21년 전 | 4786 | ||
| 2 | 21년 전 | 3291 | ||
| 1 | 22년 전 | 4382 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기