Thread: WM_CREATE and BOOLs

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    43

    WM_CREATE and BOOLs

    Got a couple more questions:

    a) The lParam of the WM_CREATE message is, according to Microsoft, "Pointer to a CREATESTRUCT structure that contains information about the window being created." However when I try to do things like lParam->lpCreateParams, I get the compiler error "base operand of `->' is not a pointer".

    b) What is the BOOL type? I know that the "bool" type (lowercase) is a type in Standard C++ which can be "true" or "false". When I used to do C, we used to define things like:

    Code:
    typedef enum{FALSE, TRUE} BOOL;
    and I guessed that this was what the "bool" type was. But now we get this "BOOL" type (uppercase) and I find that the GetMessage function (which returns a BOOL) can return -1 as a value! Is a BOOL just a signed int? In which case it is taking up way too much memory for a boolean variable which should take only one byte.
    Windows XP Professional SP2, Code::Blocks Studio 1.0rc2, GCC/G++ 3.4.2 (20040916-1), mingw32-make 3.80.0-3, GDB 5.2.1-1, W32API 3.6

    MingW Runtime 3.9, BinUitls 2.15.91 (20040904-1), MingW Utilities 0.3, Tcl/Tk 8.4.1-1

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    1. You need to cast it to a CREATESTRUCT pointer first.
    Code:
    CREATESTRUCT* pcs = (CREATESTRUCT*)lParam;
    pcs->lpCreateParams /* ... */
    
    // or
    
    ((CREATESTRUCT*)lParam)->lpCreateParams /* ... */
    2. Exactly.

  3. #3
    C++ Newbie
    Join Date
    Nov 2005
    Posts
    49

    Wink

    Quote Originally Posted by kidburla
    and I guessed that this was what the "bool" type was. But now we get this "BOOL" type (uppercase) and I find that the GetMessage function (which returns a BOOL) can return -1 as a value! Is a BOOL just a signed int? In which case it is taking up way too much memory for a boolean variable which should take only one byte.
    I've heard this before, someone else had said that it is cheaper for a 32 bit processor to access an 32 bit int value rather than a byte which requires moving into ax and then isolate the low word twice, I think the bool in C++ is implemented as a 32 bit int as well.

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    bool in C++ is one byte or larger, there's no standard value.

    BOOL in windows is an int, so it will be 16/32/64 bits depending on what int is.

    As an aside, a one-byte variable can also hold -1 you know.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed