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)
95정성태2/23/20074982.NET : 20. .Net Zip Library/Utility updates and fixes
94정성태2/23/20074774COM : 2. VC++ - OneNote Addin 제작
93정성태2/3/20075602공통 코딩 규약 : 2. 프로퍼티와 공용 필드에 대한 선택 [1]
92정성태2/1/20074756공통 코딩 규약 : 1. HMACSHA512 / HMACSHA384 클래스 사용시 주의사항
91정성태1/27/20075038.NET : 19. HTML InnerText 구하기
90정성태1/27/20076688Vista : 3. 현재 사용자가 관리자 그룹에 속해 있는지 결정하는 코드
89정성태1/24/20074210.NET : 18. ASP.NET - AspNetHostingPermissionLevel 알아내기
88정성태1/22/20074485.NET : 17. 지역화된 폰트명 구하기
87정성태1/21/20075830.NET : 16. 클립보드 - HTML 텍스트 복사/붙여넣기
86정성태1/21/20074730.NET : 15. BinaryFormatter 에서의 진행 상태바 구현
85정성태1/20/20075672COM : 1. IE 7의 다중 탭을 이용한 네비게이션 [1]
84정성태1/19/20074574.NET : 14. 웹 서비스를 이용한 머신 간의 클립보드 공유
83정성태1/12/20074507.NET : 13. SafeHandles 를 적용한 GetProcAddress 래퍼
82정성태1/12/20074208.NET : 12. Cardspace 를 위한 ASP.NET 서버 컨트롤파일 다운로드1
81정성태1/12/20074538.NET : 11. 파일 확장자에 따른 아이콘 그려주는 HttpHandler [2]파일 다운로드1
80정성태1/10/20075258SQL : 1. SQL 2005 - 대소문자 구분없이 검색하도록 구현 [1]
79정성태1/10/20074156.NET : 10. Config 설정을 .NET Class 로 매핑
78정성태1/3/20074617.NET : 9. 텍스트 꾸미는 코드
77정성태12/13/20064810.NET : 8. C# - VARIANT 관련 마샬링 코드
76정성태12/6/20065385.NET : 7. 휴대 장치 열람하는 코드
75정성태12/6/20064491.NET : 6. 웹 서비스 메서드에 대해 완료 제한 시간 설정하는 방법
74정성태11/6/20064551.NET : 5. How to Decrypt an ASP.NET Encrypted Data
73정성태11/2/20065430.NET : 4. 콘솔 프로그램 실행시간 측정
72정성태11/1/20064697.NET : 3. System Monitoring 예제
70정성태11/1/20064247.NET : 2. System.Net.NetworkInformation.Ping 클래스 사용 예제
69정성태10/27/20064552.NET : 1. Typed DataSet 에서의 ExcludeSchema 사용
1  2  3  4  [5]  6  7  8