Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
부모글 보이기/감추기

별로 ^^; 특별한 팁은 아니지만,,, 그래도 하나의 "아이디어" 라고 할만한 것이기에 소개합니다.
그러니까, 문제는 스마트 클라이언트의 "이벤트" 발생이 기본적인 "Internet_Zone" 에 위배되기 때문에 어쩔 수 없이 클라이언트 측에 보안설정을 강요받게 되는 데요.

만약, 순전히 이벤트로 인한 보안설정만 필요한 경우라면 다음의 팁으로 해결하시는 것을 권해 드립니다. 모든 상황에서 쓸 수 있는 방법은 아니지만, 적절하게 쓸 수 있는 상황도 있을 것 같기 때문에. ^^


소스 출처 : http://msdn.microsoft.com/msdnmag/issues/04/10/WebQA/default.aspx

Q We are considering hosting a Windows Forms control in an Internet Explorer Web browser for an intranet Web application. In order to avoid the issue of passing managed events from the Windows Forms control back to unmanaged JScript® code (we may not be able to ask all of our users to make the security changes necessary to allow this), I am thinking of having the JScript code poll the Windows Forms control (maybe four times per second) inquiring, basically, whether any events have fired that the JScript code needs to know about. In rough form, the JScript would look something like this:

window.setInterval(checkWinformEvents, 250);
var bCheckingEvents;
function checkWinformEvents() {
      if(!bCheckingEvents) {
            bCheckingEvents = true;
            var sEvents = objWinform.AnyEventsToReport();
            bCheckingEvents = false;
            if (sEvents) handleWinformEvents(sEvents) ;
      }
}

The managed method, AnyEventsToReport, would then return something like "Double-click on line 14 of List view," and so on. Is it a good idea to check Windows Forms events from JScript?


A Having the JScript code poll the Windows Forms control seems a little weird, but it would give you a workaround for the security restrictions put in place by Internet Explorer. There are a few problems with the code snippet, but nothing that is insurmountable. For instance, where exactly do you make the second call to setInterval? No loop is evident.

The bottom line is that this program is really not robust in the face of exceptions. Plus, there's some uninitialized data in there and you treat a string as a bool, which is a bad idea. Also, why are you doing a re-entrancy check on a method which is not recursive?

You should probably write it like this instead:

window.setInterval(checkWinformEvents, 250) ;
function checkWinformEvents() 
{
    try
    {
        handleWinformEvents(winform.AnyEventsToReport());
    }
    finally
    {
      window.setInterval(checkWinformEvents, 250) ;
    }
}
[Editor's Update - 12/6/2004: setInterval evaluates an expression each time a specified number of milliseconds has elapsed and until the timer is removed with the clearInterval method. As such, it does not need to be called again every time the checkWinformEvents function is invoked.]






[최초 등록일: ]
[최종 수정일: 3/31/2005]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-동일조건변경허락 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.

비밀번호

댓글 작성자
 




1  2  3  4  5  6  [7]  8 
NoWriterDateCnt.TitleFile(s)
43정성태7/17/20035761탐색기 Namespace Extension 컨테이너 (VC 6.0, ATL) 2002.03.24파일 다운로드1
42정성태7/17/20034285KBManager WebBand (VC 6.0, ATL/Script) 2001.10.01파일 다운로드1
41정성태7/17/20034353UrlMonDownload (VC 6.0, ATL) 2001.06.16파일 다운로드1
40정성태7/17/20034303IE 북마크 임포트 (VC 6.0, ATL, MFC 지원) 2001.01.20파일 다운로드1
39정성태7/17/20034874MsIE.exe (VC 6.0, ATL, HTML Parser 로서의 IHTMLDocument2 이용 및 IE 보안설정) 2000.11.23파일 다운로드1
38정성태7/17/20034587EnumIE.exe (VC 6.0, ATL, 현재 사용 중인 IE에 접속) 2000.10.24파일 다운로드1
37정성태7/17/20034328ReuseIE.exe (VC ++ 6,0, Internet Explorer 재사용) 2000.04.17파일 다운로드1
36정성태7/17/20033930RemoteViewer dll (VC ++ 6.0, ATL) 2000.03.13파일 다운로드1
35정성태7/17/20034236IESpy dll (VC ++ 6.0, ATL) 2000.02.28파일 다운로드1
34정성태7/17/20033970Bmp2Gif 콘트롤 (VC ++ 6.0, MFC) 2000.02.28파일 다운로드1
33정성태7/17/20033787Gif89a 콘트롤 (VC ++ 6.0, ATL) 2000.02.28파일 다운로드1
32정성태7/17/20034293이미지 4버튼 (VC ++ 6.0, ATL) 2000.02.28파일 다운로드1
31정성태7/17/20033915이미지 홀더 (VC ++ 6.0, ATL) 2000.02.28파일 다운로드1
30정성태7/17/20034040이미지 뷰어 (VC ++ 6.0, ATL) 2000.02.28파일 다운로드1
29정성태7/17/20033823ChatClient (VC ++ 6.0, MFC) 1999.09.09파일 다운로드1
28정성태7/17/20035219Winsock2 SPI : LSP 예제 (VC ++ 6.0) 2001.08.07파일 다운로드1
27정성태7/17/20034328Echo Services Server (VC ++ 6.0, ATL Service) 2001.01.07파일 다운로드1
26정성태7/17/20037355FTP Client (VC ++ 6.0, MFC) 1999.09.14파일 다운로드1
25정성태7/17/20033722모뎀 정보를 알아내는 클래스 (VC ++ 6.0, MFC) 1999.09.12파일 다운로드1
24정성태7/17/20038452Ping (VC ++ 6.0, MFC, CSocket Class) 1999.09.09 [1]파일 다운로드1
23정성태7/21/20037415ChatServer / ChatClient (VC ++ 6.0, MFC, Win32 API Socket) 1999.08.01파일 다운로드2
22정성태7/17/20033881성능 객체 카운터 (VC 6.0, Win32) 2001.07.07파일 다운로드1
21정성태7/17/20033909StringSplit 클래스 (VC++6.0, Win32) 2000.02.28파일 다운로드1
20정성태7/17/20034177SQLDirect 클래스 (VC++6.0, Win32) 2000.02.28파일 다운로드1
19정성태7/17/20033577ImeControl 클래스 (VC++6.0, Win32) 2000.02.28파일 다운로드1
18정성태7/17/20034009RegistryEx 클래스 (VC++6.0, Win32) 2000.02.28파일 다운로드1
1  2  3  4  5  6  [7]  8