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)
145정성태5/6/20087051.NET : 30. XML Serializable Dictionary
144정성태3/28/20087676.NET : 29. WPF 응용 프로그램 - 웹캠으로 입력되는 스트림을 WMV 로 출력
143정성태3/28/20087971레지스트리 : 8. VHD 파일을 하드 디스크로 인식
142정성태3/26/20087302레지스트리 : 7. 아웃룩 2007의 제한된 첨부 파일을 허용하도록 설정
141정성태3/25/20087197레지스트리 : 6. 웹 브라우저(IE 8) 컨트롤 렌더링 모드 지정
140정성태2/23/20086601.NET : 28. 프로세스를 실행시켜주는 간단한 NT 서비스 제작 [1]
139정성태2/22/20085813.NET : 27. P/Invoke 를 이용한 메시지 서명 및 확인
138정성태2/21/20087336SMTP Commands
137정성태2/19/20085990.NET 3.5 : 5. LINQ to XML : Creating XML from another XML
136정성태2/1/20088117Win32 : 3. 사용자 개입없이 인증서 설치하는 코드 [2]
135정성태1/30/20085694COM : 5. Starting a Hyper-V Virtual Machine [3]
134정성태1/28/20085858Win32 : 2. How to generate key pairs, encrypt and decrypt data with CryptoAPI
133정성태1/16/20085927유틸리티 : 1. Writing Debugger extension program in C#
132정성태1/15/20086148VS.NET Addin - DB 연결 개체 추가
131정성태1/11/20086039기타 : 1. Maze Generator in C#
130정성태1/8/20086148VS.NET Addin - 프로젝트 닫기
129정성태1/2/20085882웹폼 코딩 규약 : 2. 서버측 ViewState 저장소
128정성태12/31/20075371레지스트리 : 5. List of registry keys affecting IIS7 behavior
127정성태12/21/20076095.NET : 26. CreateProcessWithLogonW / CreateProcessAsUser API 사용
126정성태12/20/20075118Win32 : 1. SLDF_RUNAS_USER
125정성태12/14/20075447.NET : 25. InfoPath 사용자 컨트롤
124정성태11/25/20075146SQL : 2. SQL Server 2008 에서 소개하는 spatial 데이터 타입
123정성태11/20/200711825.NET : 24. C# WebCam 사용자 컨트롤
122정성태11/17/20076238COM : 4. 외부 SMTP 를 지정하여 메일 보내기
121정성태9/14/20074919.NET 3.5 : 4. Entity Framework 관련 링크 모음
120정성태9/14/20074747Vista : 7. Gadget Samples for Windows Sidebar
1  2  [3]  4  5  6  7  8