[utf8vcl-cvs] utf8vcl TestForm.dfm, 1.14, 1.15 TestForm.pas, 1.19, 1.20 UTF8VCL.pas, 1.18, 1.19
Status: Alpha
Brought to you by:
bluelive
From: Bart v. d. W. <blu...@us...> - 2007-03-19 00:48:46
|
Update of /cvsroot/utf8vcl/utf8vcl In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21058 Modified Files: TestForm.dfm TestForm.pas UTF8VCL.pas Log Message: Add support for having the correct conversion when assinging to and from widestrings. Index: UTF8VCL.pas =================================================================== RCS file: /cvsroot/utf8vcl/utf8vcl/UTF8VCL.pas,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** UTF8VCL.pas 18 Mar 2007 13:25:37 -0000 1.18 --- UTF8VCL.pas 18 Mar 2007 15:12:57 -0000 1.19 *************** *** 24,27 **** --- 24,39 ---- stdcall; external user32 name 'CreateWindowExW'; + type + TMultiByteToWideCharProc = function(CodePage: UINT; dwFlags: DWORD; + const lpMultiByteStr: LPCSTR; cchMultiByte: Integer; + lpWideCharStr: LPWSTR; cchWideChar: Integer): Integer; stdcall; + TWideCharToMultiByteProc = function(CodePage: UINT; dwFlags: DWORD; + lpWideCharStr: LPWSTR; cchWideChar: Integer; lpMultiByteStr: LPSTR; + cchMultiByte: Integer; lpDefaultChar: LPCSTR; lpUsedDefaultChar: PBOOL): Integer; stdcall; + + var + OriginalMultiByteToWideCharProc: TMultiByteToWideCharProc; + OriginalWideCharToMultiByteProc: TWideCharToMultiByteProc; + {FromWindows} *************** *** 565,568 **** --- 577,598 ---- end; + function MultiByteToWideCharIntercept(CodePage: UINT; dwFlags: DWORD; + const lpMultiByteStr: LPCSTR; cchMultiByte: Integer; + lpWideCharStr: LPWSTR; cchWideChar: Integer): Integer; stdcall; + begin + if (CodePage = CP_ACP) or (CodePage = CP_THREAD_ACP) then + CodePage := CP_UTF8; + Result := OriginalMultiByteToWideCharProc(CodePage, dwFlags, lpMultiByteStr, cchMultiByte, lpWideCharStr, cchWideChar); + end; + + function WideCharToMultiByteIntercept(CodePage: UINT; dwFlags: DWORD; + lpWideCharStr: LPWSTR; cchWideChar: Integer; lpMultiByteStr: LPSTR; + cchMultiByte: Integer; lpDefaultChar: LPCSTR; lpUsedDefaultChar: PBOOL): Integer; stdcall; + begin + if (CodePage = CP_ACP) or (CodePage = CP_THREAD_ACP) then + CodePage := CP_UTF8; + Result := OriginalWideCharToMultiByteProc(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cchMultiByte, lpDefaultChar, lpUsedDefaultChar); + end; + procedure FatalAppExitAIntercept(uAction: UINT; lpMessageText: PAnsiChar); stdcall; var *************** *** 627,630 **** --- 657,666 ---- if Active then begin + OriginalMultiByteToWideCharProc := GetProcAddress(GetModuleHandle(kernel32), 'MultiByteToWideChar'); + OriginalWideCharToMultiByteProc := GetProcAddress(GetModuleHandle(kernel32), 'WideCharToMultiByte'); + + HookKernel32Func('MultiByteToWideChar', @MultiByteToWideCharIntercept); // do not localize + HookKernel32Func('WideCharToMultiByte', @WideCharToMultiByteIntercept); // do not localize + HookUser32Func('SendMessageA', @SendMessageAIntercept); // do not localize HookUser32Func('PostMessageA', @PostMessageAIntercept); // do not localize Index: TestForm.dfm =================================================================== RCS file: /cvsroot/utf8vcl/utf8vcl/TestForm.dfm,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TestForm.dfm 18 Mar 2007 13:25:36 -0000 1.14 --- TestForm.dfm 18 Mar 2007 15:12:56 -0000 1.15 *************** *** 225,229 **** object Panel1: TPanel Left = 288 ! Top = 240 Width = 121 Height = 41 --- 225,229 ---- object Panel1: TPanel Left = 288 ! Top = 248 Width = 121 Height = 41 *************** *** 231,234 **** --- 231,250 ---- TabOrder = 19 end + object RadioGroup1: TRadioGroup + Left = 280 + Top = 176 + Width = 89 + Height = 33 + Caption = 'RadioGroup1' + TabOrder = 20 + end + object MaskEdit1: TMaskEdit + Left = 8 + Top = 272 + Width = 121 + Height = 22 + TabOrder = 21 + Text = 'MaskEdit1' + end object MainMenu1: TMainMenu Left = 104 *************** *** 250,252 **** --- 266,272 ---- Top = 336 end + object ActionList1: TActionList + Left = 152 + Top = 304 + end end Index: TestForm.pas =================================================================== RCS file: /cvsroot/utf8vcl/utf8vcl/TestForm.pas,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** TestForm.pas 18 Mar 2007 13:25:36 -0000 1.19 --- TestForm.pas 18 Mar 2007 15:12:56 -0000 1.20 *************** *** 11,15 **** uses Windows, SysUtils, Classes, Controls, Forms, ! Dialogs, ComCtrls, StdCtrls, Menus, Grids, ValEdit, Buttons, ExtCtrls; type --- 11,16 ---- uses Windows, SysUtils, Classes, Controls, Forms, ! Dialogs, ComCtrls, StdCtrls, Menus, Grids, ValEdit, Buttons, ExtCtrls, ! Mask, ActnList; type *************** *** 41,44 **** --- 42,48 ---- Panel1: TPanel; OpenDialog1: TOpenDialog; + RadioGroup1: TRadioGroup; + ActionList1: TActionList; + MaskEdit1: TMaskEdit; procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); *************** *** 98,105 **** --- 102,113 ---- GroupBox1.Caption := TestText; CheckTranslation(GroupBox1.Name, GroupBox1.Caption); + RadioGroup1.Caption := TestText; + CheckTranslation(RadioGroup1.Name, RadioGroup1.Caption); Button2.Caption := TestText; CheckTranslation(Button2.Name, Button2.Caption); RichEdit1.Text := TestText; CheckTranslation(RichEdit1.Name, RichEdit1.Text); + MaskEdit1.Text := TestText; + CheckTranslation(MaskEdit1.Name, MaskEdit1.Text); Application.Title := TestText; CheckTranslation('Application.Title', Application.Title); *************** *** 145,152 **** X, Y: Integer; Content: string; begin OpenDialog1.Filter := TestText +'|*.*'; OpenDialog1.FileName := TestText; ! OpenDialog1.Execute; Content := Menu1.Caption; --- 153,168 ---- X, Y: Integer; Content: string; + S: String; + Wide: WideString; begin OpenDialog1.Filter := TestText +'|*.*'; OpenDialog1.FileName := TestText; ! // OpenDialog1.Execute; ! ! Wide := TestText; // fails on D7, should work on bds, delphi converts it on compiletime ! S := TestText; ! Wide := S; ! ! ShowMessage(Wide); Content := Menu1.Caption; *************** *** 164,167 **** --- 180,184 ---- Content := ComboBox1.Text; Content := GroupBox1.Caption; + Content := RadioGroup1.Caption; Content := Button2.Caption; Content := RichEdit1.Text; *************** *** 231,234 **** --- 248,255 ---- Assert(GroupBox1.Caption = Content); + Content := RadioGroup1.Caption; + RadioGroup1.Caption := Content; + Assert(RadioGroup1.Caption = Content); + Content := Button2.Caption; Button2.Caption := Content; |