[utf8vcl-cvs] utf8vcl UTF8VCL.pas,1.22,1.23
Status: Alpha
Brought to you by:
bluelive
From: Robert M. <mar...@us...> - 2007-03-25 12:33:17
|
Update of /cvsroot/utf8vcl/utf8vcl In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv4796 Modified Files: UTF8VCL.pas Log Message: made the unpatched functions available under new name Index: UTF8VCL.pas =================================================================== RCS file: /cvsroot/utf8vcl/utf8vcl/UTF8VCL.pas,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** UTF8VCL.pas 25 Mar 2007 11:46:16 -0000 1.22 --- UTF8VCL.pas 25 Mar 2007 12:33:10 -0000 1.23 *************** *** 36,45 **** interface procedure ActivateUtf8VCL(Active: Boolean); implementation uses ! Windows, Messages, SysUtils, Classes, CommDlg, UTF8VCLUtils, UTF8VCLMessages; --- 36,137 ---- interface + uses + Windows, CommDlg; + procedure ActivateUtf8VCL(Active: Boolean); + type + TMultiByteToWideChar = function(CodePage: UINT; dwFlags: DWORD; + const lpMultiByteStr: LPCSTR; cchMultiByte: Integer; + lpWideCharStr: LPWSTR; cchWideChar: Integer): Integer; stdcall; + TWideCharToMultiByte = function(CodePage: UINT; dwFlags: DWORD; + lpWideCharStr: LPWSTR; cchWideChar: Integer; lpMultiByteStr: LPSTR; + cchMultiByte: Integer; lpDefaultChar: LPCSTR; lpUsedDefaultChar: PBOOL): Integer; stdcall; + TGetACP = function: UINT; stdcall; + TSendMessageA = function(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; + TPostMessageA = function(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL; stdcall; + TCreateWindowExA = function(dwExStyle: DWORD; lpClassName: PAnsiChar; + lpWindowName: PAnsiChar; dwStyle: DWORD; X, Y, nWidth, nHeight: Integer; + hWndParent: HWND; hMenu: HMENU; hInstance: HINST; lpParam: Pointer): HWND; stdcall; + TUnregisterClassA = function(lpClassName: PAnsiChar; hInstance: HINST): BOOL; stdcall; + TRegisterClassA = function(const lpWndClass: TWndClassA): ATOM; stdcall; + TRegisterClassExA = function(const WndClass: TWndClassExA): ATOM; stdcall; + TDrawTextA = function(hDC: HDC; lpString: PAnsiChar; nCount: Integer; + var lpRect: TRect; uFormat: UINT): Integer; stdcall; + TDrawTextExA = function(DC: HDC; lpchText: PAnsiChar; cchText: Integer; var p4: TRect; + dwDTFormat: UINT; DTParams: PDrawTextParams): Integer; stdcall; + TSetWindowLongA = function(hWnd: HWND; nIndex: Integer; dwNewLong: Longint): Longint; stdcall; + TSetWindowTextA = function(hWnd: HWND; lpString: PAnsiChar): BOOL; stdcall; + TGetClassInfoA = function(hInstance: HINST; lpClassName: PAnsiChar; + var lpWndClass: TWndClassA): BOOL; stdcall; + TGetClassInfoExA = function(Instance: HINST; Classname: PAnsiChar; var WndClass: TWndClassExA): BOOL; stdcall; + TCallWindowProcA = function(lpPrevWndFunc: TFNWndProc; hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; + TIsWindowUnicode = function(hWnd: HWND): BOOL; stdcall; + TGetWindowLongA = function(hWnd: HWND; nIndex: Integer): Longint; stdcall; + TDefWindowProcA = function(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; + TDefMDIChildProcA = function(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; + TDefDlgProcA = function(hDlg: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; + TGetWindowTextA = function(hWnd: HWND; lpString: PAnsiChar; nMaxCount: Integer): Integer; stdcall; + TInsertMenuA = function(hMenu: HMENU; uPosition, uFlags, uIDNewItem: UINT; + lpNewItem: PAnsiChar): BOOL; stdcall; + TInsertMenuItemA = function(p1: HMENU; p2: UINT; p3: BOOL; const p4: TMenuItemInfoA): BOOL; stdcall; + TMessageBoxA = function(hWnd: HWND; lpText, lpCaption: PAnsiChar; uType: UINT): Integer; stdcall; + TTextOutA = function(DC: HDC; X, Y: Integer; Str: PAnsiChar; Count: Integer): BOOL; stdcall; + TExtTextOutA = function(DC: HDC; X, Y: Integer; Options: Longint; + Rect: PRect; Str: PAnsiChar; Count: Longint; Dx: PInteger): BOOL; stdcall; + TGetTextExtentPoint32A = function(DC: HDC; Str: PAnsiChar; Count: Integer; + var Size: TSize): BOOL; stdcall; + TGetTextExtentPointA = function(DC: HDC; Str: PAnsiChar; Count: Integer; var Size: TSize): BOOL; stdcall; + TGetTextExtentExPointA = function(DC: HDC; p2: PAnsiChar; + p3, p4: Integer; p5, p6: PInteger; var p7: TSize): BOOL; stdcall; + TOutputDebugStringA = procedure(lpOutputString: PAnsiChar); stdcall; + TFatalAppExitA = procedure(uAction: UINT; lpMessageText: PAnsiChar); stdcall; + TGetOpenFileNameA = function(var OpenFile: TOpenFilenameA): Bool; stdcall; + + var + NonUTF8MultiByteToWideChar: TMultiByteToWideChar; + NonUTF8WideCharToMultiByte: TWideCharToMultiByte; + NonUTF8GetACP: TGetACP; + + NonUTF8SendMessage: TSendMessageA; + NonUTF8PostMessage: TPostMessageA; + NonUTF8CreateWindowEx: TCreateWindowExA; + NonUTF8UnregisterClass: TUnregisterClassA; + NonUTF8RegisterClass: TRegisterClassA; + NonUTF8RegisterClassEx: TRegisterClassExA; + NonUTF8DrawText: TDrawTextA; + NonUTF8DrawTextEx: TDrawTextExA; + NonUTF8SetWindowLong: TSetWindowLongA; + NonUTF8SetWindowText: TSetWindowTextA; + NonUTF8GetClassInfo: TGetClassInfoA; + NonUTF8GetClassInfoEx: TGetClassInfoExA; + NonUTF8CallWindowProc: TCallWindowProcA; + NonUTF8IsWindowUnicode: TIsWindowUnicode; + NonUTF8GetWindowLong: TGetWindowLongA; + + NonUTF8DefWindowProc: TDefWindowProcA; + NonUTF8DefMDIChildProc: TDefMDIChildProcA; + NonUTF8DefDlgProc: TDefDlgProcA; + + NonUTF8GetWindowText: TGetWindowTextA; + NonUTF8InsertMenu: TInsertMenuA; + NonUTF8InsertMenuItem: TInsertMenuItemA; + NonUTF8MessageBox: TMessageBoxA; + + NonUTF8TextOut: TTextOutA; + NonUTF8ExtTextOut: TExtTextOutA; + NonUTF8GetTextExtentPoint32: TGetTextExtentPoint32A; + NonUTF8GetTextExtentPoint: TGetTextExtentPointA; + NonUTF8GetTextExtentExPoint: TGetTextExtentExPointA; + + NonUTF8OutputDebugString: TOutputDebugStringA; + NonUTF8FatalAppExit: TFatalAppExitA; + + NonUTF8GetOpenFileName: TGetOpenFileNameA; + implementation uses ! Messages, SysUtils, Classes, UTF8VCLUtils, UTF8VCLMessages; *************** *** 48,59 **** CP_THREAD_ACP = 3; // current thread's ANSI code page - 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; - function _CreateWindowExW(dwExStyle: DWORD; lpClassName: PWideChar; lpWindowName: PWideChar; dwStyle: DWORD; X, Y, nWidth, nHeight: Integer; --- 140,143 ---- *************** *** 61,68 **** stdcall; external user32 name 'CreateWindowExW'; - var - OriginalMultiByteToWideCharProc: TMultiByteToWideCharProc; - OriginalWideCharToMultiByteProc: TWideCharToMultiByteProc; - {FromWindows} --- 145,148 ---- *************** *** 272,275 **** --- 352,368 ---- end; + function GetTextExtentPointAIntercept(DC: HDC; Str: PAnsiChar; Count: Integer; var Size: TSize): BOOL; stdcall; + var + C: PWideChar; + L: Integer; + begin + C := ConvertFromUTF8(Str, Count, L); + try + Result := GetTextExtentPointW(DC, C, L, Size); + finally + FreeMem(C); + end; + end; + function GetTextExtentExPointAIntercept(DC: HDC; Str: PAnsiChar; Count, nMaxExtent: Integer; lpnFit, alpDx: PInteger; var lpSize: TSize): BOOL; stdcall; *************** *** 626,630 **** if (CodePage = CP_ACP) or (CodePage = CP_THREAD_ACP) then CodePage := CP_UTF8; ! Result := OriginalMultiByteToWideCharProc(CodePage, dwFlags, lpMultiByteStr, cchMultiByte, lpWideCharStr, cchWideChar); end; --- 719,723 ---- if (CodePage = CP_ACP) or (CodePage = CP_THREAD_ACP) then CodePage := CP_UTF8; ! Result := NonUTF8MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cchMultiByte, lpWideCharStr, cchWideChar); end; *************** *** 636,640 **** if (CodePage = CP_ACP) or (CodePage = CP_THREAD_ACP) then CodePage := CP_UTF8; ! Result := OriginalWideCharToMultiByteProc(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cchMultiByte, lpDefaultChar, lpUsedDefaultChar); end; --- 729,733 ---- if (CodePage = CP_ACP) or (CodePage = CP_THREAD_ACP) then CodePage := CP_UTF8; ! Result := NonUTF8WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cchMultiByte, lpDefaultChar, lpUsedDefaultChar); end; *************** *** 708,753 **** 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 ! HookKernel32Func('GetACP', @GetACPIntercept); // do not localize ! ! HookUser32Func('SendMessageA', @SendMessageAIntercept); // do not localize ! HookUser32Func('PostMessageA', @PostMessageAIntercept); // do not localize ! HookUser32Func('CreateWindowExA', @CreateWindowExAIntercept); // do not localize ! HookUser32Func('UnregisterClassA', @UnregisterClassAIntercept); // do not localize ! HookUser32Func('RegisterClassA', @RegisterClassAIntercept); // do not localize ! HookUser32Func('RegisterClassExA', @RegisterClassExAIntercept); // do not localize ! HookUser32Func('DrawTextA', @DrawTextAIntercept); // do not localize ! HookUser32Func('DrawTextExA', @DrawTextExAIntercept); // do not localize ! HookUser32Func('SetWindowLongA', @SetWindowLongAIntercept); // do not localize ! HookUser32Func('SetWindowTextA', @SetWindowTextAIntercept); // do not localize ! HookUser32Func('GetClassInfoA', @GetClassInfoAIntercept); // do not localize ! HookUser32Func('GetClassInfoExA', @GetClassInfoExAIntercept); // do not localize ! HookUser32Func('CallWindowProcA', @CallWindowProcAIntercept); // do not localize ! HookUser32Func('IsWindowUnicode', @IsWindowUnicodeIntercept); // do not localize ! HookUser32Func('GetWindowLongA', @GetWindowLongAIntercept); // do not localize ! HookUser32Func('DefWindowProcA', @DefWindowProcAIntercept); // do not localize ! HookUser32Func('DefMDIChildProcA', @DefMDIChildProcAIntercept); // do not localize ! HookUser32Func('DefDlgProcA', @DefDlgProcAIntercept); // do not localize ! HookUser32Func('GetWindowTextA', @GetWindowTextAIntercept); // do not localize ! HookUser32Func('InsertMenuA', @InsertMenuAIntercept); // do not localize ! HookUser32Func('InsertMenuItemA', @InsertMenuItemAIntercept); // do not localize ! HookUser32Func('MessageBoxA', @MessageBoxAIntercept); // do not localize ! HookGdi32Func('TextOutA', @TextOutAIntercept); // do not localize ! HookGdi32Func('ExtTextOutA', @ExtTextOutAIntercept); // do not localize ! HookGdi32Func('GetTextExtentPoint32A', @GetTextExtentPoint32AIntercept); // do not localize ! HookGdi32Func('GetTextExtentExPointA', @GetTextExtentExPointAIntercept); // do not localize ! HookKernel32Func('OutputDebugStringA', @OutputDebugStringAIntercept); // do not localize ! HookKernel32Func('FatalAppExitA', @FatalAppExitAIntercept); // do not localize ! HookCommdlg32Func('GetOpenFileNameA', @GetOpenFileNameAIntercept); // do not localize end else --- 801,843 ---- if Active then begin ! NonUTF8MultiByteToWideChar := HookKernel32Func('MultiByteToWideChar', @MultiByteToWideCharIntercept); // do not localize ! NonUTF8WideCharToMultiByte := HookKernel32Func('WideCharToMultiByte', @WideCharToMultiByteIntercept); // do not localize ! NonUTF8GetACP := HookKernel32Func('GetACP', @GetACPIntercept); // do not localize ! NonUTF8SendMessage := HookUser32Func('SendMessageA', @SendMessageAIntercept); // do not localize ! NonUTF8PostMessage := HookUser32Func('PostMessageA', @PostMessageAIntercept); // do not localize ! NonUTF8CreateWindowEx := HookUser32Func('CreateWindowExA', @CreateWindowExAIntercept); // do not localize ! NonUTF8UnregisterClass := HookUser32Func('UnregisterClassA', @UnregisterClassAIntercept); // do not localize ! NonUTF8RegisterClass := HookUser32Func('RegisterClassA', @RegisterClassAIntercept); // do not localize ! NonUTF8RegisterClassEx := HookUser32Func('RegisterClassExA', @RegisterClassExAIntercept); // do not localize ! NonUTF8DrawText := HookUser32Func('DrawTextA', @DrawTextAIntercept); // do not localize ! NonUTF8DrawTextEx := HookUser32Func('DrawTextExA', @DrawTextExAIntercept); // do not localize ! NonUTF8SetWindowLong := HookUser32Func('SetWindowLongA', @SetWindowLongAIntercept); // do not localize ! NonUTF8SetWindowText := HookUser32Func('SetWindowTextA', @SetWindowTextAIntercept); // do not localize ! NonUTF8GetClassInfo := HookUser32Func('GetClassInfoA', @GetClassInfoAIntercept); // do not localize ! NonUTF8GetClassInfoEx := HookUser32Func('GetClassInfoExA', @GetClassInfoExAIntercept); // do not localize ! NonUTF8CallWindowProc := HookUser32Func('CallWindowProcA', @CallWindowProcAIntercept); // do not localize ! NonUTF8IsWindowUnicode := HookUser32Func('IsWindowUnicode', @IsWindowUnicodeIntercept); // do not localize ! NonUTF8GetWindowLong := HookUser32Func('GetWindowLongA', @GetWindowLongAIntercept); // do not localize ! NonUTF8DefWindowProc := HookUser32Func('DefWindowProcA', @DefWindowProcAIntercept); // do not localize ! NonUTF8DefMDIChildProc := HookUser32Func('DefMDIChildProcA', @DefMDIChildProcAIntercept); // do not localize ! NonUTF8DefDlgProc := HookUser32Func('DefDlgProcA', @DefDlgProcAIntercept); // do not localize ! NonUTF8GetWindowText := HookUser32Func('GetWindowTextA', @GetWindowTextAIntercept); // do not localize ! NonUTF8InsertMenu := HookUser32Func('InsertMenuA', @InsertMenuAIntercept); // do not localize ! NonUTF8InsertMenuItem := HookUser32Func('InsertMenuItemA', @InsertMenuItemAIntercept); // do not localize ! NonUTF8MessageBox := HookUser32Func('MessageBoxA', @MessageBoxAIntercept); // do not localize ! NonUTF8TextOut := HookGdi32Func('TextOutA', @TextOutAIntercept); // do not localize ! NonUTF8ExtTextOut := HookGdi32Func('ExtTextOutA', @ExtTextOutAIntercept); // do not localize ! NonUTF8GetTextExtentPoint32 := HookGdi32Func('GetTextExtentPoint32A', @GetTextExtentPoint32AIntercept); // do not localize ! NonUTF8GetTextExtentPoint := HookGdi32Func('GetTextExtentPointA', @GetTextExtentPointAIntercept); // do not localize ! NonUTF8GetTextExtentExPoint := HookGdi32Func('GetTextExtentExPointA', @GetTextExtentExPointAIntercept); // do not localize ! NonUTF8OutputDebugString := HookKernel32Func('OutputDebugStringA', @OutputDebugStringAIntercept); // do not localize ! NonUTF8FatalAppExit := HookKernel32Func('FatalAppExitA', @FatalAppExitAIntercept); // do not localize ! NonUTF8GetOpenFileName := HookCommdlg32Func('GetOpenFileNameA', @GetOpenFileNameAIntercept); // do not localize end else |