Click here to Skip to main content
15,914,500 members
Home / Discussions / C#
   

C#

 
GeneralProblem getting array out of arraylist Pin
sciamachy20-Dec-04 6:20
sciamachy20-Dec-04 6:20 
GeneralRe: Problem getting array out of arraylist Pin
Heath Stewart20-Dec-04 6:33
protectorHeath Stewart20-Dec-04 6:33 
GeneralRe: Problem getting array out of arraylist Pin
CoolDadTx21-Dec-04 4:11
CoolDadTx21-Dec-04 4:11 
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 
Thanks for your reaction. Maybe I do not understand your proposal to solve this problem, as said I am just a C# beginner. You can find my changed code hereunder. If I try to rebuild it I get compiler errors:

'WindowsApplication1.GenericWindow.Dispose(bool)': no suitable method found to override
The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:

GenericWindow --- The base class 'System.Windows.Forms.NativeWindow' cannot be designed.

Any idea?


using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsApplication1
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class GenericWindow : NativeWindow, IDisposable
{
private delegate Int32 EnumChildProc(IntPtr hWnd, IntPtr lParam);
private const int GWL_WNDPROC = -4;
private const int WM_PAINT = 0x000F;
private IntPtr oldWndProc = IntPtr.Zero;
private Win32WndProc newWndProc = null;
private int hIcon;
private int XPos;
private int YPos;

#region Imported User32.DLL functions

[DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern int GetDC(int hWnd);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ReleaseDC(int hWnd,int hDc);
[DllImport("User32.dll")]
private static extern int DestroyIcon(int hIcon);
[DllImport("user32.dll")]
public static extern int DrawIcon(int hdc, int x,int y, int hIcon);
[DllImport("user32.dll", EntryPoint="CallWindowProc")]
private static extern int CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
public static extern int ExtractIcon(int hInst, string lpszExeFileName, int nIconIndex);
[DllImport("user32.dll")]
private static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, Win32WndProc newProc);
[DllImport("user32.dll")]
private static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr newProc);
[DllImport("user32.dll")]
private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);

#endregion

// A delegate that matches Win32 WNDPROC:
private delegate int Win32WndProc(IntPtr hWnd, int Msg, int wParam, int lParam);

public GenericWindow()
{

}

~GenericWindow()
{ MessageBox.Show("destr");
Dispose(false);
}

void IDisposable.Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
// Dispose managed resources
}
// Dispose unmanaged resources. Ex: NativeWindow.DestroyHandle
this.DestroyHandle();
}

public void NotifyWindow(int windowHandle)
{
this.AssignHandle((IntPtr)windowHandle);
oldWndProc = GetWindowLong((IntPtr)windowHandle,GWL_WNDPROC);
newWndProc = new Win32WndProc(MyWndProc);
SetWindowLong((IntPtr)windowHandle, GWL_WNDPROC,newWndProc);
PaintExtras(1,1);
}
private int MyWndProc(IntPtr hWnd, int Msg, int
wParam, int lParam)
{
int pHandle;
switch(Msg)
{
case WM_PAINT:
pHandle = CallWindowProc(oldWndProc, hWnd,Msg, wParam, lParam);
PaintExtras(XPos, YPos);
return pHandle;
default:
return CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
}
}


private void PaintExtras(int xPos, int yPos)
{
XPos = xPos;
YPos = yPos;
int hdc = GetDC(this.Handle.ToInt32());
if (hdc != 0)
{
hIcon = ExtractIcon(this.Handle.ToInt32(),"C:\\progress10\\wrk\\experim\\down.ico",0);
int ret = DrawIcon (hdc, xPos, yPos, hIcon);
ret = DestroyIcon (hIcon);
ret = ReleaseDC(this.Handle.ToInt32(),hdc);
}
}
}
}


regards,

Stefan.
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 
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 

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.