Am creating application and l need to fill a combo box list. However, l was able to do all and is working but whenever l filling the last combobox, l get an exception as below.
First-chance exception at 0x7789dba9 in Unical PTUME.exe: 0xC0000005: Access violation reading location 0x00000001.
Unhandled exception at 0x7789dba9 in Unical PTUME.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
What does it mean and how can l correct it?
code snippet below:
case WM_CREATE:
DialogBox(((LPCREATESTRUCT)lParam)->hInstance, MAKEINTRESOURCE(IDD_CHOICEBOX),hWnd,choicedlg);//Dialog proc.
return 0;
INT_PTR CALLBACK choicedlg(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
int i=0; static int firsttime=1; PWSTR input=NULL;
switch(message)
{
case WM_INITDIALOG:
//Add faculties to the combo list
for(i=0; i<=sizeof(Choice)/sizeof(Choice[0]); i++){
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_FACULTY,CB_ADDSTRING,0,(LPARAM)Choice[i]);
}
for(i=0; i<=sizeof(Course)/sizeof(Course[0]); i++){
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT1,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT2,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT3,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT4,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT5,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT6,CB_ADDSTRING,0,(LPARAM)Course[i]);
}
for(i=0; i<=sizeof(Year)/sizeof(Year[0]); i++){
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR1,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR2,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR3,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR4,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR5,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR6,CB_ADDSTRING,0,(LPARAM)Year[i]);
} //etc
However, if l add the code below, l always get error message as above.
for(i=0; i<=sizeof(Time)/sizeof(Time[0]); i++){
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_TIME,CB_ADDSTRING,0,(LPARAM)Time[i]);
}// problem code