Modify

Opened 14 years ago

Closed 13 years ago

Last modified 13 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 follow-up: Changed 14 years ago by Jpm

Are you sure that you process is unicode?

comment:2 in reply to: ↑ 1 ; follow-up: Changed 14 years ago by Yashied

Replying to Jpm:

Are you sure that you process is unicode?

Yes.

comment:3 in reply to: ↑ 2 ; follow-up: Changed 14 years ago by Jpm

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

comment:4 in reply to: ↑ 3 Changed 14 years ago by Yashied

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 Changed 14 years ago by Jon

  • Component changed from AutoIt to Standard UDFs
  • Owner set to Gary

comment:6 Changed 13 years ago by trancexx

  • Resolution set to No Bug
  • Status changed from new to 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 Changed 13 years ago by Yashied

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

comment:8 Changed 13 years ago by trancexx

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.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Gary.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.