Modify

Opened 10 years ago

Closed 10 years ago

#3177 closed Bug (No Bug)

_WinAPI_ShowWindow() does not give True if successful

Reported by: bitnugger Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.2 Severity: None
Keywords: Cc:

Description

According to the Help file (AutoIt-en-v3.3.10.2) the function _WinAPI_ShowWindow() should give True if successful, but that's not correct...

$hWnd = WinGetHandle("[Active]")
$iSuccess = _WinAPI_ShowWindow($hWnd, @SW_SHOW)
ConsoleWrite("var: $iSuccess --> " & $iSuccess & @LF)

Output:

var: $iSuccess --> 24

Attachments (0)

Change History (4)

comment:1 by jchd18, 10 years ago

24, just like any nonzero integral value evaluates to boolean True.
Hence the question boils down: what is the problem exactly?

comment:2 by mLipok, 10 years ago

MSDN:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx

says:

Return value

Type:
Type: BOOL
If the window was previously visible, the return value is nonzero.
If the window was previously hidden, the return value is zero.

So the problem is in Documentation on MSDN and in the same manner also in AutoIt HelpFile.

#include <WinAPI.au3>
$hWnd = WinGetHandle("[ACTIVE]")

_WinAPI_ShowWindow($hWnd, 0)
Sleep(500)
$iSuccess = _WinAPI_ShowWindow($hWnd, 5)
ConsoleWrite("var: $iSuccess --> " & $iSuccess & '  ' & VarGetType($iSuccess) & @LF)

As return value is not Bool but Int32, just exactly what MSDN says

If the window was previously visible, the return value is nonzero.
If the window was previously hidden, the return value is zero.

comment:3 by bitnugger <bitnugger@…>, 10 years ago

Until now, I had to save it so that Boolean variables generally can accept only divalent and trivalent switching variables. However, I have just read in Wikipedia that "Boolean or Boolean algebra is in principle about any character set (range) are possible."

So I must then probably revise my statement ... with the positive side effect to have learned one important thing about Boolean. ;-)

The ticket can therefore be closed.

comment:4 by J-Paul Mesnage, 10 years ago

Resolution: No Bug
Status: newclosed

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


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