Click here to Skip to main content
15,900,378 members
Home / Discussions / C#
   

C#

 
GeneralRe: RCW question when returning a string Pin
Heath Stewart22-May-04 4:18
protectorHeath Stewart22-May-04 4:18 
Generallistbox control in C# Pin
HowRU21-May-04 22:22
HowRU21-May-04 22:22 
GeneralRe: listbox control in C# Pin
Heath Stewart22-May-04 4:52
protectorHeath Stewart22-May-04 4:52 
GeneralPassing a Class to an Unmanaged function as parameter Pin
shajuMathew21-May-04 20:49
shajuMathew21-May-04 20:49 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Heath Stewart22-May-04 4:17
protectorHeath Stewart22-May-04 4:17 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
shajuMathew26-May-04 1:32
shajuMathew26-May-04 1:32 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Heath Stewart26-May-04 3:23
protectorHeath Stewart26-May-04 3:23 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Member 93002222-May-04 9:18
Member 93002222-May-04 9:18 
When I was marshalling EnumChildWindows, I declared the function like that:
[DllImport("user32.dll",SetLastError=true)]<br />
			public static extern bool EnumChildWindows(      <br />
				IntPtr  hWndParent,<br />
				User32Functions.EnumWindowsCallback  lpEnumFunc,<br />
				IntPtr lParam<br />
				);

The point is, why do you need to pass a class or struct as the third parameter?
I followed the MSDN recommendation and called the function like that:
GCHandle gch=GCHandle.Alloc(this.twHandles);<br />
User32.EnumChildWindows(handleParent,this.enumThreadCallback,(IntPtr)gch);<br />
gch.Free();


Here this.twHandles is a text writer, which i later (in the callback function) use like so:
private  bool  CaptureEnumThreadWindows(int handle, IntPtr param)<br />
		{<br />
			GCHandle gch=(GCHandle)param;<br />
			TextWriter tw=(TextWriter)gch.Target;<br />
			twHandles.Write(handle.ToString()+" ");<br />
			twHandles.Flush();<br />
              return true;<br />
		}

Anyway, MSDN recommends to use GCHandle , 'so the delegate does not get moved by GC before the call ends, however I was trying to use without GCHandle, just passing IntPtr.Zero as the last parameter and it works anyway. Frankly I don't understand how this (GCHandle) can prevent the delegate from being moved by GC, but that's what MSDN says. (see GCHandle sample)
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
shajuMathew26-May-04 1:35
shajuMathew26-May-04 1:35 
QuestionHow to use a DirectShow filter in C# ? Pin
ro_angel_bv21-May-04 20:11
ro_angel_bv21-May-04 20:11 
AnswerRe: How to use a DirectShow filter in C# ? Pin
Heath Stewart22-May-04 4:00
protectorHeath Stewart22-May-04 4:00 
GeneralRe: How to use a DirectShow filter in C# ? Pin
ro_angel_bv22-May-04 9:21
ro_angel_bv22-May-04 9:21 
GeneralRe: How to use a DirectShow filter in C# ? Pin
Heath Stewart23-May-04 3:31
protectorHeath Stewart23-May-04 3:31 
GeneralRe: How to use a DirectShow filter in C# ? Pin
mjKPL1-Sep-10 5:55
mjKPL1-Sep-10 5:55 
GeneralFile Compression Pin
demasoni.com21-May-04 19:34
demasoni.com21-May-04 19:34 
GeneralRe: File Compression Pin
David M. Kean22-May-04 0:35
David M. Kean22-May-04 0:35 
GeneralRe: File Compression Pin
demasoni.com22-May-04 12:48
demasoni.com22-May-04 12:48 
GeneralSetup with InstallShield Pin
quocbao21-May-04 16:34
quocbao21-May-04 16:34 
GeneralRe: Setup with InstallShield Pin
Heath Stewart22-May-04 2:38
protectorHeath Stewart22-May-04 2:38 
GeneralCalling a function in another window. Pin
Bojan Rajkovic21-May-04 16:13
Bojan Rajkovic21-May-04 16:13 
GeneralRe: Calling a function in another window. Pin
Dimitris Iliopoulos22-May-04 0:06
Dimitris Iliopoulos22-May-04 0:06 
GeneralTest and label fields misalign on windows 2000 Pin
Parrish Pope21-May-04 15:58
sussParrish Pope21-May-04 15:58 
GeneralRe: Test and label fields misalign on windows 2000 Pin
Dimitris Iliopoulos22-May-04 0:10
Dimitris Iliopoulos22-May-04 0:10 
GeneralRe: Test and label fields misalign on windows 2000 Pin
Heath Stewart22-May-04 2:47
protectorHeath Stewart22-May-04 2:47 
GeneralRe: Test and label fields misalign on windows 2000 Pin
Heath Stewart22-May-04 3:38
protectorHeath Stewart22-May-04 3:38 

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.