Ive got a problem with Dev-c++ and the INITCOMMONCONTROLSEX command
after attaching all the libarays and header files assoicted with this command I still get the Error :
Parse error before ;
but the line is legal global identifier
This even happens after dling the latest header anmd libary files for dev
can somebody plz help me
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
/* Define a window class. */
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.hInstance=hThisInst; /* handle to this instance */
wcl.lpszClassName=szWinName; /* window class name */
wcl.lpfnWndProc=WindowFunc; /* window function */
wcl.style=0; /* default style */
wcl.lpszMenuName=NULL; /* no menu */
wcl.cbClsExtra=0; /* no extra info needed */
wcl.cbWndExtra=0; /* no extra info needed */
/* white window background */
wcl.hbrBackground=(HBRUSH) GetStockObject(WHITE_BRUSH);
/* register window class */
if(!RegisterClassEx(&wcl)) return 0;
/* create a window of the type just registered */
hwnd=CreateWindow(
szWinName, /* name of window class */
"Using Tab controls", /* title */
WS_OVERLAPPEDWINDOW, /* window style normal */
CW_USEDEFAULT, /* X coordinate - let Windows decide */
CW_USEDEFAULT, /* Y coordinate - let Windows decide */
CW_USEDEFAULT, /* width - let Windows decide */
CW_USEDEFAULT, /* height - let Windows decide */
HWND_DESKTOP, /* no parent window */
NULL, /* no menu */
hThisInst, /* handle of this program instance */
NULL); /* no additional arguments */
/* Initialize the common controls */
cc.dwSize=sizeof(INITCOMMONCONTROLSEX);
cc.dwICC=ICC_TAB_CLASSES;
InitCommonControlsEx(&cc);
hInst=hThisInst; /* Save the current instance handle */
/* display the window */
ShowWindow(hwnd,nWinMode);
UpdateWindow(hwnd);
/* create the message loop */
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg); /* translate keyboard messages */
DispatchMessage(&msg); /* return control to Windows */
}
return msg.wParam;
}
/* function called by Windows, passed messages from the message queue */
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
NMHDR *nmptr;
int tabnumber;
HDC hdc;
char str[80];
TCITEM tci;
RECT WinDim;
switch(message)
{
case WM_CREATE:
GetClientRect(hwnd,&WinDim); /* get size of parrent window */
/* create a tab control */
hTabWnd=CreateWindow(
WC_TABCONTROL,
"",
WS_VISIBLE|WS_TABSTOP|WS_CHILD,
0,0,WinDim.right,WinDim.bottom,
hwnd,
NULL,
hInst,
NULL);
break;
case WM_NOTIFY: /* Process a tab change */
nmptr=(LPNMHDR)lParam;
if(nmptr->code == TCN_SELCHANGE)
{
tabnumber = TabCtrl_GetCurSel((HWND)nmptr->hwndFrom);
hdc = GetDC(hTabWnd);
sprintf(str,"Do this and show the number %d",tabnumber+1);
SetBkColor(hdc,RGB(200,200,100));
TextOut(hdc,40,100,str,strlen(str));
ReleaseDC(hTabWnd,hdc);
}
break;
case WM_DESTROY: /* terminate the program */
PostQuitMessage(0);
break;
default:
/* let Windows prcess any messages not in this switch statement */
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
now ive complied this in MVC++ and it works it also works in LCC-win32 but dev keeps saying parse error before
';' on the line INITCOMMONCONTROLSEX cc;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yeah, the InitCommonControlsEx() function doesn't exist in the mingw headers / libs. You might want to try getting the common control header update off of vUpdate. If it still doesn't work, just you InitCommonControls(). That is what I use and it works fine. Good luck =)
Kip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ive got a problem with Dev-c++ and the INITCOMMONCONTROLSEX command
after attaching all the libarays and header files assoicted with this command I still get the Error :
Parse error before ;
but the line is legal global identifier
This even happens after dling the latest header anmd libary files for dev
can somebody plz help me
Show us the code.
Kip
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM);
char szWinName[]="MyWin"; /* name of window clas */
/* Globals */
HINSTANCE hInst;
HWND hwnd;
HWND hTabWnd;
int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpszArgs,int nWinMode)
{
MSG msg;
WNDCLASSEX wcl;
INITCOMMONCONTROLSEX cc;
/* Define a window class. */
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.hInstance=hThisInst; /* handle to this instance */
wcl.lpszClassName=szWinName; /* window class name */
wcl.lpfnWndProc=WindowFunc; /* window function */
wcl.style=0; /* default style */
wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION); /* standard icon */
wcl.hIconSm=LoadIcon(NULL,IDI_WINLOGO); /* minimized icon */
wcl.hCursor=LoadCursor(NULL,IDC_ARROW); /* cursor style */
wcl.lpszMenuName=NULL; /* no menu */
wcl.cbClsExtra=0; /* no extra info needed */
wcl.cbWndExtra=0; /* no extra info needed */
/* white window background */
wcl.hbrBackground=(HBRUSH) GetStockObject(WHITE_BRUSH);
/* register window class */
if(!RegisterClassEx(&wcl)) return 0;
/* create a window of the type just registered */
hwnd=CreateWindow(
szWinName, /* name of window class */
"Using Tab controls", /* title */
WS_OVERLAPPEDWINDOW, /* window style normal */
CW_USEDEFAULT, /* X coordinate - let Windows decide */
CW_USEDEFAULT, /* Y coordinate - let Windows decide */
CW_USEDEFAULT, /* width - let Windows decide */
CW_USEDEFAULT, /* height - let Windows decide */
HWND_DESKTOP, /* no parent window */
NULL, /* no menu */
hThisInst, /* handle of this program instance */
NULL); /* no additional arguments */
/* Initialize the common controls */
cc.dwSize=sizeof(INITCOMMONCONTROLSEX);
cc.dwICC=ICC_TAB_CLASSES;
InitCommonControlsEx(&cc);
hInst=hThisInst; /* Save the current instance handle */
/* display the window */
ShowWindow(hwnd,nWinMode);
UpdateWindow(hwnd);
/* create the message loop */
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg); /* translate keyboard messages */
DispatchMessage(&msg); /* return control to Windows */
}
return msg.wParam;
}
/* function called by Windows, passed messages from the message queue */
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
NMHDR *nmptr;
int tabnumber;
HDC hdc;
char str[80];
TCITEM tci;
RECT WinDim;
switch(message)
{
case WM_CREATE:
GetClientRect(hwnd,&WinDim); /* get size of parrent window */
/* create a tab control */
hTabWnd=CreateWindow(
WC_TABCONTROL,
"",
WS_VISIBLE|WS_TABSTOP|WS_CHILD,
0,0,WinDim.right,WinDim.bottom,
hwnd,
NULL,
hInst,
NULL);
tci.mask=TCIF_TEXT;
tci.iImage=-1;
tci.pszText = "Justin";
TabCtrl_InsertItem(hTabWnd,0,&tci);
tci.pszText = "Do";
TabCtrl_InsertItem(hTabWnd,1,&tci);
tci.pszText = "This";
TabCtrl_InsertItem(hTabWnd,2,&tci);
break;
case WM_NOTIFY: /* Process a tab change */
nmptr=(LPNMHDR)lParam;
if(nmptr->code == TCN_SELCHANGE)
{
tabnumber = TabCtrl_GetCurSel((HWND)nmptr->hwndFrom);
hdc = GetDC(hTabWnd);
sprintf(str,"Do this and show the number %d",tabnumber+1);
SetBkColor(hdc,RGB(200,200,100));
TextOut(hdc,40,100,str,strlen(str));
ReleaseDC(hTabWnd,hdc);
}
break;
case WM_DESTROY: /* terminate the program */
PostQuitMessage(0);
break;
default:
/* let Windows prcess any messages not in this switch statement */
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
now ive complied this in MVC++ and it works it also works in LCC-win32 but dev keeps saying parse error before
';' on the line INITCOMMONCONTROLSEX cc;
Yeah, the InitCommonControlsEx() function doesn't exist in the mingw headers / libs. You might want to try getting the common control header update off of vUpdate. If it still doesn't work, just you InitCommonControls(). That is what I use and it works fine. Good luck =)
Kip