[visual C#] 어플 제작중 Application에서 html 페이지를 보여줄 경우 close되는 시점잡기 정보
Flash [visual C#] 어플 제작중 Application에서 html 페이지를 보여줄 경우 close되는 시점잡기본문
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
1
댓글 1개
감사요