Bommijn
Bommijn

Reputation: 1

BOOL returning -1, 0 or positive

I'm a bit confused by the msdn GetMessage explanation.

They state that BOOL GetMessage() can return 0 when the method retrieves WM_QUIT. It returns -1 when there is an error and it returns positive for any other message.

But how can this be. A Boolean should be false or true, 0 or 1. How can it return a -1.

Link to msdn GetMessage: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage

Upvotes: 0

Views: 362

Answers (2)

H4x9r
H4x9r

Reputation: 352

The Windows Type BOOL is just a typedef of an integer. You must not confuse this with the cpp bool because it can only be true and false

Upvotes: 1

Some programmer dude
Some programmer dude

Reputation: 409166

In the Windows world, BOOL is a type-alias for int (according to the official documentation). Therefore it can have any value that an int could have.

Upvotes: 0

Related Questions