Click here to Skip to main content
15,909,953 members
Home / Discussions / C#
   

C#

 
GeneralStreams and Unmanaged code Pin
Tristan Rhodes20-Dec-04 5:44
Tristan Rhodes20-Dec-04 5:44 
GeneralRe: Streams and Unmanaged code Pin
Heath Stewart20-Dec-04 6:38
protectorHeath Stewart20-Dec-04 6:38 
GeneralNativeWindow disposing on WM_DESTROY Pin
stefan houtz20-Dec-04 0:53
stefan houtz20-Dec-04 0:53 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
Heath Stewart20-Dec-04 5:57
protectorHeath Stewart20-Dec-04 5:57 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
stefan houtz21-Dec-04 1:05
stefan houtz21-Dec-04 1:05 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
Heath Stewart21-Dec-04 7:55
protectorHeath Stewart21-Dec-04 7:55 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
stefan houtz22-Dec-04 2:52
stefan houtz22-Dec-04 2:52 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
Heath Stewart22-Dec-04 6:38
protectorHeath Stewart22-Dec-04 6:38 
Something else I noticed right off the bat:
[ClassInterface(ClassInterfaceType.AutoDual)]
NEVER use this. Auto-generated class interfaces are the worst thing ever added to the Framework, in my opinion. If you know anything about COM, you should agree. While .NET isn't prone to problems caused my moving members around, native code (like the COM infrastructure) is. Always declare your class interfaces explicitly, always use a hard-coded, unchanging guid via the GuidAttribute on both your class and COM-exposed interfaces, and never change published interfaces. Derive new ones, implement those as the first interface of your class (which the CLR treats as your class interface when you use ClassInterfaceType.None with the ClassInterfaceAttribute) successively when releasing new interfaces. This is how you'd do it in COM and need to replicate that behavior in .NET. While .NET doesn't care, COM sees a different story and clients will start breaking left and right. That is not the problem at hand, however.

If you are exposing this to COM and using your class, the make sure you're releasing the object by calling IUnknown::Release in your native code. If not, the DLL is not unloaded and will be in use (soft-locked).

And once again, you should not sub-class the Window how you're currently doing it. This is most likely causing the problem. Simply override WndProc (just like you'd do on any other Windows Forms control (since most encapsulates native Common Controls) when a particular message isn't handled in a .NET-friendly manner. Catch the WM_PAINT message like in the following and handle that however is necessary:
protected override void WndProc(ref Message m)
{
  if (m.Msg == WM_PAINT)
  {
    // Paint yourself silly.
  }
  base.WndProc(ref m);
}
I very much doubt the Framework is expecting you to sub-class the Windows by re-assigning its window procedure. Just don't. You're performing extra work - and putting extra work on the CPU for marshaling - when it's not necessary. The window procedure is already encapsulated and exposed for you: NativeWindow.WndProc.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
stefan houtz27-Dec-04 6:01
stefan houtz27-Dec-04 6:01 
GeneralDataTable.ColumnChanged doesn't rais an event after ReadXml() Pin
Dogan Gunay20-Dec-04 0:05
Dogan Gunay20-Dec-04 0:05 
Generalhelp request..., Pin
50519-Dec-04 23:56
50519-Dec-04 23:56 
GeneralRe: help request..., Pin
Colin Angus Mackay20-Dec-04 1:46
Colin Angus Mackay20-Dec-04 1:46 
Generalpropagating datagrid changes in the source database tables Pin
Rashid_Mehmood19-Dec-04 23:24
Rashid_Mehmood19-Dec-04 23:24 
GeneralRe: propagating datagrid changes in the source database tables Pin
Skynyrd20-Dec-04 0:13
Skynyrd20-Dec-04 0:13 
GeneralRe: propagating datagrid changes in the source database tables Pin
siddlingaSwami20-Dec-04 2:03
susssiddlingaSwami20-Dec-04 2:03 
GeneralReal Time Display Sound WaveForm While Acquiring Pin
Siew Eng19-Dec-04 19:22
Siew Eng19-Dec-04 19:22 
GeneralLate Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 14:53
Chris Richner19-Dec-04 14:53 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Daniel Turini19-Dec-04 17:13
Daniel Turini19-Dec-04 17:13 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 21:51
Chris Richner19-Dec-04 21:51 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 22:25
Chris Richner19-Dec-04 22:25 
Generalhashtable in extended properties Pin
esakal19-Dec-04 14:19
esakal19-Dec-04 14:19 
Generalhashtable in extended properties Pin
esakal19-Dec-04 14:09
esakal19-Dec-04 14:09 
Generaldynamically create multiple controls Pin
fredza19-Dec-04 8:04
fredza19-Dec-04 8:04 
GeneralRe: dynamically create multiple controls Pin
Heath Stewart20-Dec-04 6:28
protectorHeath Stewart20-Dec-04 6:28 
Generalproblem with extender provider Pin
esakal19-Dec-04 4:01
esakal19-Dec-04 4:01 

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.