Modify

Opened 5 years ago

Closed 5 years ago

#3809 closed Bug (Fixed)

WinGetTitle returns blank on Windows 10 using _WinAPI_CreateWindowEx

Reported by: Nine Owned by: Jon
Milestone: 3.3.15.4 Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description (last modified by mLipok)

It is working fine under Win7. But with Win10, WinGetTitle returns blank when called with $hWnd while using _WinAPI_CreateWindowEx. If you replace $hWnd with actual title, it works. If you use "[CLASS:MyWindowClass]", it works. If you do a WinList(), it will appear in the list.

Line 
1#include <WinAPIRes.au3>
2#include <WinAPISys.au3>
3#include <WindowsConstants.au3>
4
5Opt( "MustDeclareVars", 1 )
6
7Global $bExit = False
8
9Example()
10
11Func Example()
12 Local Const $sClass = "MyWindowClass"
13 Local Const $sName = "_WinAPI_RegisterClassEx"
14
15 ; Get module handle for the current process
16 Local $hInstance = _WinAPI_GetModuleHandle( 0 )
17
18 ; Create a class cursor
19 Local $hCursor = _WinAPI_LoadCursor( 0, 32512 ) ; IDC_ARROW
20
21 ; Create a class icons (large and small)
22 Local $tIcons = DllStructCreate( "ptr;ptr" )
23 _WinAPI_ExtractIconEx( @SystemDir & "\shell32.dll", 130, DllStructGetPtr( $tIcons, 1 ), DllStructGetPtr( $tIcons, 2 ), 1 )
24 Local $hIcon = DllStructGetData( $tIcons, 1 )
25 Local $hIconSm = DllStructGetData( $tIcons, 2 )
26
27 ; Create DLL callback function (window procedure)
28 Local $pWinProc = DllCallbackGetPtr( DllCallbackRegister( "WinProc", "lresult", "hwnd;uint;wparam;lparam" ) )
29
30 ; Create and fill $tagWNDCLASSEX structure
31 Local $tWCEX = DllStructCreate( $tagWNDCLASSEX & ";wchar szClassName[" & ( StringLen( $sClass ) + 1 ) & "]" )
32 DllStructSetData( $tWCEX, "Size", DllStructGetPtr( $tWCEX, "szClassName" ) - DllStructGetPtr( $tWCEX ) )
33 DllStructSetData( $tWCEX, "Style", 0 )
34 DllStructSetData( $tWCEX, "hWndProc", $pWinProc )
35 DllStructSetData( $tWCEX, "ClsExtra", 0 )
36 DllStructSetData( $tWCEX, "WndExtra", 0 )
37 DllStructSetData( $tWCEX, "hInstance", $hInstance )
38 DllStructSetData( $tWCEX, "hIcon", $hIcon )
39 DllStructSetData( $tWCEX, "hCursor", $hCursor )
40 DllStructSetData( $tWCEX, "hBackground", _WinAPI_CreateSolidBrush( _WinAPI_GetSysColor( $COLOR_3DFACE ) ) )
41 DllStructSetData( $tWCEX, "MenuName", 0 )
42 DllStructSetData( $tWCEX, "ClassName", DllStructGetPtr( $tWCEX, "szClassName" ) )
43 DllStructSetData( $tWCEX, "hIconSm", $hIconSm )
44 DllStructSetData( $tWCEX, "szClassName", $sClass )
45
46 ; Register a window class
47 _WinAPI_RegisterClassEx( $tWCEX )
48
49 ; Create a window
50 Local $hWnd = _WinAPI_CreateWindowEx( 0, $sClass, $sName, BitOR( $WS_CAPTION, $WS_POPUPWINDOW, $WS_VISIBLE ), ( @DesktopWidth - 826 ) / 2, ( @DesktopHeight - 584 ) / 2, 826, 584, 0 )
51 MsgBox ($MB_SYSTEMMODAL, "", WinGetTitle($hWnd))
52
53 ; Main msg loop
54 While Sleep(10)
55 If $bExit Then ExitLoop
56 WEnd
57
58 ; Unregister window class and release resources
59 _WinAPI_UnregisterClass( $sClass, $hInstance )
60 _WinAPI_DestroyCursor( $hCursor )
61 _WinAPI_DestroyIcon( $hIcon )
62 _WinAPI_DestroyIcon( $hIconSm )
63EndFunc
64
65; Window procedure
66Func WinProc( $hWnd, $iMsg, $wParam, $lParam )
67 Switch $iMsg
68 Case $WM_CLOSE
69 $bExit = True
70 EndSwitch
71 Return _WinAPI_DefWindowProcW( $hWnd, $iMsg, $wParam, $lParam )
72EndFunc

Attachments (0)

Change History (3)

comment:1 by mLipok, 5 years ago

Description: modified (diff)

comment:2 by J-Paul Mesnage, 5 years ago

Owner: set to J-Paul Mesnage
Status: newassigned

Fix sent to Jon

comment:3 by Jon, 5 years ago

Milestone: 3.3.15.4
Owner: changed from J-Paul Mesnage to Jon
Resolution: Fixed
Status: assignedclosed

Fixed by revision [12566] in version: 3.3.15.4

Modify Ticket

Action
as closed The owner will remain Jon.

Add Comment


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