Click here to Skip to main content
15,924,195 members
Home / Discussions / C#
   

C#

 
GeneralRe: exe or development Pin
MoustafaS8-Jun-05 10:47
MoustafaS8-Jun-05 10:47 
GeneralRe: exe or development Pin
nemopeti8-Jun-05 12:22
nemopeti8-Jun-05 12:22 
Generaldeserializing XML in a webservice client Pin
albean888-Jun-05 7:20
albean888-Jun-05 7:20 
GeneralContext Menu in TreeView control Pin
SerialHobbyist8-Jun-05 6:03
SerialHobbyist8-Jun-05 6:03 
GeneralRe: Context Menu in TreeView control Pin
Andy Moore8-Jun-05 10:48
Andy Moore8-Jun-05 10:48 
GeneralRe: Context Menu in TreeView control Pin
SerialHobbyist15-Jun-05 6:18
SerialHobbyist15-Jun-05 6:18 
QuestionIndent List View Item? Pin
Dominik Reichl8-Jun-05 4:56
Dominik Reichl8-Jun-05 4:56 
GeneralAlpha Transparence problems with Image Class Pin
Kir Birger8-Jun-05 3:57
Kir Birger8-Jun-05 3:57 
I've been battling this for a long time, and i managed to get it working with the Icon class, but due to recent changes in a program I'm working on, I now have to keep all my icons as Image class members. This gives me the black border around alpha transparent pixels in my icons. This is the code i'm using:

For the API:
<br />
private static uint SHGFI_ICON = 0x100;                         // get icon<br />
		private static uint SHGFI_LARGEICON = 0x0;                      // get large icon<br />
		private static uint SHGFI_SMALLICON = 0x1;                      // get small icon<br />
		[DllImport("Shell32.dll")] <br />
<br />
		private static extern int SHGetFileInfo( string pszPath, uint dwFileAttributes, ref      SHFILEINFO psfi, int cbfileInfo, uint uFlags); <br />
 <br />
		private struct SHFILEINFO <br />
		{ <br />
			public IntPtr hIcon; <br />
			public int iIcon; <br />
			public int dwAttributes; <br />
			public string szDisplayName; <br />
			public string szTypeName; <br />
		} <br />
 <br />
		public enum FileIconSize <br />
		{<br />
			Small,		// 16x16 pixels<br />
			Large		// 32x32 pixels<br />
		}<br />
<br />
		public static Image GetFileIcon(string fullpath, FileIconSize size) <br />
		{<br />
			SHFILEINFO info = new SHFILEINFO();<br />
<br />
			uint flags = SHGFI_ICON;<br />
			//uint flags = SHGFI_ICON|SHGFI_SYSICONINDEX;<br />
			if (size == FileIconSize.Small) <br />
			{<br />
				flags |= SHGFI_SMALLICON;<br />
			}<br />
<br />
			int retval = SHGetFileInfo(fullpath, 0, ref info, System.Runtime.InteropServices.Marshal.SizeOf(info), flags);<br />
			if (retval == 0) <br />
			{<br />
				return null;	// error occured<br />
			}<br />
<br />
			System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(info.hIcon); <br />
			<br />
			System.Windows.Forms.ImageList imgList = new ImageList();<br />
			imgList.ColorDepth = ColorDepth.Depth32Bit;<br />
			imgList.ImageSize = icon.Size;<br />
			imgList.Images.Add(icon);<br />
			return imgList.Images[0];<br />
		}	<br />


Actual working code on a Windows Form:
<br />
                        Graphics g = Graphics.FromHwnd(this.Handle);<br />
			g.FillRectangle(System.Drawing.SystemBrushes.ControlDark,20,50,32,32);<br />
			Image ico;<br />
			ico = API.GetIcon(ofd1.FileName, API.FileIconSize.Small);<br />
<br />
<br />
                        g.DrawImage(ico, 20,50);<br />



can anyone tell me what i'm doing wrong? i thought i had taken care of all the little possible ways to screw it up, such as converting it to a bitmap...
Generaltreeview checkbox Pin
Mohammad Daba'an8-Jun-05 3:18
Mohammad Daba'an8-Jun-05 3:18 
GeneralRe: treeview checkbox Pin
codeprojectin8-Jun-05 17:46
codeprojectin8-Jun-05 17:46 
Generalpropertygrid question Pin
jill_b8-Jun-05 3:15
sussjill_b8-Jun-05 3:15 
QuestionChange TabControl ItemSize dynamically? Pin
Member 17028208-Jun-05 1:31
Member 17028208-Jun-05 1:31 
AnswerRe: Change TabControl ItemSize dynamically? Pin
codeprojectin8-Jun-05 18:12
codeprojectin8-Jun-05 18:12 
GeneralDisplay data from text file to LISTVIEW Pin
ksanju10008-Jun-05 0:34
ksanju10008-Jun-05 0:34 
GeneralRe: Display data from text file to LISTVIEW Pin
Carsten Zeumer8-Jun-05 1:41
Carsten Zeumer8-Jun-05 1:41 
GeneralRe: Display data from text file to LISTVIEW Pin
ksanju10008-Jun-05 3:12
ksanju10008-Jun-05 3:12 
GeneralRe: Display data from text file to LISTVIEW Pin
Carsten Zeumer8-Jun-05 3:48
Carsten Zeumer8-Jun-05 3:48 
GeneralRe: Display data from text file to LISTVIEW Pin
ksanju10008-Jun-05 5:08
ksanju10008-Jun-05 5:08 
GeneralRe: Display data from text file to LISTVIEW Pin
Carsten Zeumer8-Jun-05 6:09
Carsten Zeumer8-Jun-05 6:09 
GeneralRe: Display data from text file to LISTVIEW Pin
ksanju10009-Jun-05 1:12
ksanju10009-Jun-05 1:12 
GeneralRe: Display data from text file to LISTVIEW Pin
ksanju10009-Jun-05 19:40
ksanju10009-Jun-05 19:40 
Generalresize the Button control Pin
prinz_simo8-Jun-05 0:26
prinz_simo8-Jun-05 0:26 
GeneralRe: resize the Button control Pin
MoustafaS8-Jun-05 2:21
MoustafaS8-Jun-05 2:21 
GeneralMS Word spell checker Pin
Gktony8-Jun-05 0:01
Gktony8-Jun-05 0:01 
GeneralRe: MS Word spell checker Pin
Anonymous9-Jun-05 4:03
Anonymous9-Jun-05 4:03 

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.