Opened on Oct 30, 2010 at 11:09:32 AM
Closed on Nov 27, 2011 at 5:30:00 PM
Last modified on Dec 5, 2011 at 12:37:49 PM
#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 , on Dec 9, 2010 at 7:56:21 PM
follow-up: 3 comment:2 by , on Dec 22, 2010 at 12:07:57 AM
follow-up: 4 comment:3 by , on Dec 22, 2010 at 10:28:36 AM
comment:4 by , on Jan 11, 2011 at 7:59:54 PM
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 , on May 23, 2011 at 6:44:59 PM
| Component: | AutoIt → Standard UDFs |
|---|---|
| Owner: | set to |
comment:6 by , on Nov 27, 2011 at 5:30:00 PM
| 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 , on Dec 4, 2011 at 8:30:23 PM
All functions that are in WinAPI.au3 uses the Unicode version, apart from these two.
comment:8 by , on Dec 5, 2011 at 12:37:49 PM
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?