Click here to Skip to main content
15,917,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: Initialize control dropped on form? Pin
MilesAhead10-May-04 10:43
MilesAhead10-May-04 10:43 
AnswerRe: Initialize control dropped on form? Pin
MilesAhead13-May-04 11:43
MilesAhead13-May-04 11:43 
Generalwhich dll need to be imported to customize PrintPreviewDialog Pin
sachinkalse9-May-04 16:25
sachinkalse9-May-04 16:25 
GeneralRe: which dll need to be imported to customize PrintPreviewDialog Pin
Heath Stewart10-May-04 3:59
protectorHeath Stewart10-May-04 3:59 
GeneralRe: which dll need to be imported to customize PrintPreviewDialog Pin
sachinkalse12-May-04 21:05
sachinkalse12-May-04 21:05 
GeneralRe: which dll need to be imported to customize PrintPreviewDialog Pin
Heath Stewart13-May-04 2:30
protectorHeath Stewart13-May-04 2:30 
GeneralBeginInvoke Pin
Hugo Hallman9-May-04 12:50
Hugo Hallman9-May-04 12:50 
GeneralRe: BeginInvoke Pin
Heath Stewart10-May-04 3:57
protectorHeath Stewart10-May-04 3:57 
You won't get memory leaks if you ignore AsyncResults. .NET is GC'd. More than likely you're not using Control.InvokeRequired and Control.Invoke to call methods and get/set properties on controls created in a different thread. This is a common problem. When you comunicate with a control that was created on a different thread (the UI thread), you must use the ISynchronizeInvoke impementation that every control inherits from Control. This makes sure that communciate with the control happens in the UI thread.

If you want PostMessage, why not just P/Invoke it? If you read the forms, we're continually telling people to P/Invoke SendMessage to send the message immediately, but P/Invoking PostMessage is really no different. It would just look like this:
[DllImport("user32.dll")]
private static extern bool PostMessage(
  IntPtr hWnd,
  [MarshalAs(UnmanagedType.U4)] int msg,
  IntPtr wParam,
  IntPtr lParam);
If you need to pass a struct or reference to a struct or something, instead of marshaling the struct yourself and passing it as an IntPtr, you could overload PostMessage like so:
[DllImport("user32.dll")]
private static extern bool PostMessage(
  IntPtr hWnd,
  [MarshalAs(UnmanagedType.U4)] int msg,
  int wParam, // DON'T NEED - SET TO 0
  ref LVITEM lvItem);
Of course, you'd need to declare a managed LVITEM struct (can be named whatever you like, though) that would marshal correctly.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: BeginInvoke Pin
Hugo Hallman10-May-04 5:29
Hugo Hallman10-May-04 5:29 
GeneralRe: BeginInvoke Pin
Heath Stewart10-May-04 5:34
protectorHeath Stewart10-May-04 5:34 
GeneralEmail clients Pin
wfe9-May-04 12:13
wfe9-May-04 12:13 
GeneralRe: Email clients Pin
Dave Kreskowiak10-May-04 0:11
mveDave Kreskowiak10-May-04 0:11 
GeneralRe: Email clients Pin
wfe10-May-04 1:17
wfe10-May-04 1:17 
GeneralRe: Email clients Pin
Heath Stewart10-May-04 3:49
protectorHeath Stewart10-May-04 3:49 
GeneralRe: Email clients Pin
wfe10-May-04 7:59
wfe10-May-04 7:59 
GeneralRe: Email clients Pin
Heath Stewart10-May-04 8:58
protectorHeath Stewart10-May-04 8:58 
GeneralRe: Email clients Pin
wfe10-May-04 9:23
wfe10-May-04 9:23 
GeneralRe: Email clients Pin
Heath Stewart10-May-04 9:43
protectorHeath Stewart10-May-04 9:43 
GeneralRe: Email clients Pin
wfe11-May-04 3:00
wfe11-May-04 3:00 
GeneralRe: Email clients Pin
Heath Stewart11-May-04 3:12
protectorHeath Stewart11-May-04 3:12 
GeneralMemory Usage of a console application Pin
eranas9-May-04 10:25
eranas9-May-04 10:25 
GeneralRe: Memory Usage of a console application Pin
Jeff Varszegi9-May-04 12:11
professionalJeff Varszegi9-May-04 12:11 
GeneralRe: Memory Usage of a console application Pin
Heath Stewart10-May-04 3:39
protectorHeath Stewart10-May-04 3:39 
GeneralMouse Drag Event Pin
Member 6910899-May-04 7:15
Member 6910899-May-04 7:15 
GeneralRe: Mouse Drag Event Pin
Mazdak9-May-04 7:52
Mazdak9-May-04 7:52 

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.