#1802 closed Bug (No Bug)
_WinAPI_CallWindowProc() and _WinAPI_DefWindowProc() are not Unicode version
| Reported by: | Yashied | Owned by: | Gary |
|---|---|---|---|
| Milestone: | Component: | Standard UDFs | |
| Version: | 3.3.6.1 | Severity: | None |
| Keywords: | _WinAPI_CallWindowProc, _WinAPI_DefWindowProc | Cc: |
Description
_WinAPI_CallWindowProc() and _WinAPI_DefWindowProc() still use the ANSI version of the API functions.
Attachments (0)
Change History (8)
follow-up: 2 comment:1 by , 15 years ago
follow-up: 3 comment:2 by , 15 years ago
follow-up: 4 comment:3 by , 15 years ago
comment:4 by , 15 years ago
Replying to Jpm:
So I am suprised that a Unicode process calling CallWindowProc does call CallWindowProcW.
Can you provide a replication script?
OK. Look at the title bar ("M" instead of "MyProg").
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>
Global Const $tagWNDCLASSEX = 'uint Size;uint Style;ptr hWndProc;int ClsExtra;int WndExtra;ptr hInstance;ptr hIcon;ptr hCursor;ptr hBackground;ptr MenuName;ptr ClassName;ptr hIconSm'
Global Const $sClass = 'MyWindowClass'
Global Const $sName = 'MyProg'
$tWndClassEx = DllStructCreate($tagWNDCLASSEX)
$hWndProc = DllCallbackRegister('_MyWndProc', 'lresult', 'hwnd;uint;wparam;lparam')
$hInstance = _WinAPI_GetModuleHandle(0)
$tClass = DllStructCreate('wchar[' & StringLen($sClass) + 1 & ']')
DllStructSetData($tClass, 1, $sClass)
DllStructSetData($tWndClassEx, 'Size', DllStructGetSize($tWndClassEx))
DllStructSetData($tWndClassEx, 'Style', 0)
DllStructSetData($tWndClassEx, 'hWndProc', DllCallbackGetPtr($hWndProc))
DllStructSetData($tWndClassEx, 'ClsExtra', 0)
DllStructSetData($tWndClassEx, 'WndExtra', 0)
DllStructSetData($tWndClassEx, 'hInstance', $hInstance)
DllStructSetData($tWndClassEx, 'hIcon', 0)
DllStructSetData($tWndClassEx, 'hCursor', 0)
DllStructSetData($tWndClassEx, 'hBackground', 0)
DllStructSetData($tWndClassEx, 'MenuName', 0)
DllStructSetData($tWndClassEx, 'ClassName', DllStructGetPtr($tClass))
DllStructSetData($tWndClassEx, 'hIconSm', 0)
DllCall('user32.dll', 'dword', 'RegisterClassExW', 'ptr', DllStructGetPtr($tWndClassEx))
DllCall('user32.dll', 'hwnd', 'CreateWindowExW', 'dword', 0, 'wstr', $sClass, 'wstr', $sName, 'dword', BitOR($WS_CAPTION, $WS_POPUPWINDOW, $WS_VISIBLE), 'int', 200, 'int', 200, 'int', 400, 'int', 400, 'hwnd', 0, 'hwnd', 0, 'hwnd', $hInstance, 'ptr', 0)
$Exit = 0
While 1
Sleep(100)
If $Exit Then
ExitLoop
EndIf
WEnd
DllCall('user32.dll', 'dword', 'UnregisterClassW', 'wstr', $sClass, 'ptr', $hInstance)
DllCallbackFree($hWndProc)
Func _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
Local $Ret = DllCall('user32.dll', 'lresult', 'DefWindowProcW', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, 'lparam', $lParam)
If @error Then
Return SetError(1, 0, 0)
EndIf
Return $Ret[0]
EndFunc ;==>_WinAPI_DefWindowProcW
Func _MyWndProc($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_CLOSE
$Exit = 1
EndSwitch
;~ Return _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>_MyWndProc
comment:5 by , 15 years ago
| Component: | AutoIt → Standard UDFs |
|---|---|
| Owner: | set to |
comment:6 by , 14 years ago
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
Yashied you have registered a window class using Unicode version of that function. In that case the system passes text parameters of messages as Unicode, meaning your _MyWndProc() must use Unicode version functions you use. If you have done opposite of that _MyWndProc() would be correct.
This proves that functions inside WinApi.au3 are not wrong.
What's true is that WinApi.au3 misses Unicode versions of those functions as DllCall function calls ANSI versions of functions by default when there are any doubts.
This is not a bug.
comment:7 by , 14 years ago
All functions that are in WinAPI.au3 uses the Unicode version, apart from these two.
comment:8 by , 14 years ago
And they should.
There are some special functions that should be supported by standard UDFs in both versions. These functions are examples of that.
You are free to ask for SVN access and after that be part of UDF development if you wish.

Are you sure that you process is unicode?