Modify

Opened 15 years ago

Closed 14 years ago

Last modified 14 years ago

#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)

comment:1 by J-Paul Mesnage, 15 years ago

Are you sure that you process is unicode?

in reply to:  1 ; comment:2 by Yashied, 15 years ago

Replying to Jpm:

Are you sure that you process is unicode?

Yes.

in reply to:  2 ; comment:3 by J-Paul Mesnage, 15 years ago

Replying to Yashied:

Replying to Jpm:

Are you sure that you process is unicode?

Yes.

So I am suprised that a Unicode process calling CallWindowProc does call CallWindowProcW.
Can you provide a replication script?
Thanks

in reply to:  3 comment:4 by Yashied, 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 Jon, 15 years ago

Component: AutoItStandard UDFs
Owner: set to Gary

comment:6 by trancexx, 14 years ago

Resolution: No Bug
Status: newclosed

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 Yashied, 14 years ago

All functions that are in WinAPI.au3 uses the Unicode version, apart from these two.

comment:8 by trancexx, 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.

Modify Ticket

Action
as closed The owner will remain Gary.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.