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)
69정성태10/27/20064549.NET : 1. Typed DataSet 에서의 ExcludeSchema 사용
68정성태1/27/20075050Vista : 2. Elevate through ShellExecute
67정성태10/22/20064237Vista : 1. Programmatically determine if an application requires elevation
66정성태9/22/20064158Tip/Trick: UpdateProgress Control and AJAX Activity Image Animations
65정성태9/15/20069443Tip/Trick: Enabling Back/Forward-Button Support for ASP.NET AJAX UpdatePanel
64정성태2/23/20074367Why are NameValueCollection lookups slower than Hashtable? [Kim Hamilton]
63정성태8/30/20064258WinFormResizer for .NET 2.0, v.2.0.0020.3 Released!
62정성태8/21/20064064Stylistic differences in using
61정성태8/5/20064250Detecting Information Card Support (CardSpace!) in a browser
60정성태7/22/20064020JonGallant WebControls v1.0 - ScrollableContainer
59정성태3/2/20065312.NET이 왜 성공할 수밖에 없는가?
58정성태10/5/20055113한국 MSDN - 홈지기가 번역한 MSDN Magazine 자료
57정성태5/5/20054519구구단 프로그램을 제외하고, 벤더종속적이지 않은 프로그래밍 언어가 있나요?
53정성태3/4/20055839[마소 연재 기사: 2004-05] 특집 X-Inernet : 닷넷 스마트 클라이언트 [4]파일 다운로드1
52정성태3/4/20056084[마소 연재 기사: 2004-04] 실전!강의실 - IE에서 닷넷 스마트 클라이언트 개발 3파일 다운로드1
51정성태3/4/20056418[마소 연재 기사: 2004-03] 실전!강의실 - IE에서 닷넷 스마트 클라이언트 개발 2파일 다운로드1
55정성태3/30/20054868    답변글 [추가] 기본 보안만으로 구현하는 스마트 클라이언트 이벤트 구현
50정성태3/4/20058468[마소 연재 기사: 2004-02] 실전!강의실 - IE에서 닷넷 스마트 클라이언트 개발 1 [3]파일 다운로드1
49정성태9/7/20067685RSA 공개키/개인키 암호화, DES 암호화, MD5 단방향 해시 암호화 클래스 (C#) 2002.09.25파일 다운로드1
48정성태7/17/20035608C# 으로 만든 Base64 인코딩/디코딩 클래스 (C#) 2002.09.24파일 다운로드1
47정성태7/17/20034558C# 으로 만든 DLL 을 Managed C++ 에서 이용하는 예제 (C#, Managed C++) 2002.08.01파일 다운로드1
46정성태7/17/20034706.NET으로 만든 COM+ 객체를 HTML에서 사용 (C#, COM+) 2002.06.10파일 다운로드1
45정성태7/17/20034869COM+ 객체 원격 접근예제 (VC 6.0, ATL, COM+) 2002.05.31파일 다운로드1
44정성태7/17/20034805Win32 API Hook (VC 6.0, ATL) 2002.05.12파일 다운로드1
54정성태3/21/20054344    답변글 [추가]: 최근 나온 소개된 관련 기사파일 다운로드2
43정성태7/17/20035761탐색기 Namespace Extension 컨테이너 (VC 6.0, ATL) 2002.03.24파일 다운로드1
1  2  3  4  5  [6]  7  8