Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie needs help with access violation 1

Status
Not open for further replies.

deepthought42

Programmer
Mar 24, 2002
19
0
0
GB
HI all hope someone can help.

My problem is that when I try using a 'LIST CONTROL' I keep getting a access violation when running the debugger.

The actual error message is:
First-chance exception in Sunday24MarProp.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
The coding I am using is shown below.

Any suggestions gratefully received
Regards Dene

// your code/pre-formatted item here

HICON hIcon[8];
int n;

m_imageList.Create(16, 16, 0, 8, 8);
hIcon[0] = AfxGetApp()->LoadIcon(IDI_ICON1);
hIcon[1] = AfxGetApp()->LoadIcon(IDI_ICON2);
hIcon[2] = AfxGetApp()->LoadIcon(IDI_ICON3);
hIcon[3] = AfxGetApp()->LoadIcon(IDI_ICON4);
hIcon[4] = AfxGetApp()->LoadIcon(IDI_ICON5);
hIcon[5] = AfxGetApp()->LoadIcon(IDI_ICON6);
hIcon[6] = AfxGetApp()->LoadIcon(IDI_ICON7);
hIcon[7] = AfxGetApp()->LoadIcon(IDI_ICON8);

for(n = 0; n < 8; n++)
{
m_imageList.Add(hIcon[n]);
}

static char* color[] = {&quot;one&quot;, &quot;two&quot;, &quot;Three&quot;, &quot;Four&quot;, &quot;Five&quot;,
&quot;Six&quot;, &quot;Severn&quot;, &quot;Eight&quot;};

CListCtrl* pList = (CListCtrl*) GetDlgItem(IDC_LIST1);
pList->SetImageList(&m_imageList, LVSIL_SMALL);

for(n = 0; n < 8; n++)
{
pList->InsertItem(n, color[n], n);
}
pList->SetBkColor(RGB(255, 255, 0));
pList->SetTextBkColor(RGB(255, 255, 0));
 
First-chance exceptions occur at a lower level in your program. Usually some API will register an exception handler in anticipation of a failure condition. If this condition occurs then you see a “First-chance exception”. Your Debugger sees this exception before it is handled (by KERNEL32.DLL in your case). If this exception is unhandled then you get a “second-chance exception”, which is when your program crashes!

First-chance exceptions can be an indicator of bad parameters however; often they just have to be ignored.

You may wish to read about Structured exception handling or MS Knowledge Base article Q105675 as a start.

Beowulf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top