본문 바로가기
Delphi 문제점 Tip

한글조합창 문제 해결

by MonoSoft 2022. 5. 10.
728x90
반응형

한글조합창 문제 해결

 

constructor TmyLIB.Create;

begin

// 그리드에서 한글 처리

Application.OnMessage := AppMessage;

.....

end;

 

procedure TmyLIB.AppMessage(var Msg: TMsg; var Handled: Boolean);

var lead: integer;

IMC: HIMC;

pt : TPoint;

rct: TRect;

tCF : tagCompositionForm;

begin

// 그리드에서만 처리

if screen.ActiveControl is TtsGrid then begin

// 한글 메시지 처리

if (Msg.message = WM_IME_COMPOSITION) or

(Msg.message = WM_CHAR) or

(Msg.message = WM_IME_STARTCOMPOSITION) or

(Msg.message = WM_IME_ENDCOMPOSITION) then 

begin

if (prevMsg.message = WM_CHAR) and

(prevMsg.wParam > $0080) and

(Msg.message = WM_CHAR) and

(Msg.wParam > $0080) then

lead := 12

else

lead := 0;

IMC := ImmGetContext(ImmGetDefaultImeWnd(Application.ActiveFormHandle));

GetCaretPos(pt);

tCF.dwStyle := CFS_RECT;

pt.Y := pt.Y - 3;

pt.X := pt.X + lead;

tCF.ptCurrentPos := pt;

rct.TopLeft := pt;

tCF.rcArea := rct;

ImmSetCompositionWindow(IMC,@tCF);

ImmReleaseContext(ImmGetDefaultImeWnd(Application.ActiveFormHandle), IMC);

end;

prevMsg := Msg; // 메시지 보관. 연속으로 WM_CHAR 오고 한글이면 조립창 우측으로 이동

end;

Handled := False;

end;

 

728x90
반응형

댓글