#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:2 by , on Nov 27, 2015 at 11:41:33 PM
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 , on Nov 28, 2015 at 5:36:40 AM
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 , on Nov 28, 2015 at 6:57:31 AM
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |

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