2006”N10ŒŽ09“ú

IME Œ»Ý“ü—Í’†

âŽ^•ú’u’†‚Ì“–ƒTƒCƒg‚Å‚·‚ªA—��Î‚ɂ�}‚�}‚Ü‚Å•ú‚Á‚�N‚­‚͍̂�}‚©‹C‚Ü‚¸‚��‚̂ŏêŒq‚��“I‚ɍXVBŽžŠÔ‚Í‚Ç‚¤‚Æ‚Å‚à‚·‚é‚ñ‚Å‚·‚ªA‚Ç‚¤‚É‚àS‚̋Րü‚ɐG‚ê‚éƒlƒ^‚ª–³‚��‚ñ‚Å‚·‚æ‚Ë‚\ccB

‚³‚āA¡‰ñ‚̍XV‚Í–^ŒfŽ¦”‚Ƀqƒ“ƒg‚𓾂āAIME ‚ðŽg—p‚µ‚Ä‚Ì“ü—Í’†‚©‚Ç‚¤‚©Žæ“¾‚·‚éƒNƒ‰ƒX‚Å‚·B“ü—Í’†‚©‚Ç‚¤‚©‚̏ó‘Ô‚ª•Ï‚í‚Á‚½Žž‚ɂ̓Cƒxƒ“ƒg‚𔭐��‚³‚¹‚Ü‚·B‚Æ‚ÍŒ¾‚Á‚Ä‚à‚²‚­ŠÈ’P‚Ƃ��‚¤‚©Žè”²‚«‚ŁAWM_IME_STARTCOMPOSITION ‚Æ WM_IME_ENDCOMPOSITION ‚ðŠÄŽ‹‚µ‚��‚邾‚¯‚Å‚·‚̂ŁAƒCƒ“ƒXƒ^ƒ“ƒXï¿½ï¿½ï¿½ï¿½Žž‚É“ü—Í’†‚¾‚Á‚½ê‡‚͈ê’U“ü—Í‚ªI—¹‚·‚é‚܂Ő³‚µ‚��’l‚ð•Ô‚µ‚Ü‚¹‚ñB

¡‰ñ‚̃\[ƒX‚Ì‹Zp“I‚ȉðà‚ð­XB

WM_IME_STARTCOMPOSITION / WM_IME_ENDCOMPOSITION ƒƒbƒZ[ƒW‚́AŽÀÛ‚É“ü—Í’†‚̃Rƒ“ƒgƒ[ƒ‹‚ɑ΂µ‚Ä‘—M‚³‚ê‚Ü‚·B‚‚܂èA•’Ê‚É‚â‚낤‚Æ‚·‚é‚ƁAŽg—p‚·‚é‘S‚Ä‚Ì“ü—Í—pƒRƒ“ƒgƒ[ƒ‹‚ɂ‚��‚Ä”hï¿½ï¿½ƒRƒ“ƒgƒ[ƒ‹‚ð—pˆÓ‚·‚é‚© NativeWindow ‚ð—pˆÓ‚·‚é‚©‚µ‚ăƒbƒZ[ƒW‚ð•ß‚Ü‚¦‚È‚­‚Ä‚Í‚È‚è‚Ü‚¹‚ñB‚»‚µ‚Ä‚»‚ê‚ÍŒ»ŽÀ“I‚ł͂Ȃ��‚Å‚µ‚傤B¡‰ñ‚Í‚»‚Ì–â‘è‚ð‰ðŒˆ‚·‚邽‚߁AƒƒbƒZ[ƒW‚ðŽóM‚·‚é‘匳‚Å•ß‚Ü‚¦‚é‚悤‚É‚µ‚��‚Ü‚·B‚»‚ꂪ IMessageFilter ƒCƒ“ƒ^[ƒtƒFƒCƒX‚Å‚·B

IMessageFilter ‚ðŽÀ‘•‚µ‚½ƒNƒ‰ƒX‚ð Application.AddMessageFilter ƒƒ\ƒbƒh‚Å“o˜^‚·‚鎖‚É‚æ‚èAƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚Ɂi‘½•ªŒµ–��‚ɂ̓AƒvƒŠƒP[ƒVƒ‡ƒ“ƒRƒ“ƒeƒLƒXƒg‚̃XƒŒƒbƒhƒƒbƒZ[ƒWƒLƒ…[‚Ɂj‘—M‚³‚ꂽƒƒbƒZ[ƒW‚ɑ΂µ‚āAƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ªˆ—‚·‚é‘OiŠeƒRƒ“ƒgƒ[ƒ‹‚Ö‘—‚é‘Oj‚É“ÆŽ©ˆ—‚ðŽ{‚·Ž–‚ª‰Â”\‚É‚È‚è‚Ü‚·B

‚¿‚Ȃ݂ɁAIMessageFilter ‚̓‚[ƒ_ƒ‹/ƒ‚[ƒhƒŒƒXƒ_ƒCƒAƒƒO‚Ȃǂɂ‚��‚Ä‚à—LŒø‚Å‚·‚ªA•ÊƒXƒŒƒbƒh‚ōìï¿½ï¿½‚³‚ꂽƒRƒ“ƒgƒ[ƒ‹‚ɂ‚��‚Ă͈µ‚¦‚Ü‚¹‚ñB‚Ü‚ A•’Ê‚Í‚»‚à‚»‚à‚»‚ñ‚ȃRƒg‚µ‚Ȃ��‚Å‚µ‚傤‚ªB

¡‰ñ‚̃\[ƒX‚̓JƒXƒ^ƒ€ƒCƒxƒ“ƒg‚ðŽg‚¦‚Ȃ�� VB7.0/7.1iVB2002/2003j‚͑Ήž‚µ‚��‚Ü‚¹‚ñB‚Ü‚  Component.Events ‚ªŽg‚¦‚Ȃ��‚¾‚¯‚Å‚·‚̂ŁA‚»‚ÌŽü•Ó‚ðƒJƒXƒ^ƒ€ƒCƒxƒ“ƒg‚��‚á‚È‚­‚Ä•’ʂ̃Cƒxƒ“ƒg‚ŏˆ—‚·‚é‚悤‚É‚·‚ê‚ΈڐA‚͓‚��Ž–‚ł͂Ȃ��‚Å‚µ‚傤B

// C#
using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace HongliangSoft.Utilities.IO {
    [DefaultEvent("ConversionChanged")]
    public class ImeStatus : Component, IMessageFilter {
        public ImeStatus() {
            Application.AddMessageFilter(this);
        }
        public ImeStatus(IContainer container) : this() {
            if (container != null)
                container.Add(this);
        }
        private static readonly object EventConversionChanged
            = new object();
        private bool isConversion = false;
        [Browsable(false)]
        public bool IsConversion {
            get { return this.isConversion; }
        }
        public event EventHandler ConversionChanged {
            add    {
                this.Events.AddHandler(EventConversionChanged, value);
            }
            remove {
                this.Events.RemoveHandler(EventConversionChanged, value);
            }
        }
        protected override void Dispose(bool disposing) {
            if (disposing) {
                Application.RemoveMessageFilter(this);
            }
            base.Dispose(disposing);
        }
        public bool PreFilterMessage(ref Message m) {
            const int WmStartComposition = 0x10D;
            const int WmEndComposition = 0x10E;
            switch (m.Msg) {
              case WmStartComposition :
                this.isConversion = true;
                OnConversionChanged(EventArgs.Empty);
                break;
              case WmEndComposition :
                this.isConversion = false;
                OnConversionChanged(EventArgs.Empty);
                break;
            }
            return false;
        }
        protected virtual void OnConversionChanged(EventArgs e) {
            EventHandler handler
                = this.Events[EventConversionChanged] as EventHandler;
            if (handler != null)
                handler(this, e);
        }
    }
}
' VB8.0
Imports System
Imports System.ComponentModel
Imports System.Windows.Forms

Namespace HongliangSoft.Utilities.IO
   <DefaultEvent("ConversionChanged")> _
   Public Class ImeStatus
      Inherits Component
      Implements IMessageFilter

      Public Sub New()
         Application.AddMessageFilter(Me)
      End Sub

      Public Sub New(ByVal container As IContainer)
         If container IsNot Nothing Then
            container.Add(Me)
         End If
      End Sub
      Private ReadOnly Shared EventConversionChanged As New Object()
      Private m_isConversion As Boolean = False

      <Browsable(False)> _
      Public ReadOnly Property IsConversion() As Boolean
         Get
            Return Me.m_isConversion
         End Get
      End Property
      Public Custom Event ConversionChanged As EventHandler
         AddHandler(ByVal value As EventHandler)
            Me.Events.AddHandler(EventConversionChanged, value)
         End AddHandler
         RemoveHandler(ByVal value As EventHandler)
            Me.Events.RemoveHandler(EventConversionChanged, value)
         End RemoveHandler
         RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)
            Dim handler As EventHandler = _
               TryCast(Me.Events(EventConversionChanged), _
                       EventHandler)
            If handler IsNot Nothing Then
               handler(sender, e)
            End If
         End RaiseEvent
      End Event

      Protected Overrides Sub Dispose(ByVal disposing As Boolean)
         If disposing Then
            Application.RemoveMessageFilter(Me)
         End If
         MyBase.Dispose(disposing)
      End Sub

      Public Function PreFilterMessage(ByRef m As Message) As Boolean _
                            Implements IMessageFilter.PreFilterMessage
         Const WmStartComposition As Integer = &H10D
         Const WmEndComposition As Integer = &H10E
         Select Case m.Msg
            Case WmStartComposition
               Me.m_isConversion = True
               Me.OnConversionChanged(EventArgs.Empty)
            Case WmEndComposition
               Me.m_isConversion = False
               Me.OnConversionChanged(EventArgs.Empty)
         End Select
         Return False
      End Function

      Protected Overridable Sub OnConversionChanged(ByVal e As EventArgs)
            RaiseEvent ConversionChanged(Me, e)
      End Sub
   End Class
End Namespace
posted by Hongliang at 02:41| Comment(0) | TrackBack(0) | .NET | ‚}‚̃uƒƒO‚Ì“ÇŽÒ‚É‚È‚é | XVî•ñ‚ðƒ`ƒFƒbƒN‚·‚é
‚�}‚Ì‹LŽ–‚ւ̃Rƒƒ“ƒg
ƒRƒƒ“ƒg‚ð‘‚­
‚�N–¼‘O:

ƒ[ƒ‹ƒAƒhƒŒƒX:

ƒz[ƒ€ƒy[ƒWƒAƒhƒŒƒX:

ƒRƒƒ“ƒg:

”FØƒR[ƒh: [•K{“ü—Í]


¦‰æ‘œ‚Ì’†‚̕��Žš‚𔼊p‚Å“ü—Í‚µ‚Ä‚­‚¾‚³‚��B

‚�}‚Ì‹LŽ–‚ւ̃gƒ‰ƒbƒNƒoƒbƒN

‚�}‚�}ihongliang.seesaa.netj‚ÅŒöŠJ‚µ‚��‚é‚à‚̂ɂ‚��‚āA—˜—p‚ÍŽ©—R‚ɍs‚Á‚Ä’¸‚��‚č\‚��‚Ü‚¹‚ñB‰ü•ÏAÄ”Еz‚à‚�ND‚«‚É‚È‚³‚Á‚ĉº‚³‚��B—˜—p‚ɑ΂µ‚�}‚¿‚炪‰½‚©‚ð—v‹‚·‚é‚�}‚Æ‚Í‚ ‚è‚Ü‚¹‚ñB

‚½‚¾‚µAŒöŠJ‚·‚é‚à‚Ì‚ðŽg—pA‚Ü‚½‚ÍŽQl‚µ‚½‚�}‚Æ‚É‚æ‚Á‚ĉ½‚ç‚©‚Ì‘¹ŠQ“™‚ªï¿½ï¿½‚��‚½ê‡‚Å‚àAŽ„‚͂��‚©‚È‚éÓ”C‚à•‰‚��‚Ü‚¹‚ñB

‚ A‚�}‚ñ‚È‚Ì‚ÉŽg‚Á‚½‚Á‚ăRƒƒ“ƒg‚𒸂¯‚ê‚ÎŠð‚µ‚ï¿½ï¿½‚Å‚·B