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;
}
}
게시글 목록
| 번호 | 제목 |
|---|---|
| 384 | |
| 12508 |
JavaScript
서버시간 알아내기
|
| 383 | |
| 381 | |
| 20395 | |
| 12507 | |
| 12506 | |
| 12505 | |
| 12504 |
웹서버
서버 동시접속자 설정 변경하기
|
| 12503 | |
| 12502 | |
| 12500 | |
| 12499 | |
| 12498 |
MySQL
테이블 복사 쿼리
|
| 20392 | |
| 12497 |
PHP
현재 접속중인 사용자 나타내기
|
| 12496 |
MySQL
mysql select 후 update 하기
|
| 12495 | |
| 12494 |
PHP
한글문자열 자르는 법 입니다.
|
| 12493 | |
| 12492 | |
| 12491 |
PHP
이메일주소 검사하기 입니다.
|
| 12490 | |
| 12489 | |
| 12488 |
node.js
Node js 게시판 프로젝트 소개합니다.
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기