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)
173정성태4/12/201111169레지스트리 : 11. BHO를 IE와 탐색기에서 선택적으로 로드하고 싶다면?
172정성태4/1/201110122.NET : 44. ContextBoundObject
171정성태3/30/20119996.NET 4.0 : 1. ASP.NET WF4 / WCF and Async Calls
170정성태3/25/20119780.NET 3.0 : 5. WCF How To’s Index [2]
169정성태3/10/201111175.NET : 43. 열려진 소켓 포트를 소유한 Process ID 구하는 방법 [2]
165정성태10/20/201010779레지스트리 : 10. 탐색기의 특정 폴더에 대해 Webdev.WebServer40.exe 로 호스팅을 시작하는 메뉴 추가
164정성태10/11/201010030.NET : 42. Writing Windows Shell Extension with .NET Framework 4 (C#, VB.NET)
163정성태8/27/20108828.NET : 41. Writing Files from Low-Integrity Processes
162정성태8/24/20108993.NET : 40. Self STS
161정성태5/16/201011916.NET : 39. #SNMP - C# Based Open Source SNMP for .NET and Mono
160정성태5/11/20108959.NET : 38. How to get info from client certificates issued by a CA (C#)
159정성태4/30/20108820.NET : 37. How to write a VS2010 Extension using Statement Lambdas
158정성태12/20/200922771명령행 : 6. 배치 파일에서 현재 디렉터리 알아내는 방법 [1]
157정성태11/12/20099536.NET : 36. Dictionary<,> 개체 직렬화
156정성태11/10/200910689.NET : 35. UDP 패킷의 경유 IP 설정 (Source Routing)
155정성태11/4/20099338.NET : 34. MSDeploy 명령행에 대응되는 C# 코드 예제
154정성태7/13/20098872.NET 3.0 : 4. WCF - 연결 개체 닫기
153정성태6/29/20098245.NET : 33. Creating audio signals in .NET
152정성태1/6/20098870.NET 3.0 : 3. WPF - StatefulUserControlBase.cs
151정성태1/1/200911557.NET : 32. Wake-On-Lan C# 코드 [1]
150정성태12/12/20088221.NET 3.5 : 7. ETW / .NET Framework 3.5
149정성태12/3/20088660Win32 : 4. Using Windows Vista Built-In Double Buffering
148정성태11/25/20087602.NET : 31. ThreadPool.UnsafeQueueNativeOverlapped [1]
147정성태11/21/20086870.NET 3.5 : 6. ProcessGeneratedCode
146정성태10/29/20086765레지스트리 : 9. How to detect what .NET Framework X service pack is installed
145정성태5/6/20087014.NET : 30. XML Serializable Dictionary
1  [2]  3  4  5  6  7  8