Hi Philipp
while reading your mail I wrote this code. Just go through
it.
[DllImport("shell32.dll",CharSet=CharSet.Auto)]
public static extern int ExtractIconEx(
string path, int i, IntPtr[] small, IntPtr[] big, uint op);
[DllImport("user32.dll",CharSet=CharSet.Auto)]
public static extern int DrawIconEx(
IntPtr hdc, // handle to device context
int xLeft, // x-coord of upper left corner
int yTop, // y-coord of upper left corner
IntPtr hIcon, // handle to icon
int cxWidth, // icon width
int cyWidth, // icon height
uint istepIfAniCur, // frame index, animated cursor
IntPtr dbrFlickerFreeDraw, // handle to background brush
uint diFlags); // icon-drawing flags
.
.
.
.
.
.
.
.
.
.
int m_nIcons = ExtractIconEx(
"C:\\WINNT\\system32\\SHELL32.dLL",
-1,
null,
null,
0);
if(m_nIcons == -1)
{
MessageBox.Show("Couldn't retreive icons.");
return;
}
IntPtr[] m_pIconsLarge = new IntPtr[m_nIcons];
IntPtr[] m_pIconsSmall = new IntPtr[m_nIcons];
ExtractIconEx(
"C:\\WINNT\\system32\\SHELL32.dLL",
0,
m_pIconsLarge,
m_pIconsSmall,
(uint)m_nIcons);
Graphics gf = Graphics.FromHwnd(this.Handle);
IntPtr hDC = gf.GetHdc();
for(int i = 0 ; i < m_nIcons; i++)
{
DrawIconEx(hDC, // DC
60,60, // x,y
m_pIconsLarge[i], // HICON
100,100, // cx,cy
0, // frame num N/A
(IntPtr)null , // background brush
3); // flags
System.Threading.Thread.Sleep(500);
}
There are some easier ways of drawing icons and bitmaps
under .Net.
you might wanna explore functions like Graphics
class's DrawIcon function.
Do write back if there is anything you wanna ask.
Ankur Verma
.Net and C++ Specialist
Wiley Tech Support
|