Click here to Skip to main content
15,921,840 members
Home / Discussions / C#
   

C#

 
AnswerRe: Newbie: Programaticaly adding items to a dropdown menu? Pin
Stefan Troschuetz2-Nov-06 0:02
Stefan Troschuetz2-Nov-06 0:02 
AnswerRe: Newbie: Programaticaly adding items to a dropdown menu? Pin
V.2-Nov-06 0:13
professionalV.2-Nov-06 0:13 
GeneralRe: Newbie: Programaticaly adding items to a dropdown menu? Pin
t lab2-Nov-06 1:59
t lab2-Nov-06 1:59 
GeneralRe: Newbie: Programaticaly adding items to a dropdown menu? Pin
V.2-Nov-06 2:18
professionalV.2-Nov-06 2:18 
GeneralRe: Newbie: Programaticaly adding items to a dropdown menu? Pin
t lab2-Nov-06 2:47
t lab2-Nov-06 2:47 
AnswerRe: Newbie: Programaticaly adding items to a dropdown menu? Pin
t lab2-Nov-06 2:43
t lab2-Nov-06 2:43 
QuestionShell icons Pin
PaulPrice1-Nov-06 23:07
PaulPrice1-Nov-06 23:07 
AnswerRe: Shell icons Pin
Saqib Mehmood2-Nov-06 2:42
Saqib Mehmood2-Nov-06 2:42 
for getting file icons you need to use shell APIs. you can use the following snippet.

// define a struct for getting info from shell

[StructLayout(LayoutKind.Sequential)]
public struct SHFILEINFO
{
	public IntPtr hIcon;
	public IntPtr iIcon;
	public uint dwAttributes;
	[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
	public string szDisplayName;
	[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
	public string szTypeName;
};

// define this class for invoking shell api to get file information
class Win32
{
	public const uint SHGFI_ICON = 0x100;
	public const uint SHGFI_LARGEICON = 0x0; // 'Large icon
	public const uint SHGFI_SMALLICON = 0x1; // 'Small icon

	[DllImport("shell32.dll")]
	public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
}

// write the following code where you want to get the selected file icon.

IntPtr hImgSmall; //the handle to the system image list
string fName = "c:\\getfileicon.cs"; //  'the file name to get icon from
SHFILEINFO shinfo = new SHFILEINFO();

//Use this to get the small Icon
hImgSmall = Win32.SHGetFileInfo(fName, 0, ref shinfo,(uint)Marshal.SizeOf(shinfo),Win32.SHGFI_ICON |Win32.SHGFI_SMALLICON);

/*
	//Use this to get the small Icon
	hImgLarge = Win32.SHGetFileInfo(fName, 0, ref shinfo,(uint)Marshal.SizeOf(shinfo),Win32.SHGFI_ICON |Win32.SHGFI_LARGEICON); 
*/

//The icon is returned in the hIcon member of the shinfo struct
System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);

// do whatever with this icon. i.e I am adding it to an Image List.
imageList1.Images.Add(myIcon);

I think this code would be helpful.


Saqib

QuestionHow to implement a dictionary lookup in windows form application? Pin
XuanThang Hoang1-Nov-06 23:03
XuanThang Hoang1-Nov-06 23:03 
QuestionHow to change diaplayname of property outside the class Pin
praveenqwe1-Nov-06 22:59
praveenqwe1-Nov-06 22:59 
AnswerRe: How to change diaplayname of property outside the class Pin
aamironline1-Nov-06 23:05
aamironline1-Nov-06 23:05 
AnswerRe: How to change diaplayname of property outside the class Pin
praveenqwe2-Nov-06 18:10
praveenqwe2-Nov-06 18:10 
Questionmultilingual applications Pin
abyclassic1-Nov-06 22:32
abyclassic1-Nov-06 22:32 
AnswerRe: multilingual applications Pin
aamironline2-Nov-06 7:22
aamironline2-Nov-06 7:22 
GeneralRe: multilingual applications Pin
abyclassic2-Nov-06 18:40
abyclassic2-Nov-06 18:40 
GeneralRe: multilingual applications Pin
lmoelleb2-Nov-06 20:41
lmoelleb2-Nov-06 20:41 
QuestionCombining Columns In A ListBox Pin
Samuel G1-Nov-06 22:18
Samuel G1-Nov-06 22:18 
Questionscrollbar when user's got low resolution? Pin
livez1-Nov-06 22:04
livez1-Nov-06 22:04 
AnswerRe: scrollbar when user's got low resolution? Pin
quiteSmart1-Nov-06 22:08
quiteSmart1-Nov-06 22:08 
AnswerRe: scrollbar when user's got low resolution? Pin
MJay1-Nov-06 22:15
MJay1-Nov-06 22:15 
GeneralRe: scrollbar when user's got low resolution? Pin
livez1-Nov-06 22:19
livez1-Nov-06 22:19 
GeneralRe: scrollbar when user's got low resolution? Pin
MJay1-Nov-06 22:36
MJay1-Nov-06 22:36 
AnswerRe: scrollbar when user's got low resolution? Pin
luckykhalid1-Nov-06 22:27
luckykhalid1-Nov-06 22:27 
AnswerRe: scrollbar when user's got low resolution? Pin
aamironline1-Nov-06 22:30
aamironline1-Nov-06 22:30 
GeneralRe: scrollbar when user's got low resolution? Pin
livez1-Nov-06 22:37
livez1-Nov-06 22:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.