Whats' wrong with this windows Macro?

This is a discussion on Whats' wrong with this windows Macro? within the Windows Programming forums, part of the Platform Specific Boards category; Hello, Please help me solve the following: /*Now create the button.*/ hwndButton = CreateWindow ( "button", /*Builtin button class.*/ "Click ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    34

    Whats' wrong with this windows Macro?

    Hello,
    Please help me solve the following:

    /*Now create the button.*/

    hwndButton = CreateWindow (
    "button", /*Builtin button class.*/
    "Click Here",

    WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
    0,
    0,
    cx,
    cy,
    hwnd, /*Parent is this window.*/

    (HMENU) 1, /*Control ID:1 */

    ((LPCREATESTRUCT) lParam)-> hInstance,

    NULL
    );

    return 0;
    break;

    }

    I get the error message: Macro 'Create WindowA' used with
    only 10 args.

    How do I resolve this?

    Thank you,

    Adock.

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    MSDN lists 11 params, but when I the autohelp lists the params as I type out the function it only lists 10 (int nHeight is missing). I normally use CreateWindowEx so I'm not too familiar with CreateWindow.

    This is what's listed in the MSDN library:

    HWND CreateWindow(
    LPCTSTR lpClassName, // pointer to registered class name
    LPCTSTR lpWindowName, // pointer to window name
    DWORD dwStyle, // window style
    int x, // horizontal position of window
    int y, // vertical position of window
    int nWidth, // window width
    int nHeight, // window height
    HWND hWndParent, // handle to parent or owner window
    HMENU hMenu, // handle to menu or child-window identifier
    HANDLE hInstance, // handle to application instance
    LPVOID lpParam // pointer to window-creation data
    );

    I just check the msdn site and they list the same thing (as my msdn library). Weird?
    Last edited by jdinger; 03-20-2002 at 08:40 PM.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,854
    (HMENU) 1, /*Control ID:1 */

    Could be a confilict with some other ctrl.

    I would use
    #define IDD_MYDIALOG 10001

    Check your resource.h for conflicts.

    ((LPCREATESTRUCT) lParam)-> hInstance,

    AFAIK this struct is only passed on WM_CREATE. So this code is in response to a window being created? (or you are keeping a static to the pointer to the struct ie may not be valid pointer)

    In my opinion you should keep the HINSTANCE as a global. Or at least a local to the winmain source file. I think this is the problem.

    or look here for a couple of ways to get the HINSTANCE

    http://www.cprogramming.com/cboard/s...threadid=13495
    Last edited by novacain; 03-20-2002 at 10:22 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    34

    Reply

    Thanks to both of you.
    I will take some time
    to study your suggestions.

    Adock.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Network Programming in C for Windows
    By m.mixon in forum C Programming
    Replies: 7
    Last Post: 06-19-2006, 08:27 PM
  2. LoadFromFile() causes Windows 98 to freeze?
    By MidnightlyCoder in forum Windows Programming
    Replies: 8
    Last Post: 03-17-2006, 01:23 PM
  3. Program works on Windows XP and 2000, not on 98 or ME
    By MidnightlyCoder in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2006, 02:36 PM
  4. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  5. Windows Memory Allocation :: C++
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 11-03-2002, 11:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21