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)
120정성태9/14/20074770Vista : 7. Gadget Samples for Windows Sidebar
119정성태8/23/20075021.NET 3.5 : 3. WCF 서비스에서 HTTP 헤더 설정
118정성태6/20/20075532.NET 3.5 : 2. LINQ - 페이징 구현
117정성태6/20/20075190.NET : 23. Silverlight 응용 프로그램 제작
116정성태6/19/20075517.NET : 22. Bluetooth on Managed code [2]
115정성태6/17/20074885레지스트리 : 4. .NET Framework 및 Visual Studio 관련 레지스트리 키
114정성태6/9/20075239레지스트리 : 3. DWM enable/disable
113정성태6/9/20074701Vista : 6. 웹 사이트 추가/삭제 예제 코드
112정성태6/7/20074676Vista : 5. Transacted NTFS 코드 예제들
111정성태6/6/20074962.NET 3.5 : 1. LINQ 를 이용하여 DB 데이터를 XML 로 변환
110정성태6/2/20074855레지스트리 : 2. Aero Glass 효과를 느리게 보여주는 설정
109정성태5/19/200710384공통 코딩 규약 : 4. 닷넷 직렬화 방법 - 이진 직렬화(Binary Serialization) 사용 패턴
108정성태5/19/20074829공통 코딩 규약 : 3. 탭 문자 설정 [1]
107정성태5/11/20074722명령행 : 5. 비스타 - Auditing 관련 옵션 제어
106정성태5/11/20075697.NET 3.0 : 2. WPF - InvokeRequired 대신 CheckAccess 호출
105정성태5/9/20074488명령행 : 4. [PS] 같은 이름을 가진 프로세스 중에서 제일 먼저 띄운 인스턴스를 제외하고 모두 종료
104정성태5/3/20074469명령행 : 3. [롱혼] ServerManagerCmd.exe
103정성태4/18/20074514웹폼 코딩 규약 : 1. 서버측 웹폼 컨트롤 - 클라이언트 측 이벤트를 노출시키는 방법
102정성태4/18/20075920COM : 3. ActiveScript의 문법 오류 검사 [3]
101정성태4/18/20075121레지스트리 : 1. 비스타 - IIS 서비스 설치 여부
100정성태3/29/20074567명령행 : 2. AppPool 재시작
99정성태3/22/20074731명령행 : 1. 닷넷 웹 사이트 소스를 공유 폴더에 위치한 경우 설정
98정성태3/7/20075200.NET : 21. 저장 프로시저(SP)에 관한 스키마 정보 알아내기
97정성태3/7/20074554.NET 3.0 : 1. Boilerplate code for custom Encoder Binding Elements
96정성태3/7/20075287Vista : 4. 마스터 볼륨을 조정하는 방법
95정성태2/23/20074991.NET : 20. .Net Zip Library/Utility updates and fixes
1  2  3  [4]  5  6  7  8