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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locating resources: icons

Status
Not open for further replies.

Maurader

Technical User
May 8, 2002
59
CA
I am developing a MFC dll, and my code has

// Initialize the list control (Rectangle / Obround / Single D / Double D)

m_shape_image.Create (32, 32, 0, 0, 8);
icon[0] = AfxGetApp()->LoadIcon(IDI_RECTANGLE);
icon[1] = AfxGetApp()->LoadIcon(IDI_OBROUND);
icon[2] = AfxGetApp()->LoadIcon(IDI_SINGLE_D);
icon[3] = AfxGetApp()->LoadIcon(IDI_DOUBLE_D);

for (i = 0; i < N_SHAPES; i++)
m_shape_image.Add (icon);

CListCtrl *list = (CListCtrl *) GetDlgItem (IDC_SHAPES);
list->SetImageList (&m_shape_image, LVSIL_SMALL);
for (i = 0; i < N_SHAPES; i++)
{
get_msg (TEXT_HDR, s, M_SHAPES + i);
list->InsertItem (i, s, i);
}


but when i compile and use the dll, it cannot locate the icons and the list is blank. Is there something wrong with my path settings? or where I need to put the .ico files?

Thanks!
 
If you have made a resource DLL you need to load it with

AfxLoadLibrary(&quot;DLLNAME.dll&quot;);

Matt
 
Sorry forgot to mention a step

HINSTANCE hDLL= NULL;

hDLL= AfxLoadLibrary(_T(&quot;JapaneseDll.dll&quot;));
if(hDLL)
{
AfxSetResourceHandle(hDLL);
}
 
I don't have a resource dll...do I need to create one?
I only have a mail dll called shapes.dll, which is created from cpp files...and in these cpp files i have the above code...
 
Oh, no, i misunderstood. If you made the resources and loaded them into the app you should just be able to call the load functions based on their name.

I would test first that you can load a single icon

replace this line in your code with a different icon id and see if you can infact load it properly


m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
 
right now my code is

HICON m_icon;
m_icon = AfxGetApp()->LoadIcon(IDI_RECTANGLE);
m_shape_image.Create (32, 32, 0, 0, 8);
m_shape_image.Add (m_icon);
CListCtrl *list = (CListCtrl *) GetDlgItem (IDC_SHAPES);
list->SetImageList (&m_shape_image, LVSIL_SMALL);
for (i = 0; i < N_SHAPES; i++)
{
get_msg (TEXT_HDR, s, M_SHAPES + i);
list->InsertItem (i, s, i);
}

which still doesn't show the icons...are there any paths that i need to set? or where should my .ico files be located?
 
yup, i have created these icons in the resources folder, and right now the .ico files are located in C:\shapes, but aftr I create the DLL, I put it in C:\Mill.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top