Thread: CreateWindow, primary expression expected

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    416

    CreateWindow, primary expression expected

    I must be blind and not see something, or I've stared at this for too long... or both. But can someone help me see what is going on here? I successfully set up the tabs in another program, and am trying to do the same to my current project. The only difference between the two projects is this one is on a dialog and the previous working one was a main WndProc() window. Here is the section that is giving me the error.
    Code:
            case WM_INITDIALOG:
            {
                RECT rect;
                tablehwnd = onehwnd;
    
                GetClientRect(tablehwnd, &rect);
                InitCommonControls();
                
                //Create tabbed window
                hwndTab = CreateWindow(WC_TABCONTROL,"",WS_CHILD|WS_VISIBLE, //<< line that is having trouble
                      0,0,rect.right,rect.bottom,tablehwnd,(HMENU)TCITEM_HANDLE,
                      (HINSTANCE)GetWindowLong(tablehwnd,GWL_HINSTANCE),NULL);
    
                //Set up tabs
                tcitem.mask = TCIF_TEXT;
    
                //Create tabs
                tcitem.pszText = "Tab 1";
                int tabctrlone = TabCtrl_InsertItem(hwndTab, 0, &tcitem);
                tcitem.pszText = "Tab 2";
                int tabctrltwo = TabCtrl_InsertItem(hwndTab, 1, &tcitem);
    
                //Set tab index to 0, and show window for tab 0
                TabCtrl_SetCurSel(hwndTab,0);
                ShowWindow(hwndCalc,SW_SHOW);
    
                //Change tab font
                SendMessage (hwndTab,WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
            }
            break;
    Code:
    C:\Beta Studios\CP Full\main.h||In function `BOOL MathTableProc(HWND__*, UINT, WPARAM, LPARAM)':|
    C:\Beta Studios\CP Full\main.h|4519|error: expected primary-expression before ')' token|
    ||=== Build finished: 1 errors, 1 warnings ===|
    EDIT: Fixed it! I don't exactly know why, but I changed the (HMENU)TCITEM_HANDLE to NULL and it worked. If someone wants to explain that to me that'd be awesome, otherwise it's no big deal.
    Last edited by scwizzo; 07-14-2008 at 10:02 PM.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Quote Originally Posted by scwizzo View Post
    EDIT: Fixed it! I don't exactly know why, but I changed the (HMENU)TCITEM_HANDLE to NULL and it worked. If someone wants to explain that to me that'd be awesome, otherwise it's no big deal.
    What was TCITEM_HANDLE?

    As you used the child style, the CreateWindow() is expecting an ID number for the control (not a handle to a menu).

    Resource ID numbers are limited to 0xdfff (57,343).

    Exceeding this number may have caused the issue?

    EDIT: Using zero for the ID number may not be a good idea also....
    "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

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Quote Originally Posted by novacain View Post
    Exceeding this number may have caused the issue?
    The TCITEM_HANDLE was set as
    Code:
    #define TCITEM_HANDLE 6
    So it's possible the compiler did not like the value I defined it as. But yet, I have other handles defined as 1 to 14, although they are used in the resource file, and not a handle in a CreateWindow() function. But, removing it and placing NULL there did not make anything in other areas any more difficult. I just use the hwndTab handle when I want to use that window. Actually, the only time I use hwndTab is when I make a static window a child of hwndTab. Thanks for the help clearing that up, though!
    Last edited by scwizzo; 07-18-2008 at 10:14 PM.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    67
    You have to use NULL for the hMenu value ...
    http://msdn.microsoft.com/en-us/libr...51(VS.85).aspx
    http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx

    Take a look at TCITEM


    Greetz
    Greenhorn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. expected primary expression
    By lilhawk2892 in forum C++ Programming
    Replies: 10
    Last Post: 11-22-2007, 07:50 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM