Click here to Skip to main content
16,005,121 members
Home / Discussions / C#
   

C#

 
AnswerRe: Exceptions Pin
Giorgi Dalakishvili8-Nov-07 7:09
mentorGiorgi Dalakishvili8-Nov-07 7:09 
AnswerRe: Exceptions Pin
Judah Gabriel Himango8-Nov-07 7:09
sponsorJudah Gabriel Himango8-Nov-07 7:09 
AnswerRe: Exceptions Pin
codemunch8-Nov-07 7:12
codemunch8-Nov-07 7:12 
GeneralRe: Exceptions Pin
Anthony Mushrow8-Nov-07 7:58
professionalAnthony Mushrow8-Nov-07 7:58 
GeneralRe: Exceptions Pin
codemunch8-Nov-07 8:33
codemunch8-Nov-07 8:33 
AnswerRe: Exceptions Pin
Jim Warburton8-Nov-07 7:15
Jim Warburton8-Nov-07 7:15 
AnswerRe: Exceptions Pin
PIEBALDconsult8-Nov-07 15:33
mvePIEBALDconsult8-Nov-07 15:33 
QuestionHow to get a window's icon, WM_GETICON indeed. Pin
Anthony Mushrow8-Nov-07 6:48
professionalAnthony Mushrow8-Nov-07 6:48 
Now, i said i would, so i will http://www.codeproject.com/lounge.asp?msg=2309375#xx2309375xx[^]

Your Majesty,

I have been unable to obtain the icon of an open window for some time, despite my toughest efforts. I have been using SendMessage to send a message to a window, notepad for example, with the message WM_GETICON, and trying to get both small and large icons. This always returns with 0. Ma'am, i would greatly appreciate it if you would help me in solving my dilemma, through use of SendMessage or otherwise. Below you will find an example of the code i am using.

I remain your faithful and humble subject,
The Undefeated

C#
hWnd = IntPtr.Zero;
foreach(Process window in Process.GetProcesses()) {
	
	if(window.MainWindowTitle == this.textBox1.Text)
		hWnd = window.MainWindowHandle;
}
			
if(hWnd == IntPtr.Zero)
	MessageBox.Show("Could not find window");

...

if(hWnd != IntPtr.Zero) {
	//Apart from using int hIcon, i've also just used IntPtr
	int hIcon = SendMessage(hWnd, 0x7f, 1, 0);
	if(hIcon == 0)
		MessageBox.Show("Damn, it did it again");
	else
		//And i've also tried using Icon test = Icon.FromHandle(hIcon);
		this.pictureBox1.Image = Bitmap.FromHicon(new IntPtr(hIcon));
}

//Note that ShowWindow(hWnd, ShowWindowStyle.SW_HIDE); 
//actaully does hide the window, therefor, the handle works just fine


Wow, writing my user name "The Undefeated" ugh, its so old. I havn't used it in years, many years, but i thought i should perhaps leave it alone anyway Sigh | :sigh:



My current favourite word is: PIE!

Good ol' pie, it's been a while.

AnswerRe: How to get a window's icon, WM_GETICON indeed. Pin
Giorgi Dalakishvili8-Nov-07 7:00
mentorGiorgi Dalakishvili8-Nov-07 7:00 
GeneralRe: How to get a window's icon, WM_GETICON indeed. Pin
Anthony Mushrow8-Nov-07 7:44
professionalAnthony Mushrow8-Nov-07 7:44 
GeneralRe: How to get a window's icon, WM_GETICON indeed. Pin
Giorgi Dalakishvili8-Nov-07 8:08
mentorGiorgi Dalakishvili8-Nov-07 8:08 
QuestionFilter Graphs Pin
GrizzlyDoug8-Nov-07 6:19
GrizzlyDoug8-Nov-07 6:19 
AnswerRe: Filter Graphs Pin
Rich Insley8-Nov-07 9:59
Rich Insley8-Nov-07 9:59 
QuestionAttributes giving problem Pin
humayunlalzad8-Nov-07 5:57
humayunlalzad8-Nov-07 5:57 
AnswerRe: Attributes giving problem Pin
J4amieC8-Nov-07 6:18
J4amieC8-Nov-07 6:18 
AnswerRe: Attributes giving problem Pin
Pete O'Hanlon8-Nov-07 9:11
mvePete O'Hanlon8-Nov-07 9:11 
AnswerRe: Attributes giving problem [modified] Pin
PIEBALDconsult8-Nov-07 15:37
mvePIEBALDconsult8-Nov-07 15:37 
GeneralRe: Attributes giving problem Pin
PIEBALDconsult8-Nov-07 16:58
mvePIEBALDconsult8-Nov-07 16:58 
AnswerRe: Attributes giving problem Pin
Nissim Salomon9-Nov-07 0:15
Nissim Salomon9-Nov-07 0:15 
QuestionHow to Send Parameter(s) to Reporting Service ? Pin
hdv2128-Nov-07 4:34
hdv2128-Nov-07 4:34 
AnswerRe: How to Send Parameter(s) to Reporting Service ? Pin
Giorgi Dalakishvili8-Nov-07 6:23
mentorGiorgi Dalakishvili8-Nov-07 6:23 
GeneralRe: How to Send Parameter(s) to Reporting Service ? Pin
hdv2128-Nov-07 11:32
hdv2128-Nov-07 11:32 
GeneralRe: How to Send Parameter(s) to Reporting Service ? Pin
Giorgi Dalakishvili8-Nov-07 20:15
mentorGiorgi Dalakishvili8-Nov-07 20:15 
QuestionXML Deserialisation & Malformed XML [modified] Pin
MrEyes8-Nov-07 4:23
MrEyes8-Nov-07 4:23 
AnswerRe: XML Deserialisation & Malformed XML Pin
MrEyes8-Nov-07 4:58
MrEyes8-Nov-07 4:58 

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.