Hallo,
ich möchte eine Form an den Desktop andocken.
Wisst Ihr zufällig wie man das macht.
Ich habe bisscher eine Klasse genutzt die das unter WinXO macht, doch leider funktioniert es unter Vista überhaupt nicht. Wenn ich es unter Vista ausführe bekommen ich zwar keine Fehlermeldung aber die ganze Form ist nicht mehr sichtbar. Vielleicht wisst ihr ja woran es liegt.
Hier ist der Code:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36:
| [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr FindWindow([MarshalAs(UnmanagedType.LPTStr)] string lpClassName, [MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);
[DllImport("user32.dll")] public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")] public static extern IntPtr GetDC(UInt16 hwnd);
IntPtr ipDesktop; Form ParentForm;
public DockWindowIntoDesktop(Form senderForm) { ParentForm = senderForm; }
public void DockStart() { IntPtr hwndParent = FindWindow("ProgMan", null); SetParent(ParentForm.Handle, hwndParent); ipDesktop = GetDC(0); } public void DockStop() { IntPtr hwndParent = FindWindow("screenClass", null); SetParent(ParentForm.Handle, hwndParent); ipDesktop = GetDC(0); } |
Gruß
Staeker
Moderiert von
Christian S.: C#-Tags hinzugefügt