Modify

Opened 4 years ago

Closed 4 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 Changed 4 years ago by jchd18

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

comment:2 Changed 4 years ago by mLipok

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 Changed 4 years ago by bitnugger <bitnugger@…>

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 Changed 4 years ago by Jpm

  • Resolution set to No Bug
  • Status changed from new to closed

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 ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.