winapi stuct

    技术2022-05-11  123

    [Mono-patches] mcs/class/System.Windows.Forms/System.Windows.Forms ChangeLog,1.65,1.66 win32functions.cs,1.1,1.2 win32Structs.cs,1.1,1.2 Menu.cs,1.16,1.17 ScrollableControl.cs,1.8,1.9 NativeWindow.cs,1.9,1.10 Form.cs,1.14,1.15

    Dennis Hayes dennis@mono-cvs.ximian.com Sat, 23 Nov 2002 23:31:30 -0500

     

    Previous message: [Mono-patches] mcs/mcs ChangeLog,1.888,1.889 class.cs,1.305,1.306 ecore.cs,1.186,1.187 expression.cs,1.383,1.384 typemanager.cs,1.200,1.201 Next message: [Mono-patches] mcs/class/System.XML/System.Xml XmlImplementation.cs,1.6,1.7 ChangeLog,1.138,1.139 Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
    Update of /cvs/public/mcs/class/System.Windows.Forms/System.Windows.Forms In directory mono-cvs.ximian.com:/tmp/cvs-serv25563 Modified Files: ChangeLog win32functions.cs win32Structs.cs Menu.cs ScrollableControl.cs NativeWindow.cs Form.cs Log Message: 2002-11-23 DennisHayes <dennish@raytek.com> checked in for Francois-Denis Gonthier * win32functions.cs * win32Structs.cs * Menu.cs * ScrollableControl.cs * MenuItem.cs * NativeWindow.cs * Form.cs * move some more stuff from monostub to c# * converted a couple of files to unix style line end * some implmementation Index: ChangeLog =================================================================== RCS file: /cvs/public/mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- ChangeLog 23 Nov 2002 02:10:47 -0000 1.65 +++ ChangeLog 24 Nov 2002 04:31:26 -0000 1.66 @@ -1,3 +1,16 @@ + 2002-11-23 DennisHayes <dennish@raytek.com> + checked in for Francois-Denis Gonthier + + * win32functions.cs + * win32Structs.cs + * Menu.cs + * ScrollableControl.cs + * MenuItem.cs + * NativeWindow.cs + * Form.cs + * move some more stuff from monostub to c# + * converted a couple of files to unix style line end + * some implmementation 2002-11-17 DennisHayes <dennish@raytek.com> Index: win32functions.cs =================================================================== RCS file: /cvs/public/mcs/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- win32functions.cs 18 Nov 2002 04:44:37 -0000 1.1 +++ win32functions.cs 24 Nov 2002 04:31:26 -0000 1.2 @@ -27,566 +27,549 @@ * authorization from Carlos Harvey Perez. */ -using System; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Text; -using System.Diagnostics; - -//using UtilityLibrary.WinControls; - -//namespace UtilityLibrary.Win32 -namespace System.Windows.Forms{ - /// <summary> - /// Windows API Functions - /// </summary> - public class Win32 - { - #region Constructors - // No need to construct this object - #endregion - - #region Constans values - internal const string TOOLBARCLASSNAME = "ToolbarWindow32"; - internal const string REBARCLASSNAME = "ReBarWindow32"; - internal const string PROGRESSBARCLASSNAME = "msctls_progress32"; - internal const string SCROLLBAR = "SCROLLBAR"; - #endregion - - #region CallBacks - internal delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam); - internal delegate int CompareFunc(IntPtr param1, IntPtr param2, IntPtr sortParam); - internal delegate int WinProc(IntPtr hWnd, int message, int wParam, int lParam); - #endregion - - #region Kernel32.dll functions - [DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto)] - internal static extern int GetCurrentThreadId(); - [DllImport("kernel32.dll")] - internal static extern int GetDriveType(string rootPathName); - [DllImport("kernel32.dll")] - internal static extern int GetVolumeInformation(string drivePath, - StringBuilder volumeNameBuffer, - int driveNameBufferSize, - out int serialNumber, - out int maxFileNameLength, - out int fileSystemFlags, - StringBuilder systemNameBuffer, - int systemNameBufferSize); - [DllImport("kernel32.dll")] - internal static extern void OutputDebugString(string message); - #endregion - - #region Gdi32.dll functions - [DllImport("gdi32.dll")] - static internal extern bool StretchBlt(IntPtr hDCDest, int XOriginDest, int YOriginDest, int WidthDest, int HeightDest, - IntPtr hDCSrc, int XOriginScr, int YOriginSrc, int WidthScr, int HeightScr, PatBltTypes Rop); - [DllImport("gdi32.dll")] - static internal extern IntPtr CreateCompatibleDC(IntPtr hDC); - [DllImport("gdi32.dll")] - static internal extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int Width, int Heigth); - [DllImport("gdi32.dll")] - static internal extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); - [DllImport("gdi32.dll")] - static internal extern bool BitBlt(IntPtr hDCDest, int XOriginDest, int YOriginDest, int WidthDest, int HeightDest, - IntPtr hDCSrc, int XOriginScr, int YOriginSrc, PatBltTypes flags); - [DllImport("gdi32.dll")] - static internal extern IntPtr DeleteDC(IntPtr hDC); - [DllImport("gdi32.dll")] - static internal extern bool PatBlt(IntPtr hDC, int XLeft, int YLeft, int Width, int Height, int Rop); - [DllImport("gdi32.dll")] - static internal extern bool DeleteObject(IntPtr hObject); - [DllImport("gdi32.dll")] - static internal extern int GetPixel(IntPtr hDC, int XPos, int YPos); - [DllImport("gdi32.dll")] - static internal extern int SetMapMode(IntPtr hDC, int fnMapMode); - [DllImport("gdi32.dll")] - static internal extern int GetObjectType(IntPtr handle); - [DllImport("gdi32")] - internal static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO_FLAT bmi, - int iUsage, ref int ppvBits, IntPtr hSection, int dwOffset); - [DllImport("gdi32")] - internal static extern int GetDIBits(IntPtr hDC, IntPtr hbm, int StartScan, int ScanLines, int lpBits, BITMAPINFOHEADER bmi, int usage); - [DllImport("gdi32")] - internal static extern int GetDIBits(IntPtr hdc, IntPtr hbm, int StartScan, int ScanLines, int lpBits, ref BITMAPINFO_FLAT bmi, int usage); - [DllImport("gdi32")] - internal static extern IntPtr GetPaletteEntries(IntPtr hpal, int iStartIndex, int nEntries, byte[] lppe); - [DllImport("gdi32")] - internal static extern IntPtr GetSystemPaletteEntries(IntPtr hdc, int iStartIndex, int nEntries, byte[] lppe); - [DllImport("gdi32")] - internal static extern int SetDCBrushColor(IntPtr hdc, int crColor); - [DllImport("gdi32")] - internal static extern IntPtr CreateSolidBrush(int crColor); - [DllImport("gdi32")] - internal static extern int SetBkMode(IntPtr hDC, BackgroundMode mode); - [DllImport("gdi32")] - internal static extern int SetViewportOrgEx(IntPtr hdc, int x, int y, int param); - [DllImport("gdi32")] - internal static extern int SetTextColor(IntPtr hDC, int colorRef); - [DllImport("gdi32")] - internal static extern int SetStretchBltMode(IntPtr hDC, StrechModeFlags StrechMode); - [DllImport("gdi32")] - internal static extern int SetPixel(IntPtr hDC, int x, int y, int color); - [DllImport("gdi32")] - internal static extern IntPtr CreatePen(PenStyle penStyle, int width, int color); - [DllImport("gdi32")] - internal static extern int GetClipRgn(IntPtr hDC, ref IntPtr region); - [DllImport("gdi32")] - internal static extern IntPtr CreateRectRgn(int nLeftRect, int TopRect, int nRightRect, int nBottomRect); - [DllImport("gdi32")] - internal static extern int GetRgnBox(IntPtr hRegion, ref RECT rc); - #endregion - - #region Uxtheme.dll functions - [DllImport("uxtheme.dll")] - static public extern int SetWindowTheme(IntPtr hWnd, StringBuilder AppID, StringBuilder ClassID); - static public void DisableWindowsXPTheme(IntPtr hWnd) - { - // Disable using the Window XP Theme for the Window handle - // passed as a parameter - StringBuilder applicationName = new StringBuilder(" ", 1); - StringBuilder classIDs = new StringBuilder(" " , 1); - Win32.SetWindowTheme(hWnd, applicationName, classIDs); - } - #endregion - - #region User32.dll functions - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern IntPtr GetDesktopWindow(); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool ShowWindow(IntPtr hWnd, ShowWindowStyles State); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool SetForegroundWindow(IntPtr hWnd); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool OpenClipboard(IntPtr hWndNewOwner); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool CloseClipboard(); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool EmptyClipboard(); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern IntPtr SetClipboardData( int Format, IntPtr hData); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool GetMenuItemRect(IntPtr hWnd, IntPtr hMenu, int Item, ref RECT rc); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern int SendMessage(IntPtr hWnd, Msg msg, int wParam, int lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref RECT lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref POINT lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, ToolBarMessages msg, int wParam, ref TBBUTTON lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, ToolBarMessages msg, int wParam, ref TBBUTTONINFO lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern int SendMessage(IntPtr hWnd, RebarMessages msg, int wParam, ref REBARBANDINFO lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TVITEM lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TVINSERTSTRUCT lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TVSORTCB lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern int SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TVHITTESTINFO hti); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, ListViewMessages msg, int wParam, ref LVITEM lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, HeaderControlMessages msg, int wParam, ref HDITEM lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern void SendMessage(IntPtr hWnd, HeaderControlMessages msg, int wParam, ref HD_HITTESTINFO hti); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern int SendMessage(IntPtr hWnd, HeaderControlMessages msg, int wParam, int lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr PostMessage(IntPtr hWnd, int msg, int wParam, int lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr PostMessage(IntPtr hWnd, Msg msg, int wParam, int lParam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr SetWindowsHookEx(WindowsHookCodes hookid, HookProc pfnhook, IntPtr hinst, int threadid); - [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] - internal static extern bool UnhookWindowsHookEx(IntPtr hhook); - [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] - internal static extern IntPtr CallNextHookEx(IntPtr hhook, int code, IntPtr wparam, IntPtr lparam); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal extern static int DrawText(IntPtr hdc, string lpString, int nCount, ref RECT lpRect, DrawTextFormatFlags flags); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal extern static IntPtr GetDlgItem(IntPtr hDlg, int nControlID); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal extern static int InvalidateRect(IntPtr hWnd, ref RECT rc, int bErase); - [DllImport("user32.dll", CharSet=CharSet.Auto)] - internal extern static int InvalidateRect(IntPtr hWnd, IntPtr rc, int bErase); - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool WaitMessage(); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool PeekMessage(ref MESSAGE msg, int hWnd, int wFilterMin, int wFilterMax, PeekMessageFlags flags); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool GetMessage(ref MESSAGE msg, int hWnd, int wFilterMin, int wFilterMax); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool TranslateMessage(ref MESSAGE msg); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool DispatchMessage(ref MESSAGE msg); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr LoadCursor(IntPtr hInstance, CursorType cursor); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr SetCursor(IntPtr hCursor); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT ps); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, - IntPtr hdcSrc, ref POINT pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, UpdateLayeredWindowFlags dwFlags); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool ClientToScreen(IntPtr hWnd, ref POINT pt); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool TrackMouseEvent(ref TRACKMOUSEEVENTS tme); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool redraw); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern short GetKeyState(int virtKey); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern int GetClassName(IntPtr hWnd, StringBuilder ClassName, int nMaxCount); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern int SetWindowLong(IntPtr hWnd, GetWindowLongFlag flag, int dwNewLong); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern int SetWindowLong(IntPtr hWnd, GetWindowLongFlag flag, WinProc winProc); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hRegion, int flags); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr GetWindowDC(IntPtr hWnd); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern int FillRect(IntPtr hDC, ref RECT rect, IntPtr hBrush); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern int SetWindowText(IntPtr hWnd, string text); - - [DllImport("User32.dll", CharSet=CharSet.Auto)] - internal static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int maxCount); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int GetSystemMetrics(SystemMetricsCodes code); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int SetScrollInfo(IntPtr hwnd, int bar, ref SCROLLINFO si, int fRedraw); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int ShowScrollBar(IntPtr hWnd, int bar, int show); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int EnableScrollBar(IntPtr hWnd, int flags, int arrows); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int BringWindowToTop(IntPtr hWnd); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int GetScrollInfo(IntPtr hwnd, int bar, ref SCROLLINFO si); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int ScrollWindowEx(IntPtr hWnd, int dx, int dy, - ref RECT rcScroll, ref RECT rcClip, IntPtr UpdateRegion, ref RECT rcInvalidated, int flags); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool IsWindow(IntPtr hWnd); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int LockWindowUpdate(IntPtr hWnd); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool ValidateRect(IntPtr hWnd, ref RECT rcInvalidated); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern bool ValidateRect(IntPtr hWnd, IntPtr rc); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int GetScrollBarInfo(IntPtr hWnd, SystemObject id, ref SCROLLBARINFO sbi); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern IntPtr GetWindowLong(IntPtr hWnd, GetWindowLongFlag flag); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int SetProp(IntPtr hWnd, IntPtr atom, IntPtr hData); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int CallWindowProc(IntPtr hOldProc, IntPtr hWnd, int message, int wParam, int lParam); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int EndMenu(); - - [DllImport("user32.dll", CharSet=CharSet.Auto)] - static internal extern int DefWindowProc(IntPtr hWnd, int message, int wParam, int lParam); - - #endregion - - #region Shell32.dll functions - - [DllImport("Shell32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr SHGetFileInfo(string drivePath, int fileAttributes, - out SHFILEINFO fileInfo, int countBytesFileInfo, ShellFileInfoFlags flags); - - [DllImport("Shell32.dll", CharSet=CharSet.Auto)] - internal static extern IntPtr SHGetFileInfo(IntPtr idl, int fileAttributes, - out SHFILEINFO fileInfo, int countBytesFileInfo, ShellFileInfoFlags flags); - - [DllImport("Shell32.dll", CharSet=CharSet.Auto)] - internal static extern int SHGetSpecialFolderLocation(IntPtr hwndOwner, ShellSpecialFolder folder, out IntPtr idl); - - [DllImport("Shell32.dll", CharSet=CharSet.Auto)] - internal static extern int SHGetMalloc(out IMalloc alloc); - - [DllImport("Shell32.dll", CharSet=CharSet.Auto)] - internal static extern int SHGetDesktopFolder(out IShellFolder folder); - - [DllImport("Shell32.dll", CharSet=CharSet.Auto)] - internal static extern int SHGetPathFromIDList(IntPtr idl, StringBuilder path); - - internal static void SHFreeMalloc(IntPtr handle) - { - IMalloc alloc = null; - try - { - Win32.SHGetMalloc(out alloc); - Debug.Assert(alloc != null); - alloc.Free(handle); - // Free allocator itself - IUnknown iUnknown = (IUnknown)alloc; - iUnknown.Release(); - } - catch (Exception e) - { - // In case the Garbage collector is trying to free - // this memory from its own thread - Debug.WriteLine(e.Message); - } - } - - #endregion - - #region Common Controls functions - - [DllImport("comctl32.dll")] - internal static extern bool InitCommonControlsEx(INITCOMMONCONTROLSEX icc); - - [DllImport("comctl32.dll")] - internal static extern bool InitCommonControls(); - - [DllImport("comctl32.dll", EntryPoint="DllGetVersion")] - internal extern static int GetCommonControlDLLVersion(ref DLLVERSIONINFO dvi); - - [DllImport("comctl32.dll")] - internal static extern IntPtr ImageList_Create(int width, int height, int flags, int count, int grow); - - [DllImport("comctl32.dll")] - internal static extern bool ImageList_Destroy(IntPtr handle); - - [DllImport("comctl32.dll")] - internal static extern int ImageList_Add(IntPtr imageHandle, IntPtr hBitmap, IntPtr hMask); - - [DllImport("comctl32.dll")] - internal static extern bool ImageList_Remove(IntPtr imageHandle, int index); - - [DllImport("comctl32.dll")] - internal static extern bool ImageList_BeginDrag(IntPtr imageHandle, int imageIndex, int xHotSpot, int yHotSpot); - - [DllImport("comctl32.dll")] - internal static extern bool ImageList_DragEnter(IntPtr hWndLock, int x, int y); - - [DllImport("comctl32.dll")] - internal static extern bool ImageList_DragMove(int x, int y); - - [DllImport("comctl32.dll")] - internal static extern bool ImageList_DragLeave(IntPtr hWndLock); - - [DllImport("comctl32.dll")] - internal static extern void ImageList_EndDrag(); - - [DllImport("comctl32.dll")] - internal static extern bool ImageList_Draw(IntPtr hImageList, int imageIndex, - IntPtr hDCDest, int x, int y, ImageListDrawFlags flags); - - [DllImport("comctl32.dll")] - internal static extern int ImageList_DrawEx( - IntPtr hImageList, int imageIndex, IntPtr hDCDest, int x, int y, int dx, int dy, - uint backColor, uint foregColor, ImageListDrawFlags flags); - - [DllImport("comctl32.dll")] - internal static extern int ImageList_DragShowNolock(int show); - - [DllImport("comctl32.dll")] - internal static extern int ImageList_AddMasked(IntPtr hImageList, IntPtr hBitmap, int crMask); - - [DllImport("comctl32.dll")] - internal static extern int ImageList_SetDragCursorImage(IntPtr himlDrag, int iDrag, int dxHotspot, int dyHotspot); - - internal static int ImageList_DrawEx(IntPtr hImageList, int imageIndex, IntPtr hDCDest, int x, int y, int dx, int dy, - ImageListDrawColor backColor, ImageListDrawColor foreColor, ImageListDrawFlags flags) - { - uint bColor = (uint)ImageListDrawColors.CLR_NONE; - if ( backColor == ImageListDrawColor.Default ) - bColor = (uint)ImageListDrawColors.CLR_DEFAULT; - - uint fColor = (uint)ImageListDrawColors.CLR_NONE; - if ( foreColor == ImageListDrawColor.Default ) - fColor = (uint)ImageListDrawColors.CLR_DEFAULT; - - // Call actual function - return ImageList_DrawEx(hImageList, imageIndex, hDCDest, x, y, dx, dy, bColor, fColor, flags); - } - - - static internal bool IsCommonCtrl6() - { - DLLVERSIONINFO dllVersion = new DLLVERSIONINFO(); - // We are assummng here that anything greater or equal than 6 - // will have the new XP theme drawing enable - dllVersion.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO)); - Win32.GetCommonControlDLLVersion(ref dllVersion); - return (dllVersion.dwMajorVersion >= 6); - } - - #endregion - - #region Win32 Macro-Like helpers - internal static int X_LPARAM(int lParam) - { - return (lParam & 0xffff); - } - - internal static int Y_LPARAM(int lParam) - { - return (lParam >> 16); - } - - internal static Point GetPointFromLPARAM(int lParam) - { - return new Point(X_LPARAM(lParam), Y_LPARAM(lParam)); - } - - internal static int LOW_ORDER(int param) - { - return (param & 0xffff); - } - - internal static int HIGH_ORDER(int param) - { - return (param >> 16); - } - - internal static int INDEXTOOVERLAYMASK(int index) - { - return (int)((uint)index << 8); - } - - internal static int OVERLAYMASKTOINDEX(int index) - { - return (int)((uint)index >> 8); - } - - internal static int INDEXTOSTATEIMAGEMASK(int i) - { - return (int)((uint)i << 12); - } - - internal static int STATEIMAGEMASKTOINDEX(int i) - { - return (int)((uint)i >> 12); - } - - internal static short HRESULT_CODE(int hr) - { - return (short)(hr & 0xFFFF); - } - - internal static bool SUCCEEDED(int status) - { - return (status >= 0); - } - - internal static bool FAILED(int status) - { - return (status < 0); - } - - internal static int MAKEINTRESOURCE(int res) - { - return 0x0000FFFF & res; - } - #endregion - - - #region Mono win32 Fuinctions - // helper function for calling RegisterClass - internal delegate IntPtr WndProc (IntPtr hwnd, int msg, - IntPtr wParam, IntPtr lParam); +using System; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Text; +using System.Diagnostics; - // +//using UtilityLibrary.WinControls; - [DllImport ("monostub.exe", +//namespace UtilityLibrary.Win32 +namespace System.Windows.Forms{ + /// <summary> + /// Windows API Functions + /// </summary> + public class Win32 + { + #region Constructors + // No need to construct this object + #endregion + + #region Constans values + internal const string TOOLBARCLASSNAME = "ToolbarWindow32"; + internal const string REBARCLASSNAME = "ReBarWindow32"; + internal const string PROGRESSBARCLASSNAME = "msctls_progress32"; + internal const string SCROLLBAR = "SCROLLBAR"; + #endregion + + #region CallBacks + internal delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam); + internal delegate int CompareFunc(IntPtr param1, IntPtr param2, IntPtr sortParam); + internal delegate int WinProc(IntPtr hWnd, int message, int wParam, int lParam); + #endregion + + #region Kernel32.dll functions + [DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto)] + internal static extern int GetCurrentThreadId(); + [DllImport("kernel32.dll")] + internal static extern int GetDriveType(string rootPathName); + [DllImport("kernel32.dll")] + internal static extern int GetVolumeInformation(string drivePath, + StringBuilder volumeNameBuffer, + int driveNameBufferSize, + out int serialNumber, + out int maxFileNameLength, + out int fileSystemFlags, + StringBuilder systemNameBuffer, + int systemNameBufferSize); + [DllImport("kernel32.dll")] + internal static extern void OutputDebugString(string message); + #endregion + + #region Gdi32.dll functions + [DllImport("gdi32.dll")] + static internal extern bool StretchBlt(IntPtr hDCDest, int XOriginDest, int YOriginDest, int WidthDest, int HeightDest, + IntPtr hDCSrc, int XOriginScr, int YOriginSrc, int WidthScr, int HeightScr, PatBltTypes Rop); + [DllImport("gdi32.dll")] + static internal extern IntPtr CreateCompatibleDC(IntPtr hDC); + [DllImport("gdi32.dll")] + static internal extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int Width, int Heigth); + [DllImport("gdi32.dll")] + static internal extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); + [DllImport("gdi32.dll")] + static internal extern bool BitBlt(IntPtr hDCDest, int XOriginDest, int YOriginDest, int WidthDest, int HeightDest, + IntPtr hDCSrc, int XOriginScr, int YOriginSrc, PatBltTypes flags); + [DllImport("gdi32.dll")] + static internal extern IntPtr DeleteDC(IntPtr hDC); + [DllImport("gdi32.dll")] + static internal extern bool PatBlt(IntPtr hDC, int XLeft, int YLeft, int Width, int Height, int Rop); + [DllImport("gdi32.dll")] + static internal extern bool DeleteObject(IntPtr hObject); + [DllImport("gdi32.dll")] + static internal extern int GetPixel(IntPtr hDC, int XPos, int YPos); + [DllImport("gdi32.dll")] + static internal extern int SetMapMode(IntPtr hDC, int fnMapMode); + [DllImport("gdi32.dll")] + static internal extern int GetObjectType(IntPtr handle); + [DllImport("gdi32")] + internal static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO_FLAT bmi, + int iUsage, ref int ppvBits, IntPtr hSection, int dwOffset); + [DllImport("gdi32")] + internal static extern int GetDIBits(IntPtr hDC, IntPtr hbm, int StartScan, int ScanLines, int lpBits, BITMAPINFOHEADER bmi, int usage); + [DllImport("gdi32")] + internal static extern int GetDIBits(IntPtr hdc, IntPtr hbm, int StartScan, int ScanLines, int lpBits, ref BITMAPINFO_FLAT bmi, int usage); + [DllImport("gdi32")] + internal static extern IntPtr GetPaletteEntries(IntPtr hpal, int iStartIndex, int nEntries, byte[] lppe); + [DllImport("gdi32")] + internal static extern IntPtr GetSystemPaletteEntries(IntPtr hdc, int iStartIndex, int nEntries, byte[] lppe); + [DllImport("gdi32")] + internal static extern int SetDCBrushColor(IntPtr hdc, int crColor); + [DllImport("gdi32")] + internal static extern IntPtr CreateSolidBrush(int crColor); + [DllImport("gdi32")] + internal static extern int SetBkMode(IntPtr hDC, BackgroundMode mode); + [DllImport("gdi32")] + internal static extern int SetViewportOrgEx(IntPtr hdc, int x, int y, int param); + [DllImport("gdi32")] + internal static extern int SetTextColor(IntPtr hDC, int colorRef); + [DllImport("gdi32")] + internal static extern int SetStretchBltMode(IntPtr hDC, StrechModeFlags StrechMode); + [DllImport("gdi32")] + internal static extern int SetPixel(IntPtr hDC, int x, int y, int color); + [DllImport("gdi32")] + internal static extern IntPtr CreatePen(PenStyle penStyle, int width, int color); + [DllImport("gdi32")] + internal static extern int GetClipRgn(IntPtr hDC, ref IntPtr region); + [DllImport("gdi32")] + internal static extern IntPtr CreateRectRgn(int nLeftRect, int TopRect, int nRightRect, int nBottomRect); + [DllImport("gdi32")] + internal static extern int GetRgnBox(IntPtr hRegion, ref RECT rc); + #endregion + + #region Uxtheme.dll functions + [DllImport("uxtheme.dll")] + static public extern int SetWindowTheme(IntPtr hWnd, StringBuilder AppID, StringBuilder ClassID); + static public void DisableWindowsXPTheme(IntPtr hWnd) + { + // Disable using the Window XP Theme for the Window handle + // passed as a parameter + StringBuilder applicationName = new StringBuilder(" ", 1); + StringBuilder classIDs = new StringBuilder(" " , 1); + Win32.SetWindowTheme(hWnd, applicationName, classIDs); + } + #endregion + + #region User32.dll functions + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern IntPtr GetDesktopWindow(); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool ShowWindow(IntPtr hWnd, ShowWindowStyles State); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool SetForegroundWindow(IntPtr hWnd); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool OpenClipboard(IntPtr hWndNewOwner); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool CloseClipboard(); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool EmptyClipboard(); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern IntPtr SetClipboardData( int Format, IntPtr hData); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool GetMenuItemRect(IntPtr hWnd, IntPtr hMenu, int Item, ref RECT rc); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern int SendMessage(IntPtr hWnd, Msg msg, int wParam, int lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref RECT lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref POINT lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, ToolBarMessages msg, int wParam, ref TBBUTTON lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, ToolBarMessages msg, int wParam, ref TBBUTTONINFO lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern int SendMessage(IntPtr hWnd, RebarMessages msg, int wParam, ref REBARBANDINFO lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TVITEM lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TVINSERTSTRUCT lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TVSORTCB lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern int SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TVHITTESTINFO hti); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, ListViewMessages msg, int wParam, ref LVITEM lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, HeaderControlMessages msg, int wParam, ref HDITEM lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern void SendMessage(IntPtr hWnd, HeaderControlMessages msg, int wParam, ref HD_HITTESTINFO hti); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern int SendMessage(IntPtr hWnd, HeaderControlMessages msg, int wParam, int lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr PostMessage(IntPtr hWnd, int msg, int wParam, int lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr PostMessage(IntPtr hWnd, Msg msg, int wParam, int lParam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr SetWindowsHookEx(WindowsHookCodes hookid, HookProc pfnhook, IntPtr hinst, int threadid); + [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] + internal static extern bool UnhookWindowsHookEx(IntPtr hhook); + [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] + internal static extern IntPtr CallNextHookEx(IntPtr hhook, int code, IntPtr wparam, IntPtr lparam); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal extern static int DrawText(IntPtr hdc, string lpString, int nCount, ref RECT lpRect, DrawTextFormatFlags flags); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal extern static IntPtr GetDlgItem(IntPtr hDlg, int nControlID); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal extern static int InvalidateRect(IntPtr hWnd, ref RECT rc, int bErase); + [DllImport("user32.dll", CharSet=CharSet.Auto)] + internal extern static int InvalidateRect(IntPtr hWnd, IntPtr rc, int bErase); + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool WaitMessage(); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool PeekMessage(ref MESSAGE msg, int hWnd, int wFilterMin, int wFilterMax, PeekMessageFlags flags); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool GetMessage(ref MESSAGE msg, int hWnd, int wFilterMin, int wFilterMax); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool TranslateMessage(ref MESSAGE msg); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool DispatchMessage(ref MESSAGE msg); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr LoadCursor(IntPtr hInstance, CursorType cursor); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr SetCursor(IntPtr hCursor); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT ps); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, + IntPtr hdcSrc, ref POINT pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, UpdateLayeredWindowFlags dwFlags); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool ClientToScreen(IntPtr hWnd, ref POINT pt); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool TrackMouseEvent(ref TRACKMOUSEEVENTS tme); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool redraw); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern short GetKeyState(int virtKey); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern int GetClassName(IntPtr hWnd, StringBuilder ClassName, int nMaxCount); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern int SetWindowLong(IntPtr hWnd, GetWindowLongFlag flag, int dwNewLong); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern int SetWindowLong(IntPtr hWnd, GetWindowLongFlag flag, WinProc winProc); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hRegion, int flags); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr GetWindowDC(IntPtr hWnd); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern int FillRect(IntPtr hDC, ref RECT rect, IntPtr hBrush); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern int SetWindowText(IntPtr hWnd, string text); + + [DllImport("User32.dll", CharSet=CharSet.Auto)] + internal static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int maxCount); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int GetSystemMetrics(SystemMetricsCodes code); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int SetScrollInfo(IntPtr hwnd, int bar, ref SCROLLINFO si, int fRedraw); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int ShowScrollBar(IntPtr hWnd, int bar, int show); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int EnableScrollBar(IntPtr hWnd, int flags, int arrows); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int BringWindowToTop(IntPtr hWnd); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int GetScrollInfo(IntPtr hwnd, int bar, ref SCROLLINFO si); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int ScrollWindowEx(IntPtr hWnd, int dx, int dy, + ref RECT rcScroll, ref RECT rcClip, IntPtr UpdateRegion, ref RECT rcInvalidated, int flags); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool IsWindow(IntPtr hWnd); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int LockWindowUpdate(IntPtr hWnd); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool ValidateRect(IntPtr hWnd, ref RECT rcInvalidated); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern bool ValidateRect(IntPtr hWnd, IntPtr rc); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int GetScrollBarInfo(IntPtr hWnd, SystemObject id, ref SCROLLBARINFO sbi); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern IntPtr GetWindowLong(IntPtr hWnd, GetWindowLongFlag flag); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int SetProp(IntPtr hWnd, IntPtr atom, IntPtr hData); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int CallWindowProc(IntPtr hOldProc, IntPtr hWnd, int message, int wParam, int lParam); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int EndMenu(); + + [DllImport("user32.dll", CharSet=CharSet.Auto)] + static internal extern int DefWindowProc(IntPtr hWnd, int message, int wParam, int lParam); + + #endregion + + #region Shell32.dll functions + + [DllImport("Shell32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr SHGetFileInfo(string drivePath, int fileAttributes, + out SHFILEINFO fileInfo, int countBytesFileInfo, ShellFileInfoFlags flags); + + [DllImport("Shell32.dll", CharSet=CharSet.Auto)] + internal static extern IntPtr SHGetFileInfo(IntPtr idl, int fileAttributes, + out SHFILEINFO fileInfo, int countBytesFileInfo, ShellFileInfoFlags flags); + + [DllImport("Shell32.dll", CharSet=CharSet.Auto)] + internal static extern int SHGetSpecialFolderLocation(IntPtr hwndOwner, ShellSpecialFolder folder, out IntPtr idl); + + [DllImport("Shell32.dll", CharSet=CharSet.Auto)] + internal static extern int SHGetMalloc(out IMalloc alloc); + + [DllImport("Shell32.dll", CharSet=CharSet.Auto)] + internal static extern int SHGetDesktopFolder(out IShellFolder folder); + + [DllImport("Shell32.dll", CharSet=CharSet.Auto)] + internal static extern int SHGetPathFromIDList(IntPtr idl, StringBuilder path); + + internal static void SHFreeMalloc(IntPtr handle) + { + IMalloc alloc = null; + try + { + Win32.SHGetMalloc(out alloc); + Debug.Assert(alloc != null); + alloc.Free(handle); + // Free allocator itself + IUnknown iUnknown = (IUnknown)alloc; + iUnknown.Release(); + } + catch (Exception e) + { + // In case the Garbage collector is trying to free + // this memory from its own thread + Debug.WriteLine(e.Message); + } + } + + #endregion + + #region Common Controls functions + + [DllImport("comctl32.dll")] + internal static extern bool InitCommonControlsEx(INITCOMMONCONTROLSEX icc); + + [DllImport("comctl32.dll")] + internal static extern bool InitCommonControls(); + + [DllImport("comctl32.dll", EntryPoint="DllGetVersion")] + internal extern static int GetCommonControlDLLVersion(ref DLLVERSIONINFO dvi); + + [DllImport("comctl32.dll")] + internal static extern IntPtr ImageList_Create(int width, int height, int flags, int count, int grow); + + [DllImport("comctl32.dll")] + internal static extern bool ImageList_Destroy(IntPtr handle); + + [DllImport("comctl32.dll")] + internal static extern int ImageList_Add(IntPtr imageHandle, IntPtr hBitmap, IntPtr hMask); + + [DllImport("comctl32.dll")] + internal static extern bool ImageList_Remove(IntPtr imageHandle, int index); + + [DllImport("comctl32.dll")] + internal static extern bool ImageList_BeginDrag(IntPtr imageHandle, int imageIndex, int xHotSpot, int yHotSpot); + + [DllImport("comctl32.dll")] + internal static extern bool ImageList_DragEnter(IntPtr hWndLock, int x, int y); + + [DllImport("comctl32.dll")] + internal static extern bool ImageList_DragMove(int x, int y); + + [DllImport("comctl32.dll")] + internal static extern bool ImageList_DragLeave(IntPtr hWndLock); + + [DllImport("comctl32.dll")] + internal static extern void ImageList_EndDrag(); + + [DllImport("comctl32.dll")] + internal static extern bool ImageList_Draw(IntPtr hImageList, int imageIndex, + IntPtr hDCDest, int x, int y, ImageListDrawFlags flags); + + [DllImport("comctl32.dll")] + internal static extern int ImageList_DrawEx( + IntPtr hImageList, int imageIndex, IntPtr hDCDest, int x, int y, int dx, int dy, + uint backColor, uint foregColor, ImageListDrawFlags flags); + + [DllImport("comctl32.dll")] + internal static extern int ImageList_DragShowNolock(int show); + + [DllImport("comctl32.dll")] + internal static extern int ImageList_AddMasked(IntPtr hImageList, IntPtr hBitmap, int crMask); + + [DllImport("comctl32.dll")] + internal static extern int ImageList_SetDragCursorImage(IntPtr himlDrag, int iDrag, int dxHotspot, int dyHotspot); + + internal static int ImageList_DrawEx(IntPtr hImageList, int imageIndex, IntPtr hDCDest, int x, int y, int dx, int dy, + ImageListDrawColor backColor, ImageListDrawColor foreColor, ImageListDrawFlags flags) + { + uint bColor = (uint)ImageListDrawColors.CLR_NONE; + if ( backColor == ImageListDrawColor.Default ) + bColor = (uint)ImageListDrawColors.CLR_DEFAULT; + + uint fColor = (uint)ImageListDrawColors.CLR_NONE; + if ( foreColor == ImageListDrawColor.Default ) + fColor = (uint)ImageListDrawColors.CLR_DEFAULT; + + // Call actual function + return ImageList_DrawEx(hImageList, imageIndex, hDCDest, x, y, dx, dy, bColor, fColor, flags); + } + + + static internal bool IsCommonCtrl6() + { + DLLVERSIONINFO dllVersion = new DLLVERSIONINFO(); + // We are assummng here that anything greater or equal than 6 + // will have the new XP theme drawing enable + dllVersion.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO)); + Win32.GetCommonControlDLLVersion(ref dllVersion); + return (dllVersion.dwMajorVersion >= 6); + } + + #endregion + + #region Win32 Macro-Like helpers + internal static int X_LPARAM(int lParam) + { + return (lParam & 0xffff); + } + + internal static int Y_LPARAM(int lParam) + { + return (lParam >> 16); + } + + internal static Point GetPointFromLPARAM(int lParam) + { + return new Point(X_LPARAM(lParam), Y_LPARAM(lParam)); + } + + internal static int LOW_ORDER(int param) + { + return (param & 0xffff); + } + + internal static int HIGH_ORDER(int param) + { + return (param >> 16); + } + + internal static int INDEXTOOVERLAYMASK(int index) + { + return (int)((uint)index << 8); + } + + internal static int OVERLAYMASKTOINDEX(int index) + { + return (int)((uint)index >> 8); + } + + internal static int INDEXTOSTATEIMAGEMASK(int i) + { + return (int)((uint)i << 12); + } + + internal static int STATEIMAGEMASKTOINDEX(int i) + { + return (int)((uint)i >> 12); + } + + internal static short HRESULT_CODE(int hr) + { + return (short)(hr & 0xFFFF); + } + + internal static bool SUCCEEDED(int status) + { + return (status >= 0); + } + + internal static bool FAILED(int status) + { + return (status < 0); + } + + internal static int MAKEINTRESOURCE(int res) + { + return 0x0000FFFF & res; + } + #endregion + + + #region Mono win32 Fuinctions + + internal delegate IntPtr WndProc (IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam); + + [DllImport ("user32.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)] - internal static extern int MonoRegisterClass ( - int style, WndProc lpfnWndProc, int cbClsExtra, - int cbWndExtra, IntPtr hInstance, IntPtr hIcon, - IntPtr hCursor, IntPtr hbrBackground, - string lpszMenuName, string lpszClassName); - // - // [DllImport ("user32.DLL", - // CallingConvention = CallingConvention.StdCall, - // CharSet = CharSet.Auto)] - // public static extern int RegisterClass ( - // int style, WndProc lpfnWndProc, int cbClsExtra, - // int cbWndExtra, IntPtr hInstance, IntPtr hIcon, - // IntPtr hCursor, IntPtr hbrBackground, - // string lpszMenuName, string lpszClassName); - + internal static extern uint RegisterClassA(ref WNDCLASS wndClass); #region Added by Dennis hayes 10-20-2002 //correct? [DllImport ("user32.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)] - internal static extern uint SendMessage( - IntPtr hWnd, uint Msg, + internal static extern uint SendMessage( + IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); [DllImport ("user32.dll", CallingConvention = CallingConvention.StdCall, - CharSet = CharSet.Auto)] - internal static extern bool GetWindowPlacement( - IntPtr hWnd, - ref WINDOWPLACEMENT lpwndpl // position data + CharSet = CharSet.Auto)] + internal static extern bool GetWindowPlacement( + IntPtr hWnd, + ref WINDOWPLACEMENT lpwndpl // position data ); #endregion @@ -792,10 +775,10 @@ CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)] internal static extern bool GetCursorPos (ref POINT lpPoint); - - #endregion - - - } - -} + + #endregion + + + } + +} Index: win32Structs.cs =================================================================== RCS file: /cvs/public/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Structs.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- win32Structs.cs 18 Nov 2002 04:44:37 -0000 1.1 +++ win32Structs.cs 24 Nov 2002 04:31:26 -0000 1.2 @@ -27,664 +27,664 @@ * authorization from Carlos Harvey Perez. */ - -using System; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Text; -using System.Diagnostics; - -//namespace UtilityLibrary.Win32 -namespace System.Windows.Forms -{ - - /// <summary> - /// Structures to interoperate with the Windows 32 API - /// </summary> - - #region SIZE - [StructLayout(LayoutKind.Sequential)] - internal struct SIZE - { - internal int cx; - internal int cy; - } - #endregion - - #region RECT - [StructLayout(LayoutKind.Sequential)] - internal struct RECT - { - internal int left; - internal int top; - internal int right; - internal int bottom; - } - #endregion - - #region INITCOMMONCONTROLSEX - [StructLayout(LayoutKind.Sequential, Pack=1)] - internal class INITCOMMONCONTROLSEX - { - internal int dwSize; - internal CommonControlInitFlags dwICC; - } - #endregion - - #region TBBUTTON - [StructLayout(LayoutKind.Sequential, Pack=1)] - internal struct TBBUTTON - { - internal int iBitmap; - internal int idCommand; - internal byte fsState; - internal byte fsStyle; - internal byte bReserved0; - internal byte bReserved1; - internal int dwData; - internal int iString; - } - #endregion - - #region POINT - [StructLayout(LayoutKind.Sequential)] - internal struct POINT - { - internal int x; - internal int y; - } - #endregion - - #region NMHDR - [StructLayout(LayoutKind.Sequential)] - internal struct NMHDR - { - internal IntPtr hwndFrom; - internal int idFrom; - internal int code; - } - #endregion - - #region TOOLTIPTEXTA - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] - internal struct TOOLTIPTEXTA - { - internal NMHDR hdr; - internal IntPtr lpszText; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)] - internal string szText; - internal IntPtr hinst; - internal ToolTipFlags flags; - } - #endregion - - #region TOOLTIPTEXT - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct TOOLTIPTEXT - { - internal NMHDR hdr; - internal IntPtr lpszText; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)] - internal string szText; - internal IntPtr hinst; - internal int uFlags; - } - #endregion - - #region NMCUSTOMDRAW - [StructLayout(LayoutKind.Sequential)] - internal struct NMCUSTOMDRAW - { - internal NMHDR hdr; - internal int dwDrawStage; - internal IntPtr hdc; - internal RECT rc; - internal int dwItemSpec; - internal int uItemState; - internal IntPtr lItemlParam; - } - #endregion - - #region NMTBCUSTOMDRAW - [StructLayout(LayoutKind.Sequential)] - internal struct NMTBCUSTOMDRAW - { - internal NMCUSTOMDRAW nmcd; - internal IntPtr hbrMonoDither; - internal IntPtr hbrLines; - internal IntPtr hpenLines; - internal int clrText; - internal int clrMark; - internal int clrTextHighlight; - internal int clrBtnFace; - internal int clrBtnHighlight; - internal int clrHighlightHotTrack; - internal RECT rcText; - internal int nStringBkMode; - internal int nHLStringBkMode; - } - #endregion - - #region NMLVCUSTOMDRAW - [StructLayout(LayoutKind.Sequential)] - internal struct NMLVCUSTOMDRAW - { - internal NMCUSTOMDRAW nmcd; - internal int clrText; - internal int clrTextBk; - internal int iSubItem; - } - #endregion - - #region TBBUTTONINFO - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct TBBUTTONINFO - { - internal int cbSize; - internal int dwMask; - internal int idCommand; - internal int iImage; - internal byte fsState; - internal byte fsStyle; - internal short cx; - internal IntPtr lParam; - internal IntPtr pszText; - internal int cchText; - } - #endregion - - #region REBARBANDINFO - [StructLayout(LayoutKind.Sequential)] - internal struct REBARBANDINFO - { - internal int cbSize; - internal RebarInfoMask fMask; - internal RebarStylesEx fStyle; - internal int clrFore; - internal int clrBack; - internal IntPtr lpText; - internal int cch; - internal int iImage; - internal IntPtr hwndChild; - internal int cxMinChild; - internal int cyMinChild; - internal int cx; - internal IntPtr hbmBack; - internal int wID; - internal int cyChild; - internal int cyMaxChild; - internal int cyIntegral; - internal int cxIdeal; - internal int lParam; - internal int cxHeader; - } - #endregion - - #region MOUSEHOOKSTRUCT - [StructLayout(LayoutKind.Sequential)] - internal struct MOUSEHOOKSTRUCT - { - internal POINT pt; - internal IntPtr hwnd; - internal int wHitTestCode; - internal IntPtr dwExtraInfo; - } - #endregion - - #region NMTOOLBAR - [StructLayout(LayoutKind.Sequential)] - internal struct NMTOOLBAR - { - internal NMHDR hdr; - internal int iItem; - internal TBBUTTON tbButton; - internal int cchText; - internal IntPtr pszText; - internal RECT rcButton; - } - #endregion - - #region NMREBARCHEVRON - [StructLayout(LayoutKind.Sequential)] - internal struct NMREBARCHEVRON - { - internal NMHDR hdr; - internal int uBand; - internal int wID; - internal int lParam; - internal RECT rc; - internal int lParamNM; - } - #endregion - - #region BITMAP - [StructLayout(LayoutKind.Sequential)] - internal struct BITMAP - { - internal long bmType; - internal long bmWidth; - internal long bmHeight; - internal long bmWidthBytes; - internal short bmPlanes; - internal short bmBitsPixel; - internal IntPtr bmBits; - } - #endregion - - #region BITMAPINFO_FLAT - [StructLayout(LayoutKind.Sequential)] - internal struct BITMAPINFO_FLAT - { - internal int bmiHeader_biSize; - internal int bmiHeader_biWidth; - internal int bmiHeader_biHeight; - internal short bmiHeader_biPlanes; - internal short bmiHeader_biBitCount; - internal int bmiHeader_biCompression; - internal int bmiHeader_biSizeImage; - internal int bmiHeader_biXPelsPerMeter; - internal int bmiHeader_biYPelsPerMeter; - internal int bmiHeader_biClrUsed; - internal int bmiHeader_biClrImportant; - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1024)] - internal byte[] bmiColors; - } - #endregion - - #region RGBQUAD - internal struct RGBQUAD - { - internal byte rgbBlue; - internal byte rgbGreen; - internal byte rgbRed; - internal byte rgbReserved; - } - #endregion - - #region BITMAPINFOHEADER - [StructLayout(LayoutKind.Sequential)] - internal class BITMAPINFOHEADER - { - internal int biSize = Marshal.SizeOf(typeof(BITMAPINFOHEADER)); - internal int biWidth; - internal int biHeight; - internal short biPlanes; - internal short biBitCount; - internal int biCompression; - internal int biSizeImage; - internal int biXPelsPerMeter; - internal int biYPelsPerMeter; - internal int biClrUsed; - internal int biClrImportant; - } - #endregion - - #region BITMAPINFO - [StructLayout(LayoutKind.Sequential)] - internal class BITMAPINFO - { - internal BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER(); - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1024)] - internal byte[] bmiColors; - } - #endregion - - #region PALETTEENTRY - [StructLayout(LayoutKind.Sequential)] - internal struct PALETTEENTRY - { - internal byte peRed; - internal byte peGreen; - internal byte peBlue; - internal byte peFlags; - } - #endregion - - #region MESSAGE - [StructLayout(LayoutKind.Sequential)] - internal struct MESSAGE - { - internal IntPtr hwnd; - internal int message; - internal IntPtr wParam; - internal IntPtr lParam; - internal int time; - internal int pt_x; - internal int pt_y; - } - #endregion - - #region HD_HITTESTINFO - [StructLayout(LayoutKind.Sequential)] - internal struct HD_HITTESTINFO - { - internal POINT pt; - internal HeaderControlHitTestFlags flags; - internal int iItem; - } - #endregion - - #region DLLVERSIONINFO - [StructLayout(LayoutKind.Sequential)] - internal struct DLLVERSIONINFO - { - internal int cbSize; - internal int dwMajorVersion; - internal int dwMinorVersion; - internal int dwBuildNumber; - internal int dwPlatformID; - } - #endregion - - #region PAINTSTRUCT - [StructLayout(LayoutKind.Sequential)] - internal struct PAINTSTRUCT - { - internal IntPtr hdc; - internal int fErase; - internal Rectangle rcPaint; - internal int fRestore; - internal int fIncUpdate; - internal int Reserved1; - internal int Reserved2; - internal int Reserved3; - internal int Reserved4; - internal int Reserved5; - internal int Reserved6; - internal int Reserved7; - internal int Reserved8; - } - #endregion - - #region BLENDFUNCTION - [StructLayout(LayoutKind.Sequential, Pack=1)] - internal struct BLENDFUNCTION - { - internal byte BlendOp; - internal byte BlendFlags; - internal byte SourceConstantAlpha; - internal byte AlphaFormat; - } - - #endregion - - #region TRACKMOUSEEVENTS - [StructLayout(LayoutKind.Sequential)] - internal struct TRACKMOUSEEVENTS - { - internal int cbSize; - internal TrackerEventFlags dwFlags; - internal IntPtr hWnd; - internal int dwHoverTime; - } - #endregion - - #region NMTVCUSTOMDRAW - [StructLayout(LayoutKind.Sequential)] - internal struct NMTVCUSTOMDRAW - { - internal NMCUSTOMDRAW nmcd; - internal int clrText; - internal int clrTextBk; - internal int iLevel; - } - #endregion - - #region TVITEM - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct TVITEM - { - internal int mask; - internal IntPtr hItem; - internal int state; - internal int stateMask; - internal IntPtr pszText; - internal int cchTextMax; - internal int iImage; - internal int iSelectedImage; - internal int cChildren; - internal IntPtr lParam; - } - #endregion - - #region LVITEM - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct LVITEM - { - internal ListViewItemFlags mask; - internal int iItem; - internal int iSubItem; - internal int state; - internal int stateMask; - internal IntPtr pszText; - internal int cchTextMax; - internal int iImage; - internal int lParam; - internal int iIndent; - } - #endregion - - #region HDITEM - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct HDITEM - { - internal HeaderItemFlags mask; - internal int cxy; - internal IntPtr pszText; - internal IntPtr hbm; - internal int cchTextMax; - internal int fmt; - internal int lParam; - internal int iImage; - internal int iOrder; - } - #endregion - - #region WINDOWPLACEMENT - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct WINDOWPLACEMENT - { - internal uint length; //Were int in original code - internal uint flags; // - internal uint showCmd; // - internal POINT ptMinPosition; - internal POINT ptMaxPosition; - internal RECT rcNormalPosition; - } - #endregion - - #region SCROLLINFO - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct SCROLLINFO - { - internal int cbSize; - internal int fMask; - internal int nMin; - internal int nMax; - internal int nPage; - internal int nPos; - internal int nTrackPos; - } - #endregion - - #region SHFILEINFO - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct SHFILEINFO - { - internal IntPtr hIcon; - internal int iIcon; - internal int dwAttributes; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)] - internal string szDisplayName; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)] - internal string szTypeName; - } - - #endregion - - #region SHITEMID - [StructLayout(LayoutKind.Sequential)] - internal struct SHITEMID - { - internal short cb; - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1)] - internal byte[] abID; - } - #endregion - - #region ITEMIDLIST - [StructLayout(LayoutKind.Sequential)] - internal struct ITEMIDLIST - { - internal SHITEMID mkid; - } - #endregion - - #region IID - [StructLayout(LayoutKind.Sequential)] - internal struct IID - { - int x; - short s1; - short s2; - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=8)] - byte[] chars; - } - #endregion - - #region REFIID - [StructLayout(LayoutKind.Sequential)] - internal struct REFIID - { - internal int x; - internal short s1; - internal short s2; - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=8)] - internal byte[] chars; - - internal REFIID(string guid) - { - // Needs to be a string of the form: - // "000214E6-0000-0000-c000-000000000046" - string[] data = guid.Split('-'); - Debug.Assert(data.Length == 5); - x = Convert.ToInt32(data[0], 16); - s1 = Convert.ToInt16(data[1], 16); - s2 = Convert.ToInt16(data[2], 16); - string bytesData = data[3] + data[4]; - chars = new byte[] { Convert.ToByte(bytesData.Substring(0,2), 16), Convert.ToByte(bytesData.Substring(2,2), 16), - Convert.ToByte(bytesData.Substring(4,2), 16), Convert.ToByte(bytesData.Substring(6,2), 16), - Convert.ToByte(bytesData.Substring(8,2), 16), Convert.ToByte(bytesData.Substring(10,2), 16), - Convert.ToByte(bytesData.Substring(12,2), 16), Convert.ToByte(bytesData.Substring(14,2), 16) }; - } - - } - #endregion - - #region STRRET - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct STRRET - { - internal STRRETFlags uType; // One of the STRRET values - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1024)] - internal byte[] cStr; - } - #endregion - - #region STRRET_EX - [StructLayout(LayoutKind.Explicit)] - internal struct STRRET_EX - { - [FieldOffset(0)] internal STRRETFlags uType; // One of the STRRET values - [FieldOffset(4)] internal IntPtr pOLEString; - } - #endregion - - #region TVINSERTSTRUCT - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct TVINSERTSTRUCT - { - internal int hParent; - internal int hInsertAfter; - internal TVITEM item; - } - #endregion - - #region NM_TREEVIEW - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct NM_TREEVIEW - { - internal NMHDR hdr; - internal int action; - internal TVITEM itemOld; - internal TVITEM itemNew; - internal POINT ptDrag; - } - #endregion - - #region TVHITTESTINFO - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct TVHITTESTINFO - { - internal POINT pt; - internal TreeViewHitTestFlags flags; - internal IntPtr hItem; - } - #endregion - - #region TVSORTCB - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct TVSORTCB - { - internal IntPtr hParent; - internal Win32.CompareFunc lpfnCompare; - internal int lParam; - } - #endregion - - #region SCROLLBARINFO - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct SCROLLBARINFO - { - internal int cbSize; - internal RECT rcScrollBar; - internal int dxyLineButton; - internal int xyThumbTop; - internal int xyThumbBottom; - internal int reserved; - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=6)] - internal int[] rgstate; - } - #endregion - - #region CMINVOKECOMMANDINFO - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct CMINVOKECOMMANDINFO - { - internal int cbSize; // sizeof(CMINVOKECOMMANDINFO) - internal int fMask; // any combination of CMIC_MASK_* - internal IntPtr hwnd; // might be NULL (indicating no owner window) - internal IntPtr lpVerb; // either a string or MAKEINTRESOURCE(idOffset) - internal IntPtr lpParameters; // might be NULL (indicating no parameter) - internal IntPtr lpDirectory; // might be NULL (indicating no specific directory) - internal int nShow; // one of SW_ values for ShowWindow() API - internal int dwHotKey; - internal IntPtr hIcon; - } - #endregion - - #region NMHEADER - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - internal struct NMHEADER - { - internal NMHDR hdr; - internal int iItem; - internal int iButton; - internal HDITEM hItem; - } - #endregion - - + +using System; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Text; +using System.Diagnostics; + +//namespace UtilityLibrary.Win32 +namespace System.Windows.Forms +{ + + /// <summary> + /// Structures to interoperate with the Windows 32 API + /// </summary> + + #region SIZE + [StructLayout(LayoutKind.Sequential)] + internal struct SIZE + { + internal int cx; + internal int cy; + } + #endregion + + #region RECT + [StructLayout(LayoutKind.Sequential)] + internal struct RECT + { + internal int left; + internal int top; + internal int right; + internal int bottom; + } + #endregion + + #region INITCOMMONCONTROLSEX + [StructLayout(LayoutKind.Sequential, Pack=1)] + internal class INITCOMMONCONTROLSEX + { + internal int dwSize; + internal CommonControlInitFlags dwICC; + } + #endregion + + #region TBBUTTON + [StructLayout(LayoutKind.Sequential, Pack=1)] + internal struct TBBUTTON + { + internal int iBitmap; + internal int idCommand; + internal byte fsState; + internal byte fsStyle; + internal byte bReserved0; + internal byte bReserved1; + internal int dwData; + internal int iString; + } + #endregion + + #region POINT + [StructLayout(LayoutKind.Sequential)] + internal struct POINT + { + internal int x; + internal int y; + } + #endregion + + #region NMHDR + [StructLayout(LayoutKind.Sequential)] + internal struct NMHDR + { + internal IntPtr hwndFrom; + internal int idFrom; + internal int code; + } + #endregion + + #region TOOLTIPTEXTA + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] + internal struct TOOLTIPTEXTA + { + internal NMHDR hdr; + internal IntPtr lpszText; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)] + internal string szText; + internal IntPtr hinst; + internal ToolTipFlags flags; + } + #endregion + + #region TOOLTIPTEXT + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct TOOLTIPTEXT + { + internal NMHDR hdr; + internal IntPtr lpszText; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)] + internal string szText; + internal IntPtr hinst; + internal int uFlags; + } + #endregion + + #region NMCUSTOMDRAW + [StructLayout(LayoutKind.Sequential)] + internal struct NMCUSTOMDRAW + { + internal NMHDR hdr; + internal int dwDrawStage; + internal IntPtr hdc; + internal RECT rc; + internal int dwItemSpec; + internal int uItemState; + internal IntPtr lItemlParam; + } + #endregion + + #region NMTBCUSTOMDRAW + [StructLayout(LayoutKind.Sequential)] + internal struct NMTBCUSTOMDRAW + { + internal NMCUSTOMDRAW nmcd; + internal IntPtr hbrMonoDither; + internal IntPtr hbrLines; + internal IntPtr hpenLines; + internal int clrText; + internal int clrMark; + internal int clrTextHighlight; + internal int clrBtnFace; + internal int clrBtnHighlight; + internal int clrHighlightHotTrack; + internal RECT rcText; + internal int nStringBkMode; + internal int nHLStringBkMode; + } + #endregion + + #region NMLVCUSTOMDRAW + [StructLayout(LayoutKind.Sequential)] + internal struct NMLVCUSTOMDRAW + { + internal NMCUSTOMDRAW nmcd; + internal int clrText; + internal int clrTextBk; + internal int iSubItem; + } + #endregion + + #region TBBUTTONINFO + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct TBBUTTONINFO + { + internal int cbSize; + internal int dwMask; + internal int idCommand; + internal int iImage; + internal byte fsState; + internal byte fsStyle; + internal short cx; + internal IntPtr lParam; + internal IntPtr pszText; + internal int cchText; + } + #endregion + + #region REBARBANDINFO + [StructLayout(LayoutKind.Sequential)] + internal struct REBARBANDINFO + { + internal int cbSize; + internal RebarInfoMask fMask; + internal RebarStylesEx fStyle; + internal int clrFore; + internal int clrBack; + internal IntPtr lpText; + internal int cch; + internal int iImage; + internal IntPtr hwndChild; + internal int cxMinChild; + internal int cyMinChild; + internal int cx; + internal IntPtr hbmBack; + internal int wID; + internal int cyChild; + internal int cyMaxChild; + internal int cyIntegral; + internal int cxIdeal; + internal int lParam; + internal int cxHeader; + } + #endregion + + #region MOUSEHOOKSTRUCT + [StructLayout(LayoutKind.Sequential)] + internal struct MOUSEHOOKSTRUCT + { + internal POINT pt; + internal IntPtr hwnd; + internal int wHitTestCode; + internal IntPtr dwExtraInfo; + } + #endregion + + #region NMTOOLBAR + [StructLayout(LayoutKind.Sequential)] + internal struct NMTOOLBAR + { + internal NMHDR hdr; + internal int iItem; + internal TBBUTTON tbButton; + internal int cchText; + internal IntPtr pszText; + internal RECT rcButton; + } + #endregion + + #region NMREBARCHEVRON + [StructLayout(LayoutKind.Sequential)] + internal struct NMREBARCHEVRON + { + internal NMHDR hdr; + internal int uBand; + internal int wID; + internal int lParam; + internal RECT rc; + internal int lParamNM; + } + #endregion + + #region BITMAP + [StructLayout(LayoutKind.Sequential)] + internal struct BITMAP + { + internal long bmType; + internal long bmWidth; + internal long bmHeight; + internal long bmWidthBytes; + internal short bmPlanes; + internal short bmBitsPixel; + internal IntPtr bmBits; + } + #endregion + + #region BITMAPINFO_FLAT + [StructLayout(LayoutKind.Sequential)] + internal struct BITMAPINFO_FLAT + { + internal int bmiHeader_biSize; + internal int bmiHeader_biWidth; + internal int bmiHeader_biHeight; + internal short bmiHeader_biPlanes; + internal short bmiHeader_biBitCount; + internal int bmiHeader_biCompression; + internal int bmiHeader_biSizeImage; + internal int bmiHeader_biXPelsPerMeter; + internal int bmiHeader_biYPelsPerMeter; + internal int bmiHeader_biClrUsed; + internal int bmiHeader_biClrImportant; + [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1024)] + internal byte[] bmiColors; + } + #endregion + + #region RGBQUAD + internal struct RGBQUAD + { + internal byte rgbBlue; + internal byte rgbGreen; + internal byte rgbRed; + internal byte rgbReserved; + } + #endregion + + #region BITMAPINFOHEADER + [StructLayout(LayoutKind.Sequential)] + internal class BITMAPINFOHEADER + { + internal int biSize = Marshal.SizeOf(typeof(BITMAPINFOHEADER)); + internal int biWidth; + internal int biHeight; + internal short biPlanes; + internal short biBitCount; + internal int biCompression; + internal int biSizeImage; + internal int biXPelsPerMeter; + internal int biYPelsPerMeter; + internal int biClrUsed; + internal int biClrImportant; + } + #endregion + + #region BITMAPINFO + [StructLayout(LayoutKind.Sequential)] + internal class BITMAPINFO + { + internal BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER(); + [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1024)] + internal byte[] bmiColors; + } + #endregion + + #region PALETTEENTRY + [StructLayout(LayoutKind.Sequential)] + internal struct PALETTEENTRY + { + internal byte peRed; + internal byte peGreen; + internal byte peBlue; + internal byte peFlags; + } + #endregion + + #region MESSAGE + [StructLayout(LayoutKind.Sequential)] + internal struct MESSAGE + { + internal IntPtr hwnd; + internal int message; + internal IntPtr wParam; + internal IntPtr lParam; + internal int time; + internal int pt_x; + internal int pt_y; + } + #endregion + + #region HD_HITTESTINFO + [StructLayout(LayoutKind.Sequential)] + internal struct HD_HITTESTINFO + { + internal POINT pt; + internal HeaderControlHitTestFlags flags; + internal int iItem; + } + #endregion + + #region DLLVERSIONINFO + [StructLayout(LayoutKind.Sequential)] + internal struct DLLVERSIONINFO + { + internal int cbSize; + internal int dwMajorVersion; + internal int dwMinorVersion; + internal int dwBuildNumber; + internal int dwPlatformID; + } + #endregion + + #region PAINTSTRUCT + [StructLayout(LayoutKind.Sequential)] + internal struct PAINTSTRUCT + { + internal IntPtr hdc; + internal int fErase; + internal Rectangle rcPaint; + internal int fRestore; + internal int fIncUpdate; + internal int Reserved1; + internal int Reserved2; + internal int Reserved3; + internal int Reserved4; + internal int Reserved5; + internal int Reserved6; + internal int Reserved7; + internal int Reserved8; + } + #endregion + + #region BLENDFUNCTION + [StructLayout(LayoutKind.Sequential, Pack=1)] + internal struct BLENDFUNCTION + { + internal byte BlendOp; + internal byte BlendFlags; + internal byte SourceConstantAlpha; + internal byte AlphaFormat; + } + + #endregion + + #region TRACKMOUSEEVENTS + [StructLayout(LayoutKind.Sequential)] + internal struct TRACKMOUSEEVENTS + { + internal int cbSize; + internal TrackerEventFlags dwFlags; + internal IntPtr hWnd; + internal int dwHoverTime; + } + #endregion + + #region NMTVCUSTOMDRAW + [StructLayout(LayoutKind.Sequential)] + internal struct NMTVCUSTOMDRAW + { + internal NMCUSTOMDRAW nmcd; + internal int clrText; + internal int clrTextBk; + internal int iLevel; + } + #endregion + + #region TVITEM + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct TVITEM + { + internal int mask; + internal IntPtr hItem; + internal int state; + internal int stateMask; + internal IntPtr pszText; + internal int cchTextMax; + internal int iImage; + internal int iSelectedImage; + internal int cChildren; + internal IntPtr lParam; + } + #endregion + + #region LVITEM + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct LVITEM + { + internal ListViewItemFlags mask; + internal int iItem; + internal int iSubItem; + internal int state; + internal int stateMask; + internal IntPtr pszText; + internal int cchTextMax; + internal int iImage; + internal int lParam; + internal int iIndent; + } + #endregion + + #region HDITEM + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct HDITEM + { + internal HeaderItemFlags mask; + internal int cxy; + internal IntPtr pszText; + internal IntPtr hbm; + internal int cchTextMax; + internal int fmt; + internal int lParam; + internal int iImage; + internal int iOrder; + } + #endregion + + #region WINDOWPLACEMENT + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct WINDOWPLACEMENT + { + internal uint length; //Were int in original code + internal uint flags; // + internal uint showCmd; // + internal POINT ptMinPosition; + internal POINT ptMaxPosition; + internal RECT rcNormalPosition; + } + #endregion + + #region SCROLLINFO + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct SCROLLINFO + { + internal int cbSize; + internal int fMask; + internal int nMin; + internal int nMax; + internal int nPage; + internal int nPos; + internal int nTrackPos; + } + #endregion + + #region SHFILEINFO + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct SHFILEINFO + { + internal IntPtr hIcon; + internal int iIcon; + internal int dwAttributes; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)] + internal string szDisplayName; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)] + internal string szTypeName; + } + + #endregion + + #region SHITEMID + [StructLayout(LayoutKind.Sequential)] + internal struct SHITEMID + { + internal short cb; + [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1)] + internal byte[] abID; + } + #endregion + + #region ITEMIDLIST + [StructLayout(LayoutKind.Sequential)] + internal struct ITEMIDLIST + { + internal SHITEMID mkid; + } + #endregion + + #region IID + [StructLayout(LayoutKind.Sequential)] + internal struct IID + { + int x; + short s1; + short s2; + [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=8)] + byte[] chars; + } + #endregion + + #region REFIID + [StructLayout(LayoutKind.Sequential)] + internal struct REFIID + { + internal int x; + internal short s1; + internal short s2; + [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=8)] + internal byte[] chars; + + internal REFIID(string guid) + { + // Needs to be a string of the form: + // "000214E6-0000-0000-c000-000000000046" + string[] data = guid.Split('-'); + Debug.Assert(data.Length == 5); + x = Convert.ToInt32(data[0], 16); + s1 = Convert.ToInt16(data[1], 16); + s2 = Convert.ToInt16(data[2], 16); + string bytesData = data[3] + data[4]; + chars = new byte[] { Convert.ToByte(bytesData.Substring(0,2), 16), Convert.ToByte(bytesData.Substring(2,2), 16), + Convert.ToByte(bytesData.Substring(4,2), 16), Convert.ToByte(bytesData.Substring(6,2), 16), + Convert.ToByte(bytesData.Substring(8,2), 16), Convert.ToByte(bytesData.Substring(10,2), 16), + Convert.ToByte(bytesData.Substring(12,2), 16), Convert.ToByte(bytesData.Substring(14,2), 16) }; + } + + } + #endregion + + #region STRRET + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct STRRET + { + internal STRRETFlags uType; // One of the STRRET values + [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1024)] + internal byte[] cStr; + } + #endregion + + #region STRRET_EX + [StructLayout(LayoutKind.Explicit)] + internal struct STRRET_EX + { + [FieldOffset(0)] internal STRRETFlags uType; // One of the STRRET values + [FieldOffset(4)] internal IntPtr pOLEString; + } + #endregion + + #region TVINSERTSTRUCT + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct TVINSERTSTRUCT + { + internal int hParent; + internal int hInsertAfter; + internal TVITEM item; + } + #endregion + + #region NM_TREEVIEW + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct NM_TREEVIEW + { + internal NMHDR hdr; + internal int action; + internal TVITEM itemOld; + internal TVITEM itemNew; + internal POINT ptDrag; + } + #endregion + + #region TVHITTESTINFO + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct TVHITTESTINFO + { + internal POINT pt; + internal TreeViewHitTestFlags flags; + internal IntPtr hItem; + } + #endregion + + #region TVSORTCB + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct TVSORTCB + { + internal IntPtr hParent; + internal Win32.CompareFunc lpfnCompare; + internal int lParam; + } + #endregion + + #region SCROLLBARINFO + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct SCROLLBARINFO + { + internal int cbSize; + internal RECT rcScrollBar; + internal int dxyLineButton; + internal int xyThumbTop; + internal int xyThumbBottom; + internal int reserved; + [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=6)] + internal int[] rgstate; + } + #endregion + + #region CMINVOKECOMMANDINFO + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct CMINVOKECOMMANDINFO + { + internal int cbSize; // sizeof(CMINVOKECOMMANDINFO) + internal int fMask; // any combination of CMIC_MASK_* + internal IntPtr hwnd; // might be NULL (indicating no owner window) + internal IntPtr lpVerb; // either a string or MAKEINTRESOURCE(idOffset) + internal IntPtr lpParameters; // might be NULL (indicating no parameter) + internal IntPtr lpDirectory; // might be NULL (indicating no specific directory) + internal int nShow; // one of SW_ values for ShowWindow() API + internal int dwHotKey; + internal IntPtr hIcon; + } + #endregion + + #region NMHEADER + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct NMHEADER + { + internal NMHDR hdr; + internal int iItem; + internal int iButton; + internal HDITEM hItem; + } + #endregion + + [StructLayout(LayoutKind.Sequential)] internal struct MSG { internal IntPtr hwnd; @@ -694,39 +694,39 @@ internal uint time; internal POINT pt; } -// -// [StructLayout(LayoutKind.Sequential)] -// internal struct WNDCLASS { -// internal int style; -// internal WndProc lpfnWndProc; -// internal int cbClsExtra; -// internal int cbWndExtra; -// internal IntPtr hInstance; -// internal IntPtr hIcon; -// internal IntPtr hCursor; -// internal IntPtr hbrBackground; -// internal string lpszMenuName; -// internal string lpszClassName; -// } - + + [StructLayout(LayoutKind.Sequential)] + internal struct WNDCLASS { + internal int style; + internal Win32.WndProc lpfnWndProc; + internal int cbClsExtra; + internal int cbWndExtra; + internal IntPtr hInstance; + internal IntPtr hIcon; + internal IntPtr hCursor; + internal IntPtr hbrBackground; + internal string lpszMenuName; + internal string lpszClassName; + } + // // // [StructLayout(LayoutKind.Sequential)] // internal struct WNDCLASSA { - // uint style; - // WNDPROC lpfnWndProc; - // INT cbClsExtra; - // INT cbWndExtra; - // HINSTANCE hInstance; - // HICON hIcon; - // HCURSOR hCursor; - // HBRUSH hbrBackground; - // LPCSTR lpszMenuName; - // LPCSTR lpszClassName; - // } - - - -} - + // uint style; + // WNDPROC lpfnWndProc; + // INT cbClsExtra; + // INT cbWndExtra; + // HINSTANCE hInstance; + // HICON hIcon; + // HCURSOR hCursor; + // HBRUSH hbrBackground; + // LPCSTR lpszMenuName; + // LPCSTR lpszClassName; + // } + + + +} + Index: Menu.cs =================================================================== RCS file: /cvs/public/mcs/class/System.Windows.Forms/System.Windows.Forms/Menu.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Menu.cs 18 Nov 2002 04:46:32 -0000 1.16 +++ Menu.cs 24 Nov 2002 04:31:26 -0000 1.17 @@ -1,425 +1,425 @@ -// -// System.Windows.Forms.Menu.cs -// -// Author: -// stubbed out by Paul Osman (paul.osman@sympatico.ca) -// Dennis Hayes (dennish@raytek.com) -// Alexandre Pigolkine (pigolkine@gmx.de) -// -// (C) 2002 Ximian, Inc -// - -using System; -using System.Reflection; -using System.Globalization; -//using System.Windows.Forms.AccessibleObject.IAccessible; -using System.Drawing; -using System.Collections; -using System.Runtime.Remoting; - -namespace System.Windows.Forms { - - - /// <summary> - /// ToDo note: - /// - Nothing is implemented - /// </summary> - using System.ComponentModel; - public abstract class Menu : Component { - - // - // -- Public Methods - // - - [MonoTODO] - public ContextMenu GetContextMenu() { - throw new NotImplementedException(); - } - - [MonoTODO] - public MainMenu GetMainMenu() { - throw new NotImplementedException(); - } - - [MonoTODO] - public virtual void MergeMenu(Menu menuSrc) { - throw new NotImplementedException(); - } - - [MonoTODO] - protected override void Dispose(bool disposing) { - throw new NotImplementedException (); - } - - [MonoTODO] - public override string ToString() { - //do our own ToString here. - // this is overrridden - return base.ToString(); - } - - // - // -- Protected Methods - // - - protected void CloneMenu(Menu menuSrc) { - throw new NotImplementedException(); - } - - protected Menu( MenuItem[] items) { - if( items != null) { - IsParent_ = true; - MenuItems.AddRange ( items); - } - } - - // - // -- Public Properties - // - - - private IntPtr menuHandle_ = IntPtr.Zero; - public IntPtr Handle { - get { - if( menuHandle_ == IntPtr.Zero) { - menuHandle_ = Win32.CreateMenu(); - //System.Console.WriteLine("Create menu {0}", menuHandle_); - } - return menuHandle_; - } - } - - protected bool IsParent_ = false; - - public virtual bool IsParent { - - get { - return IsParent_; - } - } - - public MenuItem MdiListItem { - - get { - throw new NotImplementedException(); - } - } - - private Menu.MenuItemCollection menuCollection_ = null; - - public Menu.MenuItemCollection MenuItems { - get { - if( menuCollection_ == null) { - menuCollection_ = new Menu.MenuItemCollection( this); - } - return menuCollection_; - } - } - - internal const uint INVALID_MENU_ID = 0xffffffff; - // Variables are stored here to provide access for the base functions - protected uint MenuID_ = INVALID_MENU_ID; - - // Provides unique id to all items in all menus, hopefully space is enougth. - // Possible to use array to keep ids from deleted menu items - // and reuse them. - protected static uint MenuIDs_ = 1; - - // Library interface - - // Recursively searches for specified item in menu. - // Goes immediately into child, when mets one. - internal virtual MenuItem GetMenuItemByID( uint id) - { - foreach( MenuItem mi in MenuItems) { - if( mi.IsParent_) { - MenuItem submi = mi.GetMenuItemByID(id); - if( submi != null) return submi; - } - else { - if( mi.MenuID_ == id){ - return mi; - } - } - } - return null; - } - - // - // Btw, this function is funky, it is being used by routines that are supposed - // to be passing an IntPtr to the AppendMenu function - // - internal virtual uint GetIDByMenuItem( MenuItem mi) - { - // FIXME: Pay attention, do not assign an id to a "stranger" - // If reusing IDs, get one from array first - if ( mi.MenuID_ == INVALID_MENU_ID) { - mi.MenuID_ = MenuIDs_++; - } - return mi.MenuID_; - } - - //inherited - //public virtual ISite Site { - // get { - // throw new NotImplementedException(); - // } - // set { - // throw new NotImplementedException(); - // } - //} - - // - // -- Protected Properties - // - - //inherited - //protected bool DesignMode { - // get { - // throw new NotImplementedException(); - // } - //} - //protected EventHandlerList Events { - // get { - // throw new NotImplementedException(); - // } - //} - - - // - // System.Windows.Forms.Menu.MenuItemCollection.cs - // - // Author: - // stubbed out by Paul Osman (paul.osman@sympatico.ca) - // - // (C) 2002 Ximian, Inc - // - /// <summary> - /// ToDo note: - /// - Nothing is implemented - /// </summary> - - public class MenuItemCollection : IList, ICollection, IEnumerable { - private ArrayList items_ = new ArrayList(); - private Menu parentMenu_ = null; - // - // -- Constructor - // - - public MenuItemCollection(Menu m) { - parentMenu_ = m; - } - - // - // -- Public Methods - // - - public virtual int Add(MenuItem mi) { - int result = -1; - // FIXME: MenuItem cannot be inserted to several containers. Check this here. - if( mi != null){ - // FIXME: Set MenuItem's owner here. - items_.Add(mi); - result = items_.Count; - //System.Console.WriteLine("Adding menuItem {0}, parent {1}", mi.Text, mi.IsParent); - if( parentMenu_ != null) { - if( mi.IsParent){ - Win32.AppendMenuA( parentMenu_.Handle, (int)MF_.MF_ENABLED | (int)MF_.MF_STRING | (int)MF_.MF_POPUP, - mi.Handle, mi.Text); - } - else { - Win32.AppendMenuA( parentMenu_.Handle, (int)MF_.MF_ENABLED | (int)MF_.MF_STRING, - (IntPtr) parentMenu_.GetIDByMenuItem(mi), mi.Text); - } - } - } - return result; - } - private MenuItem AddMenuItemCommon( MenuItem mi) { - return ( -1 != Add (mi)) ? mi : null; - } - - public virtual MenuItem Add ( string s) { - return AddMenuItemCommon( new MenuItem (s)); - } - - public virtual int Add ( int i, MenuItem m) { - throw new NotImplementedException (); - } - - public virtual MenuItem Add (string s, EventHandler e) { - return AddMenuItemCommon(new MenuItem ( s, e)); - } - - public virtual MenuItem Add (string s, MenuItem[] items) { - return AddMenuItemCommon(new MenuItem ( s, items)); - } - - public virtual void AddRange(MenuItem[] items) { - foreach( MenuItem mi in items) { - Add(mi); - } - } - - public virtual void Clear() { - throw new NotImplementedException (); - } - - public bool Contains(MenuItem m) { - throw new NotImplementedException (); - } - - public void CopyTo(Array a, int i) { - throw new NotImplementedException (); - } - - public override bool Equals(object o) { - throw new NotImplementedException (); - } - - [MonoTODO] - public override int GetHashCode() { - //FIXME add our proprities - return base.GetHashCode(); - } - - public IEnumerator GetEnumerator() { - return items_.GetEnumerator(); - } - - public int IndexOf(MenuItem m) { - throw new NotImplementedException (); - } - - public virtual void Remove(MenuItem m) { - throw new NotImplementedException (); - } - - public virtual void RemoveAt(int i) { - throw new NotImplementedException (); - } - - public override string ToString() { - throw new NotImplementedException (); - } - - // - // -- Protected Methods - // - - ~MenuItemCollection() { - throw new NotImplementedException (); - } - - //inherited - //protected object MemberwiseClone() { - // throw new NotImplementedException (); - //} - - // - // -- Public Properties - // - - public int Count { - - get { - throw new NotImplementedException (); - } - } - - // public virtual MenuItem this(int i) - // { - // get - // { - // throw new NotImplementedException (); - // } - // } - /// <summary> - /// IList Interface implmentation. - /// </summary> - bool IList.IsReadOnly{ - get{ - // We allow addition, removeal, and editing of items after creation of the list. - return false; - } - } - bool IList.IsFixedSize{ - get{ - // We allow addition and removeal of items after creation of the list. - return false; - } - } - - //[MonoTODO] - object IList.this[int index]{ - get{ - throw new NotImplementedException (); - } - set{ - throw new NotImplementedException (); - } - } - - [MonoTODO] - void IList.Clear(){ - throw new NotImplementedException (); - } - - [MonoTODO] - int IList.Add( object value){ - throw new NotImplementedException (); - } - - [MonoTODO] - bool IList.Contains( object value){ - throw new NotImplementedException (); - } - - [MonoTODO] - int IList.IndexOf( object value){ - throw new NotImplementedException (); - } - - [MonoTODO] - void IList.Insert(int index, object value){ - throw new NotImplementedException (); - } - - [MonoTODO] - void IList.Remove( object value){ - throw new NotImplementedException (); - } - - [MonoTODO] - void IList.RemoveAt( int index){ - throw new NotImplementedException (); - } - // End of IList interface - /// <summary> - /// ICollection Interface implmentation. - /// </summary> - int ICollection.Count{ - get{ - throw new NotImplementedException (); - } - } - bool ICollection.IsSynchronized{ - get{ - throw new NotImplementedException (); - } - } - object ICollection.SyncRoot{ - get{ - throw new NotImplementedException (); - } - } - void ICollection.CopyTo(Array array, int index){ - throw new NotImplementedException (); - } - // End Of ICollection - } - } -} - - - +// +// System.Windows.Forms.Menu.cs +// +// Author: +// stubbed out by Paul Osman (paul.osman@sympatico.ca) +// Dennis Hayes (dennish@raytek.com) +// Alexandre Pigolkine (pigolkine@gmx.de) +// +// (C) 2002 Ximian, Inc +// + +using System; +using System.Reflection; +using System.Globalization; +//using System.Windows.Forms.AccessibleObject.IAccessible; +using System.Drawing; +using System.Collections; +using System.Runtime.Remoting; + +namespace System.Windows.Forms { + + + /// <summary> + /// ToDo note: + /// - Nothing is implemented + /// </summary> + using System.ComponentModel; + public abstract class Menu : Component { + + // + // -- Public Methods + // + + [MonoTODO] + public ContextMenu GetContextMenu() { + throw new NotImplementedException(); + } + + [MonoTODO] + public MainMenu GetMainMenu() { + throw new NotImplementedException(); + } + + [MonoTODO] + public virtual void MergeMenu(Menu menuSrc) { + throw new NotImplementedException(); + } + + [MonoTODO] + protected override void Dispose(bool disposing) { + throw new NotImplementedException (); + } + + [MonoTODO] + public override string ToString() { + //do our own ToString here. + // this is overrridden + return base.ToString(); + } + + // + // -- Protected Methods + // + + protected void CloneMenu(Menu menuSrc) { + throw new NotImplementedException(); + } + + protected Menu( MenuItem[] items) { + if( items != null) { + IsParent_ = true; + MenuItems.AddRange ( items); + } + } + + // + // -- Public Properties + // + + + private IntPtr menuHandle_ = IntPtr.Zero; + public IntPtr Handle { + get { + if( menuHandle_ == IntPtr.Zero) { + menuHandle_ = Win32.CreateMenu(); + //System.Console.WriteLine("Create menu {0}", menuHandle_); + } + return menuHandle_; + } + } + + protected bool IsParent_ = false; + + public virtual bool IsParent { + + get { + return IsParent_; + } + } + + public MenuItem MdiListItem { + + get { + throw new NotImplementedException(); + } + } + + private Menu.MenuItemCollection menuCollection_ = null; + + public Menu.MenuItemCollection MenuItems { + get { + if( menuCollection_ == null) { + menuCollection_ = new Menu.MenuItemCollection( this); + } + return menuCollection_; + } + } + + internal const uint INVALID_MENU_ID = 0xffffffff; + // Variables are stored here to provide access for the base functions + protected internal uint MenuID_ = INVALID_MENU_ID; + + // Provides unique id to all items in all menus, hopefully space is enougth. + // Possible to use array to keep ids from deleted menu items + // and reuse them. + protected static int MenuIDs_ = 1; + + // Library interface + + // Recursively searches for specified item in menu. + // Goes immediately into child, when mets one. + internal virtual MenuItem GetMenuItemByID( uint id) + { + foreach( MenuItem mi in MenuItems) { + if( mi.IsParent) { + MenuItem submi = mi.GetMenuItemByID(id); + if( submi != null) return submi; + } + else { + if( mi.MenuID_ == id){ + return mi; + } + } + } + return null; + } + + // + // Btw, this function is funky, it is being used by routines that are supposed + // to be passing an IntPtr to the AppendMenu function + // + internal virtual uint GetIDByMenuItem(MenuItem mi) + { + // FIXME: Pay attention, do not assign an id to a "stranger" + // If reusing IDs, get one from array first + if ( mi.MenuID_ == INVALID_MENU_ID) { + mi.MenuID_ = MenuIDs_++; + } + return (uint)mi.MenuID; + } + + //inherited + //public virtual ISite Site { + // get { + // throw new NotImplementedException(); + // } + // set { + // throw new NotImplementedException(); + // } + //} + + // + // -- Protected Properties + // + + //inherited + //protected bool DesignMode { + // get { + // throw new NotImplementedException(); + // } + //} + //protected EventHandlerList Events { + // get { + // throw new NotImplementedException(); + // } + //} + + + // + // System.Windows.Forms.Menu.MenuItemCollection.cs + // + // Author: + // stubbed out by Paul Osman (paul.osman@sympatico.ca) + // + // (C) 2002 Ximian, Inc + // + /// <summary> + /// ToDo note: + /// - Nothing is implemented + /// </summary> + + public class MenuItemCollection : IList, ICollection, IEnumerable { + private ArrayList items_ = new ArrayList(); + private Menu parentMenu_ = null; + // + // -- Constructor + // + + public MenuItemCollection(Menu m) { + parentMenu_ = m; + } + + // + // -- Public Methods + // + + public virtual int Add(MenuItem mi) { + int result = -1; + // FIXME: MenuItem cannot be inserted to several containers. Check this here. + if( mi != null){ + // FIXME: Set MenuItem's owner here. + items_.Add(mi); + result = items_.Count; + //System.Console.WriteLine("Adding menuItem {0}, parent {1}", mi.Text, mi.IsParent); + if( parentMenu_ != null) { + if( mi.IsParent){ + Win32.AppendMenuA( parentMenu_.Handle, (int)MF_.MF_ENABLED | (int)MF_.MF_STRING | (int)MF_.MF_POPUP, + mi.Handle, mi.Text); + } + else { + Win32.AppendMenuA( parentMenu_.Handle, (int)MF_.MF_ENABLED | (int)MF_.MF_STRING, + (IntPtr) parentMenu_.GetIDByMenuItem(mi), mi.Text); + } + } + } + return result; + } + private MenuItem AddMenuItemCommon( MenuItem mi) { + return ( -1 != Add (mi)) ? mi : null; + } + + public virtual MenuItem Add ( string s) { + return AddMenuItemCommon( new MenuItem (s)); + } + + public virtual int Add ( int i, MenuItem m) { + throw new NotImplementedException (); + } + + public virtual MenuItem Add (string s, EventHandler e) { + return AddMenuItemCommon(new MenuItem ( s, e)); + } + + public virtual MenuItem Add (string s, MenuItem[] items) { + return AddMenuItemCommon(new MenuItem ( s, items)); + } + + public virtual void AddRange(MenuItem[] items) { + foreach( MenuItem mi in items) { + Add(mi); + } + } + + public virtual void Clear() { + throw new NotImplementedException (); + } + + public bool Contains(MenuItem m) { + throw new NotImplementedException (); + } + + public void CopyTo(Array a, int i) { + throw new NotImplementedException (); + } + + public override bool Equals(object o) { + throw new NotImplementedException (); + } + + [MonoTODO] + public override int GetHashCode() { + //FIXME add our proprities + return base.GetHashCode(); + } + + public IEnumerator GetEnumerator() { + return items_.GetEnumerator(); + } + + public int IndexOf(MenuItem m) { + throw new NotImplementedException (); + } + + public virtual void Remove(MenuItem m) { + throw new NotImplementedException (); + } + + public virtual void RemoveAt(int i) { + throw new NotImplementedException (); + } + + public override string ToString() { + throw new NotImplementedException (); + } + + // + // -- Protected Methods + // + + ~MenuItemCollection() { + throw new NotImplementedException (); + } + + //inherited + //protected object MemberwiseClone() { + // throw new NotImplementedException (); + //} + + // + // -- Public Properties + // + + public int Count { + + get { + throw new NotImplementedException (); + } + } + + // public virtual MenuItem this(int i) + // { + // get + // { + // throw new NotImplementedException (); + // } + // } + /// <summary> + /// IList Interface implmentation. + /// </summary> + bool IList.IsReadOnly{ + get{ + // We allow addition, removeal, and editing of items after creation of the list. + return false; + } + } + bool IList.IsFixedSize{ + get{ + // We allow addition and removeal of items after creation of the list. + return false; + } + } + + //[MonoTODO] + object IList.this[int index]{ + get{ + throw new NotImplementedException (); + } + set{ + throw new NotImplementedException (); + } + } + + [MonoTODO] + void IList.Clear(){ + throw new NotImplementedException (); + } + + [MonoTODO] + int IList.Add( object value){ + throw new NotImplementedException (); + } + + [MonoTODO] + bool IList.Contains( object value){ + throw new NotImplementedException (); + } + + [MonoTODO] + int IList.IndexOf( object value){ + throw new NotImplementedException (); + } + + [MonoTODO] + void IList.Insert(int index, object value){ + throw new NotImplementedException (); + } + + [MonoTODO] + void IList.Remove( object value){ + throw new NotImplementedException (); + } + + [MonoTODO] + void IList.RemoveAt( int index){ + throw new NotImplementedException (); + } + // End of IList interface + /// <summary> + /// ICollection Interface implmentation. + /// </summary> + int ICollection.Count{ + get{ + throw new NotImplementedException (); + } + } + bool ICollection.IsSynchronized{ + get{ + throw new NotImplementedException (); + } + } + object ICollection.SyncRoot{ + get{ + throw new NotImplementedException (); + } + } + void ICollection.CopyTo(Array array, int index){ + throw new NotImplementedException (); + } + // End Of ICollection + } + } +} + + + Index: ScrollableControl.cs =================================================================== RCS file: /cvs/public/mcs/class/System.Windows.Forms/System.Windows.Forms/ScrollableControl.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ScrollableControl.cs 18 Nov 2002 04:46:33 -0000 1.8 +++ ScrollableControl.cs 24 Nov 2002 04:31:26 -0000 1.9 @@ -1,308 +1,341 @@ -// -// System.Windows.Forms.Form -// -// Author: -// Miguel de Icaza (miguel@ximian.com) -// stubbed out by Daniel Carrera (dcarrera@math.toronto.edu) -// ScrollableControl.DockPaddingEdges stub added by Jaak Simm (jaaksimm@firm.ee) -// Dennis Hayes (dennish@raytek.com) -// WINELib implementation started by John Sohn (jsohn@columbus.rr.com) -// CE Complete. -// (C) 2002 Ximian, Inc -// - -using System; -using System.Drawing; -using System.ComponentModel; -namespace System.Windows.Forms { - - public class ScrollableControl : Control { - - private ScrollableControl.DockPaddingEdges dockPadding; - - // - // --- Constructor - // - public ScrollableControl () : base () - { - dockPadding = new ScrollableControl.DockPaddingEdges(); - } - // - // --- Public Properties - // - [MonoTODO] - public virtual bool AutoScroll { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Size AutoScrollMargin { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Size AutoScrollMinSize { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Point AutoScrollPosition { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - public override Rectangle DisplayRectangle { - get { - return base.DisplayRectangle; - } - } - - [MonoTODO] - public ScrollableControl.DockPaddingEdges DockPadding { - get { - return dockPadding; - } - } - - // - // --- Protected Properties - // - - protected override CreateParams CreateParams { - get { - CreateParams createParams = new CreateParams (); - createParams.Caption = ""; - createParams.ClassName = "mono_scrollable_control"; - createParams.X = Left; - createParams.Y = Top; - createParams.Width = Width; - createParams.Height = Height; - createParams.ClassStyle = 0; - createParams.ExStyle = 0; - createParams.Param = 0; - - //if (parent != null) - // createParams.Parent = parent.Handle; - //else - createParams.Parent = (IntPtr) 0; - - createParams.Style = (int) WindowStyles.WS_OVERLAPPEDWINDOW; - - return createParams; - } - } - - [MonoTODO] - protected bool HScroll { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - protected bool VScroll { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - // - // --- Protected Methods - // - [MonoTODO] - protected virtual void AdjustFormScrollbars ( - bool displayScrollbars) - { - throw new NotImplementedException (); - } - - protected override void OnLayout (LayoutEventArgs e) { - base.OnLayout (e); - } - - protected override void OnMouseWheel (MouseEventArgs e) { - base.OnMouseWheel (e); - } - - protected override void OnVisibleChanged (EventArgs e) { - base.OnVisibleChanged (e); - } - - protected override void ScaleCore (float dx, float dy) { - base.ScaleCore (dx, dy); - } - - protected override void WndProc (ref Message m) { - base.WndProc (ref m); - } - - - /// ScrollableControl.DockPaddingEdges - /// Determines the border padding for docked controls. - - public class DockPaddingEdges : ICloneable { - // --- Fields --- - int all; - int bottom; - int left; - int right; - int top; - - - // --- public Properties --- - public int All { - get { - return all; - } - set { - all = value; - left = value; - right = value; - bottom = value; - top = value; - } - } - - public int Bottom { - get { return bottom; } - set { bottom = value; } - } - - public int Left { - get { return left; } - set { left = value; } - } - - public int Right { - get { return right; } - set { right = value; } - } - - public int Top { - get { return top; } - set { top = value; } - } - - - /// --- public Methods --- - - /// <summary> - /// Equality Operator - /// </summary> - /// - /// <remarks> - /// Compares two DockPaddingEdges objects. The return value is - /// based on the equivalence of the - /// properties of the two DockPaddingEdges. - /// </remarks> - - public static bool operator == (DockPaddingEdges objA, DockPaddingEdges objB) { - return ((objA.left == objB.left) && - (objA.right == objB.right) && - (objA.top == objB.top) && - (objA.bottom == objB.bottom) && - (objA.all == objB.all)); - } - /// <summary> - /// Equals Method - /// </summary> - /// - /// <remarks> - /// Checks equivalence of this DockPaddingEdges and another object. - /// </remarks> - - public override bool Equals (object obj) { - if (!(obj is DockPaddingEdges)) - return false; - - return (this == (DockPaddingEdges) obj); - } - - /// <summary> - /// Inequality Operator - /// </summary> - /// - /// <remarks> - /// Compares two DockPaddingEdges objects. The return value is - /// based on the equivalence of the - /// properties of the two Sizes. - /// </remarks> - - public static bool operator != (DockPaddingEdges objA, DockPaddingEdges objB) { - return ((objA.left != objB.left) || - (objA.right != objB.right) || - (objA.top != objB.top) || - (objA.bottom != objB.bottom) || - (objA.all != objB.all)); - } - /// <summary> - /// GetHashCode Method - /// </summary> - /// - /// <remarks> - /// Calculates a hashing value. - /// </remarks> - - public override int GetHashCode () { - unchecked{ - return all * top * bottom * right * left; - } - } - - - /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. - object ICloneable.Clone () - { - DockPaddingEdges dpe = new DockPaddingEdges(); - dpe.all = all; - dpe.top = top; - dpe.right = right; - dpe.bottom = bottom; - dpe.left = left; - return (object) dpe; - } - - /// <summary> - /// ToString Method - /// </summary> - /// - /// <remarks> - /// Formats the DockPaddingEdges as a string. - /// </remarks> - - public override string ToString () - { - return "All = " + all.ToString() + " Top = " + top.ToString() + - " Right = " + right.ToString() + " Bottom = " + bottom.ToString() + - " Left = " + left.ToString(); - } - } - - } -} - +// +// System.Windows.Forms.Form +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// stubbed out by Daniel Carrera (dcarrera@math.toronto.edu) +// ScrollableControl.DockPaddingEdges stub added by Jaak Simm (jaaksimm@firm.ee) +// Dennis Hayes (dennish@raytek.com) +// WINELib implementation started by John Sohn (jsohn@columbus.rr.com) +// CE Complete. +// (C) 2002 Ximian, Inc +// + +using System; +using System.Drawing; +using System.ComponentModel; +namespace System.Windows.Forms { + + public class ScrollableControl : Control { + + private static bool classRegistered = false; + + private ScrollableControl.DockPaddingEdges dockPadding; + + // + // --- Constructor + // + public ScrollableControl () : base () + { + dockPadding = new ScrollableControl.DockPaddingEdges(); + } + // + // --- Public Properties + // + [MonoTODO] + public virtual bool AutoScroll { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Size AutoScrollMargin { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Size AutoScrollMinSize { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Point AutoScrollPosition { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + public override Rectangle DisplayRectangle { + get { + return base.DisplayRectangle; + } + } + + [MonoTODO] + public ScrollableControl.DockPaddingEdges DockPadding { + get { + return dockPadding; + } + } + + // + // --- Protected Properties + // + + protected override CreateParams CreateParams { + get { + if (!classRegistered) { + Win32.WndProc wp = new Win32.WndProc (WndProc); + WNDCLASS wndClass = new WNDCLASS(); + + wndClass.style = (int) (CS_.CS_OWNDC | CS_.CS_VREDRAW | CS_.CS_HREDRAW); + wndClass.lpfnWndProc = wp; + wndClass.cbClsExtra = 0; + wndClass.cbWndExtra = 0; + wndClass.hInstance = (IntPtr)0; + wndClass.hIcon = (IntPtr)0; + wndClass.hCursor = (IntPtr)0; + wndClass.hbrBackground = (IntPtr)6; // ??? + wndClass.lpszMenuName = ""; + wndClass.lpszClassName = "mono_scrollable_control"; + + if (Win32.RegisterClassA(ref wndClass) != 0) + classRegistered = true; + } + + CreateParams createParams = new CreateParams (); + createParams.Caption = ""; + createParams.ClassName = "mono_scrollable_control"; + createParams.X = Left; + createParams.Y = Top; + createParams.Width = Width; + createParams.Height = Height; + createParams.ClassStyle = 0; + createParams.ExStyle = 0; + createParams.Param = 0; + + //if (parent != null) + // createParams.Parent = parent.Handle; + //else + createParams.Parent = (IntPtr) 0; + + createParams.Style = (int) WindowStyles.WS_OVERLAPPEDWINDOW; + + return createParams; + } + } + + [MonoTODO] + protected bool HScroll { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + protected bool VScroll { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + // + // --- Protected Methods + // + static private IntPtr WndProc (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam) { + Message message = new Message(); + + message.HWnd = hWnd; + message.Msg = msg; + message.WParam = wParam; + message.LParam = lParam; + message.Result = (IntPtr)0; + + return (IntPtr)0; + } + + [MonoTODO] + protected virtual void AdjustFormScrollbars ( + bool displayScrollbars) + { + throw new NotImplementedException (); + } + + protected override void OnLayout (LayoutEventArgs e) { + base.OnLayout (e); + } + + protected override void OnMouseWheel (MouseEventArgs e) { + base.OnMouseWheel (e); + } + + protected override void OnVisibleChanged (EventArgs e) { + base.OnVisibleChanged (e); + } + + protected override void ScaleCore (float dx, float dy) { + base.ScaleCore (dx, dy); + } + + protected override void WndProc (ref Message m) { + base.WndProc (ref m); + } + + + /// ScrollableControl.DockPaddingEdges + /// Determines the border padding for docked controls. + + public class DockPaddingEdges : ICloneable { + // --- Fields --- + int all; + int bottom; + int left; + int right; + int top; + + + // --- public Properties --- + public int All { + get { + return all; + } + set { + all = value; + left = value; + right = value; + bottom = value; + top = value; + } + } + + public int Bottom { + get { return bottom; } + set { bottom = value; } + } + + public int Left { + get { return left; } + set { left = value; } + } + + public int Right { + get { return right; } + set { right = value; } + } + + public int Top { + get { return top; } + set { top = value; } + } + + + /// --- public Methods --- + + /// <summary> + /// Equality Operator + /// </summary> + /// + /// <remarks> + /// Compares two DockPaddingEdges objects. The return value is + /// based on the equivalence of the + /// properties of the two DockPaddingEdges. + /// </remarks> + + public static bool operator == (DockPaddingEdges objA, DockPaddingEdges objB) { + return ((objA.left == objB.left) && + (objA.right == objB.right) && + (objA.top == objB.top) && + (objA.bottom == objB.bottom) && + (objA.all == objB.all)); + } + /// <summary> + /// Equals Method + /// </summary> + /// + /// <remarks> + /// Checks equivalence of this DockPaddingEdges and another object. + /// </remarks> + + public override bool Equals (object obj) { + if (!(obj is DockPaddingEdges)) + return false; + + return (this == (DockPaddingEdges) obj); + } + + /// <summary> + /// Inequality Operator + /// </summary> + /// + /// <remarks> + /// Compares two DockPaddingEdges objects. The return value is + /// based on the equivalence of the + /// properties of the two Sizes. + /// </remarks> + + public static bool operator != (DockPaddingEdges objA, DockPaddingEdges objB) { + return ((objA.left != objB.left) || + (objA.right != objB.right) || + (objA.top != objB.top) || + (objA.bottom != objB.bottom) || + (objA.all != objB.all)); + } + /// <summary> + /// GetHashCode Method + /// </summary> + /// + /// <remarks> + /// Calculates a hashing value. + /// </remarks> + + public override int GetHashCode () { + unchecked{ + return all * top * bottom * right * left; + } + } + + + /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. + object ICloneable.Clone () + { + DockPaddingEdges dpe = new DockPaddingEdges(); + dpe.all = all; + dpe.top = top; + dpe.right = right; + dpe.bottom = bottom; + dpe.left = left; + return (object) dpe; + } + + /// <summary> + /// ToString Method + /// </summary> + /// + /// <remarks> + /// Formats the DockPaddingEdges as a string. + /// </remarks> + + public override string ToString () + { + return "All = " + all.ToString() + " Top = " + top.ToString() + + " Right = " + right.ToString() + " Bottom = " + bottom.ToString() + + " Left = " + left.ToString(); + } + } + + } +} + Index: NativeWindow.cs =================================================================== RCS file: /cvs/public/mcs/class/System.Windows.Forms/System.Windows.Forms/NativeWindow.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- NativeWindow.cs 18 Nov 2002 04:46:33 -0000 1.9 +++ NativeWindow.cs 24 Nov 2002 04:31:26 -0000 1.10 @@ -1,232 +1,240 @@ -// -// System.Windows.Forms.NativeWindow.cs -// -// Author: -// stubbed out by Paul Osman (paul.osman@sympatico.ca) -// Dennis Hayes (dennish@Raytek.com) -// WINELib implementation started by John Sohn (jsohn@columbus.rr.com) -// -// (C) 2002 Ximian, Inc -// - -using System.Runtime.Remoting; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; -using System.Collections; - -namespace System.Windows.Forms { - - // <summary> - // Implementation started. - // - // </summary> - - public class NativeWindow : MarshalByRefObject { - - // the window's HWND - private IntPtr windowHandle; - static private Hashtable windowCollection = new Hashtable (); - static bool registeredClass = false; - - // - // --- Constructor - // - public NativeWindow () - { - windowHandle = (IntPtr) 0; - } - - // - // --- Public Properties - // - public IntPtr Handle - { - get { - return windowHandle; - } - } - - // - // --- Public Methods - // - public void AssignHandle (IntPtr handle) - { - if (windowHandle != (IntPtr) 0) - windowCollection.Remove (windowHandle); - - windowHandle = handle; - windowCollection.Add (windowHandle, this); - OnHandleChange (); - } - - public virtual void CreateHandle (CreateParams cp) - { - IntPtr createdHWnd = (IntPtr) 0; - Object lpParam = new Object(); - - if (!registeredClass) { - Win32.WndProc wp = new Win32.WndProc (WndProc); - if (Win32.MonoRegisterClass( - //if (Win32.RegisterClass( - (int) (CS_.CS_OWNDC | - CS_.CS_VREDRAW | - CS_.CS_HREDRAW), - wp, 0, 0, (IntPtr) 0, (IntPtr) 0, - (IntPtr) 0, (IntPtr) 6, "", - "mono_native_window") != 0) { - registeredClass = true; - } else { - windowHandle = (IntPtr) 0; - return; - } - } - - windowHandle = Win32.CreateWindowExA ( - (uint) cp.ExStyle, cp.ClassName, - cp.Caption,(uint) cp.Style, - cp.X, cp.Y, cp.Width, cp.Height, - (IntPtr) cp.Parent, (IntPtr) 0, - (IntPtr) 0, ref lpParam); - - if (windowHandle != (IntPtr) 0) - windowCollection.Add (windowHandle, this); - } - - [MonoTODO] - public override ObjRef CreateObjRef (Type requestedType) - { - throw new NotImplementedException (); - } - - public void DefWndProc (ref Message m) - { - m.Result = Win32.DefWindowProcA (m.HWnd, m.Msg, - m.WParam, m.LParam); - } - - public virtual void DestroyHandle () - { - windowCollection.Remove (windowHandle); - Win32.DestroyWindow (windowHandle); - } - - [MonoTODO] - public override bool Equals (object o) - { - throw new NotImplementedException (); - } - - //inherited - //public static bool Equals(object o1, object o2) - //{ - // throw new NotImplementedException (); - //} - [MonoTODO] - public override int GetHashCode () - { - //FIXME add our proprities - return base.GetHashCode (); - } - - public static NativeWindow FromHandle (IntPtr handle) - { - NativeWindow window = new NativeWindow (); - window.AssignHandle (handle); - return window; - } - - //inherited - //public object GetLifetimeService() { - // throw new NotImplementedException (); - //} - - //public Type GetType() { - // throw new NotImplementedException (); - //} - - //public virtual object InitializeLifetimeService(){ - // throw new NotImplementedException (); - //} - - public virtual void ReleaseHandle () - { - windowHandle = (IntPtr) 0; - OnHandleChange (); - } - - [MonoTODO] - public override string ToString () - { - throw new NotImplementedException (); - } - - // - // --- Protected Methods - // - //inherited - //protected object MemberwiseClone() { - // throw new NotImplementedException (); - //} - - [MonoTODO] - protected virtual void OnHandleChange () - { - // to be overridden - } - - [MonoTODO] - protected virtual void OnThreadException (Exception e) - { - throw new NotImplementedException (); - } - - protected virtual void WndProc (ref Message m) - { - if (m.Msg == (int)Msg.WM_CREATE) - Console.WriteLine ("NW WndProc WM_CREATE"); - DefWndProc (ref m); - } - - // - // --- Destructor - // - [MonoTODO] - ~NativeWindow () - { - } - - static private IntPtr WndProc ( - IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam) - { - // windowCollection is a collection of all the - // NativeWindow(s) that have been created. - // Dispatch the current message to the approriate - // window. - NativeWindow window = - (NativeWindow) windowCollection[hWnd]; - Message message = new Message (); - message.HWnd = hWnd; - message.Msg = msg; - message.WParam = wParam; - message.LParam = lParam; - message.Result = (IntPtr) 0; - - if (msg == (int)Msg.WM_CREATE) - Console.WriteLine ("WM_CREATE (static)"); - - if (window != null) { - if (msg == (int)Msg.WM_CREATE) - Console.WriteLine ("WM_CREATE (static != null)"); - window.WndProc(ref message); - } else { - Console.WriteLine ("no window, defwndproc"); - // even though we are not managing the - // window let the window get the message - message.Result = Win32.DefWindowProcA ( - hWnd, msg, wParam, lParam); - } - - return message.Result; - } - } -} +// +// System.Windows.Forms.NativeWindow.cs +// +// Author: +// stubbed out by Paul Osman (paul.osman@sympatico.ca) +// Dennis Hayes (dennish@Raytek.com) +// WINELib implementation started by John Sohn (jsohn@columbus.rr.com) +// +// (C) 2002 Ximian, Inc +// + +using System.Runtime.Remoting; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +using System.Collections; + +namespace System.Windows.Forms { + + // <summary> + // Implementation started. + // + // </summary> + + public class NativeWindow : MarshalByRefObject { + + // the window's HWND + private IntPtr windowHandle; + static private Hashtable windowCollection = new Hashtable (); + static bool registeredClass = false; + + // + // --- Constructor + // + public NativeWindow () + { + windowHandle = (IntPtr) 0; + } + + // + // --- Public Properties + // + public IntPtr Handle + { + get { + return windowHandle; + } + } + + // + // --- Public Methods + // + public void AssignHandle (IntPtr handle) + { + if (windowHandle != (IntPtr) 0) + windowCollection.Remove (windowHandle); + + windowHandle = handle; + windowCollection.Add (windowHandle, this); + OnHandleChange (); + } + + public virtual void CreateHandle (CreateParams cp) + { + IntPtr createdHWnd = (IntPtr) 0; + Object lpParam = new Object(); + + if (!registeredClass) { + Win32.WndProc wp = new Win32.WndProc (WndProc); + Win32.WNDCLASS wndClass = new Win32.WNDCLASS(); + + wndClass.style = (int) (Win32.CS_OWNDC | + Win32.CS_VREDRAW | + Win32.CS_HREDRAW); + wndClass.lpfnWndProc = wp; + wndClass.cbClsExtra = 0; + wndClass.cbWndExtra = 0; + wndClass.hInstance = (IntPtr)0; + wndClass.hIcon = (IntPtr)0; + wndClass.hCursor = (IntPtr)0; + wndClass.hbrBackground = (IntPtr)6; // ??? + wndClass.lpszMenuName = ""; + wndClass.lpszClassName = "mono_native_window"; + + if (Win32.RegisterClassA(wndClass) != 0) { + registeredClass = true; + } else { + windowHandle = (IntPtr)0; + return; + } + } + + windowHandle = Win32.CreateWindowExA ( + (uint) cp.ExStyle, cp.ClassName, + cp.Caption,(uint) cp.Style, + cp.X, cp.Y, cp.Width, cp.Height, + (IntPtr) cp.Parent, (IntPtr) 0, + (IntPtr) 0, ref lpParam); + + if (windowHandle != (IntPtr) 0) + windowCollection.Add (windowHandle, this); + } + + [MonoTODO] + public override ObjRef CreateObjRef (Type requestedType) + { + throw new NotImplementedException (); + } + + public void DefWndProc (ref Message m) + { + m.Result = Win32.DefWindowProcA (m.HWnd, m.Msg, + m.WParam, m.LParam); + } + + public virtual void DestroyHandle () + { + windowCollection.Remove (windowHandle); + Win32.DestroyWindow (windowHandle); + } + + [MonoTODO] + public override bool Equals (object o) + { + throw new NotImplementedException (); + } + + //inherited + //public static bool Equals(object o1, object o2) + //{ + // throw new NotImplementedException (); + //} + [MonoTODO] + public override int GetHashCode () + { + //FIXME add our proprities + return base.GetHashCode (); + } + + public static NativeWindow FromHandle (IntPtr handle) + { + NativeWindow window = new NativeWindow (); + window.AssignHandle (handle); + return window; + } + + //inherited + //public object GetLifetimeService() { + // throw new NotImplementedException (); + //} + + //public Type GetType() { + // throw new NotImplementedException (); + //} + + //public virtual object InitializeLifetimeService(){ + // throw new NotImplementedException (); + //} + + public virtual void ReleaseHandle () + { + windowHandle = (IntPtr) 0; + OnHandleChange (); + } + + [MonoTODO] + public override string ToString () + { + throw new NotImplementedException (); + } + + // + // --- Protected Methods + // + //inherited + //protected object MemberwiseClone() { + // throw new NotImplementedException (); + //} + + [MonoTODO] + protected virtual void OnHandleChange () + { + // to be overridden + } + + [MonoTODO] + protected virtual void OnThreadException (Exception e) + { + throw new NotImplementedException (); + } + + protected virtual void WndProc (ref Message m) + { + if (m.Msg == Win32.WM_CREATE) + Console.WriteLine ("NW WndProc WM_CREATE"); + DefWndProc (ref m); + } + + // + // --- Destructor + // + [MonoTODO] + ~NativeWindow () + { + } + + static private IntPtr WndProc ( + IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam) + { + // windowCollection is a collection of all the + // NativeWindow(s) that have been created. + // Dispatch the current message to the approriate + // window. + NativeWindow window = + (NativeWindow) windowCollection[hWnd]; + Message message = new Message (); + message.HWnd = hWnd; + message.Msg = msg; + message.WParam = wParam; + message.LParam = lParam; + message.Result = (IntPtr) 0; + + if (msg == Win32.WM_CREATE) + Console.WriteLine ("WM_CREATE (static)"); + + if (window != null) { + if (msg == Win32.WM_CREATE) + Console.WriteLine ("WM_CREATE (static != null)"); + window.WndProc(ref message); + } else { + Console.WriteLine ("no window, defwndproc"); + // even though we are not managing the + // window let the window get the message + message.Result = Win32.DefWindowProcA ( + hWnd, msg, wParam, lParam); + } + + return message.Result; + } + } +} Index: Form.cs =================================================================== RCS file: /cvs/public/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Form.cs 23 Nov 2002 02:15:54 -0000 1.14 +++ Form.cs 24 Nov 2002 04:31:26 -0000 1.15 @@ -1,1038 +1,1038 @@ - // - // System.Windows.Forms.Form - // - // Author: - // Miguel de Icaza (miguel@ximian.com) - // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu) - // Dennis Hayes (dennish@raytek.com) - // WINELib implementation started by John Sohn (jsohn@columbus.rr.com) - // - // (C) 2002 Ximian, Inc - // - - using System; - using System.Drawing; - using System.ComponentModel; - using System.Collections; - - namespace System.Windows.Forms { - - public class Form : ContainerControl { - DialogResult dialogResult; - Size maximumSize; - Size minimizeSize; - - // Temperary varibles that may be replaced - // with win32 functions - - // owner draw - private bool controlBox; - private bool minimizeBox; - private bool maximizeBox; - private bool helpButton; - //end owner draw - - FormBorderStyle formBorderStyle; - - // End of temperay varibles - - public Form () : base () - { - } - - static Form () - { - - } - - // --- Public Properties - // - [MonoTODO] - public IButtonControl AcceptButton { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public static Form ActiveForm { - get { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Form ActiveMdiChild { - get { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public bool AutoScale { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public virtual Size AutoScaleBaseSize { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - public override bool AutoScroll { - get { - return base.AutoScroll; - } - set { - base.AutoScroll = value; - } - } - - public override Color BackColor { - get { - return base.BackColor; - } - set { - base.BackColor = value; - } - } - - [MonoTODO] - public IButtonControl CancelButton { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public new Size ClientSize { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - //Compact Framework - //FIXME: - // In .NET this can be changed at any time. - // In WIN32 this is fixed when the window is created. - // In WIN32 to change this after the window is created, - // like in .NET, we must draw the caption bar our self. - // In the mean time, just set/return a bool. - // This might be the start of the drawing - [MonoTODO] - public bool ControlBox { - get { - return controlBox; - } - set { - controlBox = value; - //force paint - } - } - - [MonoTODO] - public Rectangle DesktopBounds { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Point DesktopLocation { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - //Compact Framework - [MonoTODO] - public DialogResult DialogResult { - get { - return dialogResult; - } - set { - dialogResult = value; - } - } - - //Compact Framework - [MonoTODO] - public FormBorderStyle FormBorderStyle { - get { - return formBorderStyle; - } - set { - formBorderStyle = value; - } - } - - [MonoTODO] - public bool HelpButton { - get { - return helpButton; - } - set { - helpButton = value; - } - } - - //Compact Framework - //[MonoTODO] - public Icon Icon { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public bool IsMidiChild { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public bool IsMidiContainer { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public bool KeyPreview { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - //Compact Framework - [MonoTODO] - public bool MaximizeBox { - get { - return maximizeBox; - } - set { - maximizeBox = value; - } - } - - [MonoTODO] - public Size MaximumSize { - get { - return maximumSize; - } - set { - maximumSize = value; - } - } - - [MonoTODO] - public Form[] MdiChildren { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Form MdiParent { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - //Compact Framework - //[MonoTODO] - private MainMenu mainMenu_ = null; - - private void assignMenu() - { - if( Handle != IntPtr.Zero ) { - // FIXME: If Form's window has no style for menu, probably, better to add it - // if menu have to be removed, remove the style. - // Attention to the repainting. -// if( mainMenu_ != null) { -// //long myStyle = Win32.GetWindowLongA( Handle, Win32.GWL_STYLE); -// //myStyle |= (long)Win32.WS_OVERLAPPEDWINDOW; -// //Win32.SetWindowLongA( Handle, Win32.GWL_STYLE, myStyle); -// SetMenu( Handle, mainMenu_.Handle); -// } -// else { -// SetMenu( Handle, IntPtr.Zero); -// } - } - } - - public MainMenu Menu { - get { - return mainMenu_; - } - set { - mainMenu_ = value; - assignMenu(); - } - } - - //[MonoTODO] - //public MainMenu MergedMenu { - // get { - // throw new NotImplementedException (); - // } - //} - - //Compact Framework - [MonoTODO] - public bool MinimizeBox { - get { - return minimizeBox; - } - set { - minimizeBox = value; - } - } - - [MonoTODO] - public Size MinimumSize { - get { - return maximumSize; - } - set { - maximumSize = value; - } - } - - [MonoTODO] - public bool Modal { - get { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public double Opacity { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Form[] OwnedForms { - get { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Form Owner { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public bool ShowInTaskbar { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - - public override ISite Site { - get { - return base.Site; - } - set { - base.Site = value; - } - } - - [MonoTODO] - public SizeGripStyle SizeGripStyle { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public FormStartPosition StartPosition { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public bool TopLevel { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public bool TopMost { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - [MonoTODO] - public Color TransparencyKey { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - - //Compact Framework - [MonoTODO] - public FormWindowState WindowState { - get { - WINDOWPLACEMENT placement = new WINDOWPLACEMENT(); - - //bool ReturnValue = Win32.GetWindowPlacement(Handle, ref placement ) ; - //if(placement.showCmd == SW_MINIMIZE){ - // return FormWindowState.Minimized; - //} - //if(placement.showCmd == SW_MAXIMIZE){ - // return FormWindowState.Maximized; - //} - return FormWindowState.Normal; - //Other options such as hide are possible in win32, but not in this part of .NET - // also this may not work because it looks like showCmd is for setting, and might not be set - // by win32 in a get. - } - set { - throw new NotImplementedException (); - } - } - - - // --- Public Methods - public void Activate () - { - Win32.SetActiveWindow (Handle); - } - - [MonoTODO] - public void AddOwnedForm (Form ownedForm) - { - throw new NotImplementedException (); - } - - //Compact Framework - public void Close () - { - Win32.CloseWindow (Handle); - } - - //inherited - //public void Dispose () - //{ - // throw new NotImplementedException (); - //} - //public static bool Equals (object o1, object o2) - //{ - // throw new NotImplementedException (); - //} [MonoTODO] - - //public override bool Equals (object o) - //{ - // throw new NotImplementedException (); - //} - - - //[MonoTODO] - //public override int GetHashCode () { - // return base.GetHashCode (); - //} - - //[MonoTODO] - // Font class not implemented or stubbed - //public static SizeF GetAutoScaleSize(Font font) - //{ - // throw new NotImplementedException (); - //} - - //public void Invalidate() - //{ - // throw new NotImplementedException (); - //} - - //public object Invoke() - //{ - // throw new NotImplementedException (); - //} - - //public void PerformLayout() - //{ - // throw new NotImplementedException (); - //} - - [MonoTODO] - public void LayoutMdi (MdiLayout value) - { - throw new NotImplementedException (); - } - - [MonoTODO] - public void RemoveOwnedForm (Form ownedForm) - { - throw new NotImplementedException (); - } - - // public void ResumeLayout() - // { - // throw new NotImplementedException (); - // } - // - // public void Scale(float f) - // { - // throw new NotImplementedException (); - // } - // - // public void Select() - // { - // throw new NotImplementedException (); - // } - // - // public void SetBounds(int x, int y, int width, int height) - // { - // throw new NotImplementedException (); - // } - - public void SetDesktopLocation (int x, int y) - { - Win32.SetWindowPos ((IntPtr) Handle, (IntPtr) 0, - x, y, 0, 0, - (int) (SetWindowPosFlags.SWP_NOSIZE | - SetWindowPosFlags.SWP_NOZORDER)); - } - - //inherited from control - //public new void Show () - //{ - // Win32.ShowWindow (Handle, (int) Win32.SW_SHOW); - //} - - [MonoTODO] - public DialogResult ShowDialog () - { - Win32.ShowWindow (Handle, ShowWindowStyles.SW_SHOW); - return new DialogResult(); - } - - //Compact Framework - [MonoTODO] - public override string ToString () - { - return base.ToString(); - } - - // --- Public Events - - public event EventHandler Activated; - - public event EventHandler Closed; - - //Compact Framework - // CancelEventHandler not yet implemented/stubbed - //public event CancelEventHandler Closing; - - public event EventHandler Deactivate; - public event InputLanguageChangedEventHandler InputLanguageChanged; - public event InputLanguageChangingEventHandler InputLanguageChanging; - - //Compact Framework - public event EventHandler Load; - - public event EventHandler MaximizedBoundsChanged; - public event EventHandler MaximumSizeChanged; - public event EventHandler MdiChildActivate; - public event EventHandler MenuComplete; - public event EventHandler MenuStart; - public event EventHandler MinimumSizedChanged; - - - // --- Protected Properties - - protected override CreateParams CreateParams { - get { - return base.CreateParams; - } - } - - protected override ImeMode DefaultImeMode { - get { - return base.DefaultImeMode; - } - } - - //[MonoTODO] - FIXME - //protected override Size DefaultSize { - //} - - //[MonoTODO] - //public new Size Size { - // get { - // throw new NotImplementedException (); - // } - // set { - // throw new NotImplementedException (); - // } - //} - - [MonoTODO] - protected Rectangle MaximizedBounds { - get { - throw new NotImplementedException (); - } - set { - throw new NotImplementedException (); - } - } - - - // --- Protected Methods - - protected override void AdjustFormScrollbars ( - bool displayScrollbars) - { - base.AdjustFormScrollbars (displayScrollbars); - } - - protected override Control.ControlCollection - CreateControlsInstance () - { - return base.CreateControlsInstance (); - } - - protected override void CreateHandle () - { - base.CreateHandle (); - - if (IsHandleCreated) - OnHandleCreated (new EventArgs()); - } - - protected override void DefWndProc (ref Message m) - { - window.DefWndProc (ref m); - } - - //protected override void Dispose(bool disposing) - //{ - // throw new NotImplementedException (); - //} - - //Compact Framework - protected virtual void OnClosed (EventArgs e) - { - if (Closed != null) - Closed (this, e); - } - - //Compact Framework - [MonoTODO] - protected virtual void OnClosing(CancelEventArgs e) - { - throw new NotImplementedException (); - } - - protected override void OnCreateControl () - { - base.OnCreateControl (); - } - - protected override void OnFontChanged (EventArgs e) - { - base.OnFontChanged (e); - } - - protected override void OnHandleCreated (EventArgs e) - { - Console.WriteLine ("OnHandleCreated"); - assignMenu(); - base.OnHandleCreated (e); - } - - protected override void OnHandleDestroyed (EventArgs e) - { - base.OnHandleDestroyed (e); - } - - protected virtual void OnInputLanguageChanged ( - InputLanguageChangedEventArgs e) - { - if (InputLanguageChanged != null) - InputLanguageChanged (this, e); - } - - protected virtual void OnInputLanguagedChanging ( - InputLanguageChangingEventArgs e) - { - if (InputLanguageChanging != null) - InputLanguageChanging (this, e); - } - - //Compact Framework - protected virtual void OnLoad (EventArgs e) - { - if (Load != null) - Load (this, e); - } - - protected virtual void OnMaximizedBoundsChanged (EventArgs e) - { - if (MaximizedBoundsChanged != null) - MaximizedBoundsChanged (this, e); - } - - protected virtual void OnMaximumSizeChanged (EventArgs e) - { - if (MaximumSizeChanged != null) - MaximumSizeChanged (this, e); - } - - protected virtual void OnMdiChildActivate (EventArgs e) - { - if (MdiChildActivate != null) - MdiChildActivate (this, e); - } - - protected virtual void OnMenuComplete (EventArgs e) - { - if (MenuComplete != null) - MenuComplete (this, e); - } - - protected virtual void OnMenuStart (EventArgs e) - { - if (MenuStart != null) - MenuStart (this, e); - } - - protected virtual void OnMinimumSizeChanged (EventArgs e) - { - - } - - //Compact Framework - protected override void OnPaint (PaintEventArgs e) - { - base.OnPaint (e); - } - - //Compact Framework - protected override void OnResize (EventArgs e) - { - base.OnResize (e); - } - - protected override void OnStyleChanged (EventArgs e) - { - base.OnStyleChanged (e); - } - - //Compact Framework - protected override void OnTextChanged (EventArgs e) - { - base.OnTextChanged (e); - } - - protected override void OnVisibleChanged (EventArgs e) - { - base.OnVisibleChanged (e); - } - - protected virtual IntPtr OnMenuCommand (uint id) - { - //base.OnVisibleChanged (e); - System.Console.WriteLine("Form on command {0}", id); - if(Menu != null) { - MenuItem mi = Menu.GetMenuItemByID( id); - if( mi != null) { - mi.PerformClick(); - } - } - return IntPtr.Zero; - } - - protected virtual IntPtr OnWmCommand (ref Message m) - { - uint wNotifyCode = (uint) ( ((uint)m.WParam.ToInt32() & 0xFFFF0000) >> 16); - uint wID = (uint)(m.WParam.ToInt32() & 0x0000FFFFL); - if( m.LParam.ToInt32() == 0) { - if( wNotifyCode == 0) { - // Menu - return OnMenuCommand(wID); - } - else if( wNotifyCode == 1) { - // Accelerator - } - } - else { - // Control notification - System.Console.WriteLine("Control notification Code {0} Id {1} Hwnd {2}", wNotifyCode, wID, m.LParam.ToInt32()); - } - return new IntPtr(1); - } - - protected override bool ProcessCmdKey ( ref Message msg, Keys keyData) - { - return base.ProcessCmdKey (ref msg, keyData); - } - - protected override bool ProcessDialogKey (Keys keyData) - { - return base.ProcessDialogKey (keyData); - } - - protected override bool ProcessKeyPreview (ref Message m) - { - return base.ProcessKeyPreview (ref m); - } - - protected override bool ProcessTabKey (bool forward) - { - return base.ProcessTabKey (forward); - } - - protected override void ScaleCore (float x, float y) - { - base.ScaleCore (x, y); - } - - protected override void SetBoundsCore ( - int x, int y, int width, int height, - BoundsSpecified specified) - { - base.SetBoundsCore (x, y, width, height, specified); - } - - protected override void SetClientSizeCore (int x, int y) - { - base.SetClientSizeCore (x, y); - } - - protected override void SetVisibleCore (bool value) - { - base.SetVisibleCore (value); - } - - //public void Select(bool b1, bool b2) - //{ - // throw new NotImplementedException (); - //} - - //protected void UpdateBounds() - //{ - // throw new NotImplementedException (); - //} - - protected override void WndProc (ref Message m) - { - base.WndProc (ref m); - - switch (m.Msg) { - case (int)Msg.WM_CLOSE: - EventArgs closeArgs = new EventArgs(); - OnClosed (closeArgs); - break; - //case ?: - //OnCreateControl() - //break; - case (int)Msg.WM_FONTCHANGE: - EventArgs fontChangedArgs = new EventArgs(); - OnFontChanged (fontChangedArgs); - break; - case (int)Msg.WM_CREATE: - EventArgs handleCreatedArgs = new EventArgs(); - OnHandleCreated (handleCreatedArgs); - break; - case (int)Msg.WM_DESTROY: - EventArgs destroyArgs = new EventArgs(); - OnHandleDestroyed (destroyArgs); - break; - case (int)Msg.WM_INPUTLANGCHANGE: - //InputLanguageChangedEventArgs ilChangedArgs = - // new InputLanguageChangedEventArgs(); - //OnInputLanguageChanged (ilChangedArgs); - break; - case (int)Msg.WM_INPUTLANGCHANGEREQUEST: - //InputLanguageChangingEventArgs ilChangingArgs = - // new InputLanguageChangingEventArgs(); - //OnInputLanguagedChanging (ilChangingArgs); - break; - /* - case Win32.WM_SHOWWINDOW: - EventArgs e; - OnLoad (e); - break; - */ - // case ?: - // OnMaximizedBoundsChanged(EventArgs e) - // break; - // case ?: - // OnMaximumSizedChanged(EventArgs e) - //break; - case (int)Msg.WM_MDIACTIVATE: - EventArgs mdiActivateArgs = new EventArgs(); - OnMdiChildActivate (mdiActivateArgs); - break; - case (int)Msg.WM_EXITMENULOOP: - EventArgs menuCompleteArgs = new EventArgs(); - OnMenuComplete (menuCompleteArgs); - break; - case (int)Msg.WM_ENTERMENULOOP: - EventArgs enterMenuLoopArgs = new EventArgs(); - OnMenuStart (enterMenuLoopArgs); - break; - // case ?: - // OnMinimumSizeChanged(EventArgs e) - // break; - case (int)Msg.WM_PAINT: - //PaintEventArgs paintArgs = new PaintEventArgs(); - //OnPaint (paintArgs); - break; - case (int)Msg.WM_SIZE: - EventArgs resizeArgs = new EventArgs(); - OnResize (resizeArgs); - break; - //case ?: - //OnStyleChanged(EventArgs e) - //break; - case (int)Msg.WM_SETTEXT: - EventArgs textChangedArgs = new EventArgs(); - OnTextChanged (textChangedArgs); - break; - case (int)Msg.WM_SHOWWINDOW: - EventArgs visibleChangedArgs = new EventArgs(); - OnVisibleChanged (visibleChangedArgs); - break; - case (int)Msg.WM_COMMAND: - OnWmCommand (ref m); - break; - } - } - - //sub class - //System.Windows.Forms.Form.ControlCollection.cs - // - //Author: - // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu) - // - // (C) 2002 Ximian, Inc - // - // - // <summary> - // This is only a template. Nothing is implemented yet. - // - // </summary> - // TODO: implement support classes and derive from - // proper classes - // FIXME: use this or the one defined on Control? - public class ControlCollectionX : - System.Windows.Forms.Control.ControlCollection - /*,ICollection*/ { - - // --- Constructor - // base class not defined (yet!) - public ControlCollectionX (Form owner) : base(owner) { - - } - - // --- Public Methods - - // TODO: see what causes this compile error - public override void Add(Control value) { - base.Add (value); - } - - public override bool Equals (object o) { - throw new NotImplementedException (); - } - - //public static bool Equals(object o1, object o2) { - // throw new NotImplementedException (); - //} - - public override int GetHashCode () { - //FIXME add our proprities - return base.GetHashCode (); - } - - //public override int GetChildIndex(Control c) { - //return base.GetChildIndex (c); - //} - - public override void Remove(Control value) { - base.Remove (value); - } - } // end of Subclass - } - } + // + // System.Windows.Forms.Form + // + // Author: + // Miguel de Icaza (miguel@ximian.com) + // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu) + // Dennis Hayes (dennish@raytek.com) + // WINELib implementation started by John Sohn (jsohn@columbus.rr.com) + // + // (C) 2002 Ximian, Inc + // + + using System; + using System.Drawing; + using System.ComponentModel; + using System.Collections; + + namespace System.Windows.Forms { + + public class Form : ContainerControl { + DialogResult dialogResult; + Size maximumSize; + Size minimizeSize; + + // Temperary varibles that may be replaced + // with win32 functions + + // owner draw + private bool controlBox; + private bool minimizeBox; + private bool maximizeBox; + private bool helpButton; + //end owner draw + + FormBorderStyle formBorderStyle; + + // End of temperay varibles + + public Form () : base () + { + } + + static Form () + { + + } + + // --- Public Properties + // + [MonoTODO] + public IButtonControl AcceptButton { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public static Form ActiveForm { + get { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Form ActiveMdiChild { + get { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public bool AutoScale { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public virtual Size AutoScaleBaseSize { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + public override bool AutoScroll { + get { + return base.AutoScroll; + } + set { + base.AutoScroll = value; + } + } + + public override Color BackColor { + get { + return base.BackColor; + } + set { + base.BackColor = value; + } + } + + [MonoTODO] + public IButtonControl CancelButton { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public new Size ClientSize { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + //Compact Framework + //FIXME: + // In .NET this can be changed at any time. + // In WIN32 this is fixed when the window is created. + // In WIN32 to change this after the window is created, + // like in .NET, we must draw the caption bar our self. + // In the mean time, just set/return a bool. + // This might be the start of the drawing + [MonoTODO] + public bool ControlBox { + get { + return controlBox; + } + set { + controlBox = value; + //force paint + } + } + + [MonoTODO] + public Rectangle DesktopBounds { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Point DesktopLocation { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + //Compact Framework + [MonoTODO] + public DialogResult DialogResult { + get { + return dialogResult; + } + set { + dialogResult = value; + } + } + + //Compact Framework + [MonoTODO] + public FormBorderStyle FormBorderStyle { + get { + return formBorderStyle; + } + set { + formBorderStyle = value; + } + } + + [MonoTODO] + public bool HelpButton { + get { + return helpButton; + } + set { + helpButton = value; + } + } + + //Compact Framework + //[MonoTODO] + public Icon Icon { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public bool IsMidiChild { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public bool IsMidiContainer { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public bool KeyPreview { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + //Compact Framework + [MonoTODO] + public bool MaximizeBox { + get { + return maximizeBox; + } + set { + maximizeBox = value; + } + } + + [MonoTODO] + public Size MaximumSize { + get { + return maximumSize; + } + set { + maximumSize = value; + } + } + + [MonoTODO] + public Form[] MdiChildren { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Form MdiParent { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + //Compact Framework + //[MonoTODO] + private MainMenu mainMenu_ = null; + + private void assignMenu() + { + if( Handle != IntPtr.Zero ) { + // FIXME: If Form's window has no style for menu, probably, better to add it + // if menu have to be removed, remove the style. + // Attention to the repainting. +// if( mainMenu_ != null) { +// //long myStyle = Win32.GetWindowLongA( Handle, Win32.GWL_STYLE); +// //myStyle |= (long)Win32.WS_OVERLAPPEDWINDOW; +// //Win32.SetWindowLongA( Handle, Win32.GWL_STYLE, myStyle); +// SetMenu( Handle, mainMenu_.Handle); +// } +// else { +// SetMenu( Handle, IntPtr.Zero); +// } + } + } + + public MainMenu Menu { + get { + return mainMenu_; + } + set { + mainMenu_ = value; + assignMenu(); + } + } + + //[MonoTODO] + //public MainMenu MergedMenu { + // get { + // throw new NotImplementedException (); + // } + //} + + //Compact Framework + [MonoTODO] + public bool MinimizeBox { + get { + return minimizeBox; + } + set { + minimizeBox = value; + } + } + + [MonoTODO] + public Size MinimumSize { + get { + return maximumSize; + } + set { + maximumSize = value; + } + } + + [MonoTODO] + public bool Modal { + get { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public double Opacity { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Form[] OwnedForms { + get { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Form Owner { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public bool ShowInTaskbar { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + + public override ISite Site { + get { + return base.Site; + } + set { + base.Site = value; + } + } + + [MonoTODO] + public SizeGripStyle SizeGripStyle { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public FormStartPosition StartPosition { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public bool TopLevel { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public bool TopMost { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + [MonoTODO] + public Color TransparencyKey { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + + //Compact Framework + [MonoTODO] + public FormWindowState WindowState { + get { + WINDOWPLACEMENT placement = new WINDOWPLACEMENT(); + + //bool ReturnValue = Win32.GetWindowPlacement(Handle, ref placement ) ; + //if(placement.showCmd == SW_MINIMIZE){ + // return FormWindowState.Minimized; + //} + //if(placement.showCmd == SW_MAXIMIZE){ + // return FormWindowState.Maximized; + //} + return FormWindowState.Normal; + //Other options such as hide are possible in win32, but not in this part of .NET + // also this may not work because it looks like showCmd is for setting, and might not be set + // by win32 in a get. + } + set { + throw new NotImplementedException (); + } + } + + + // --- Public Methods + public void Activate () + { + Win32.SetActiveWindow (Handle); + } + + [MonoTODO] + public void AddOwnedForm (Form ownedForm) + { + throw new NotImplementedException (); + } + + //Compact Framework + public void Close () + { + Win32.CloseWindow (Handle); + } + + //inherited + //public void Dispose () + //{ + // throw new NotImplementedException (); + //} + //public static bool Equals (object o1, object o2) + //{ + // throw new NotImplementedException (); + //} [MonoTODO] + + //public override bool Equals (object o) + //{ + // throw new NotImplementedException (); + //} + + + //[MonoTODO] + //public override int GetHashCode () { + // return base.GetHashCode (); + //} + + //[MonoTODO] + // Font class not implemented or stubbed + //public static SizeF GetAutoScaleSize(Font font) + //{ + // throw new NotImplementedException (); + //} + + //public void Invalidate() + //{ + // throw new NotImplementedException (); + //} + + //public object Invoke() + //{ + // throw new NotImplementedException (); + //} + + //public void PerformLayout() + //{ + // throw new NotImplementedException (); + //} + + [MonoTODO] + public void LayoutMdi (MdiLayout value) + { + throw new NotImplementedException (); + } + + [MonoTODO] + public void RemoveOwnedForm (Form ownedForm) + { + throw new NotImplementedException (); + } + + // public void ResumeLayout() + // { + // throw new NotImplementedException (); + // } + // + // public void Scale(float f) + // { + // throw new NotImplementedException (); + // } + // + // public void Select() + // { + // throw new NotImplementedException (); + // } + // + // public void SetBounds(int x, int y, int width, int height) + // { + // throw new NotImplementedException (); + // } + + public void SetDesktopLocation (int x, int y) + { + Win32.SetWindowPos ((IntPtr) Handle, (IntPtr) 0, + x, y, 0, 0, + (int) (SetWindowPosFlags.SWP_NOSIZE | + SetWindowPosFlags.SWP_NOZORDER)); + } + + //inherited from control + //public new void Show () + //{ + // Win32.ShowWindow (Handle, (int) Win32.SW_SHOW); + //} + + [MonoTODO] + public DialogResult ShowDialog () + { + Win32.ShowWindow (Handle, ShowWindowStyles.SW_SHOW); + return new DialogResult(); + } + + //Compact Framework + [MonoTODO] + public override string ToString () + { + return base.ToString(); + } + + // --- Public Events + + public event EventHandler Activated; + + public event EventHandler Closed; + + //Compact Framework + // CancelEventHandler not yet implemented/stubbed + //public event CancelEventHandler Closing; + + public event EventHandler Deactivate; + public event InputLanguageChangedEventHandler InputLanguageChanged; + public event InputLanguageChangingEventHandler InputLanguageChanging; + + //Compact Framework + public event EventHandler Load; + + public event EventHandler MaximizedBoundsChanged; + public event EventHandler MaximumSizeChanged; + public event EventHandler MdiChildActivate; + public event EventHandler MenuComplete; + public event EventHandler MenuStart; + public event EventHandler MinimumSizedChanged; + + + // --- Protected Properties + + protected override CreateParams CreateParams { + get { + return base.CreateParams; + } + } + + protected override ImeMode DefaultImeMode { + get { + return base.DefaultImeMode; + } + } + + //[MonoTODO] + FIXME + //protected override Size DefaultSize { + //} + + //[MonoTODO] + //public new Size Size { + // get { + // throw new NotImplementedException (); + // } + // set { + // throw new NotImplementedException (); + // } + //} + + [MonoTODO] + protected Rectangle MaximizedBounds { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + + // --- Protected Methods + + protected override void AdjustFormScrollbars ( + bool displayScrollbars) + { + base.AdjustFormScrollbars (displayScrollbars); + } + + protected override Control.ControlCollection + CreateControlsInstance () + { + return base.CreateControlsInstance (); + } + + protected override void CreateHandle () + { + base.CreateHandle (); + + if (IsHandleCreated) + OnHandleCreated (new EventArgs()); + } + + protected override void DefWndProc (ref Message m) + { + window.DefWndProc (ref m); + } + + //protected override void Dispose(bool disposing) + //{ + // throw new NotImplementedException (); + //} + + //Compact Framework + protected virtual void OnClosed (EventArgs e) + { + if (Closed != null) + Closed (this, e); + } + + //Compact Framework + [MonoTODO] + protected virtual void OnClosing(CancelEventArgs e) + { + throw new NotImplementedException (); + } + + protected override void OnCreateControl () + { + base.OnCreateControl (); + } + + protected override void OnFontChanged (EventArgs e) + { + base.OnFontChanged (e); + } + + protected override void OnHandleCreated (EventArgs e) + { + Console.WriteLine ("OnHandleCreated"); + assignMenu(); + base.OnHandleCreated (e); + } + + protected override void OnHandleDestroyed (EventArgs e) + { + base.OnHandleDestroyed (e); + } + + protected virtual void OnInputLanguageChanged ( + InputLanguageChangedEventArgs e) + { + if (InputLanguageChanged != null) + InputLanguageChanged (this, e); + } + + protected virtual void OnInputLanguagedChanging ( + InputLanguageChangingEventArgs e) + { + if (InputLanguageChanging != null) + InputLanguageChanging (this, e); + } + + //Compact Framework + protected virtual void OnLoad (EventArgs e) + { + if (Load != null) + Load (this, e); + } + + protected virtual void OnMaximizedBoundsChanged (EventArgs e) + { + if (MaximizedBoundsChanged != null) + MaximizedBoundsChanged (this, e); + } + + protected virtual void OnMaximumSizeChanged (EventArgs e) + { + if (MaximumSizeChanged != null) + MaximumSizeChanged (this, e); + } + + protected virtual void OnMdiChildActivate (EventArgs e) + { + if (MdiChildActivate != null) + MdiChildActivate (this, e); + } + + protected virtual void OnMenuComplete (EventArgs e) + { + if (MenuComplete != null) + MenuComplete (this, e); + } + + protected virtual void OnMenuStart (EventArgs e) + { + if (MenuStart != null) + MenuStart (this, e); + } + + protected virtual void OnMinimumSizeChanged (EventArgs e) + { + + } + + //Compact Framework + protected override void OnPaint (PaintEventArgs e) + { + base.OnPaint (e); + } + + //Compact Framework + protected override void OnResize (EventArgs e) + { + base.OnResize (e); + } + + protected override void OnStyleChanged (EventArgs e) + { + base.OnStyleChanged (e); + } + + //Compact Framework + protected override void OnTextChanged (EventArgs e) + { + base.OnTextChanged (e); + } + + protected override void OnVisibleChanged (EventArgs e) + { + base.OnVisibleChanged (e); + } + + protected virtual IntPtr OnMenuCommand (uint id) + { + //base.OnVisibleChanged (e); + System.Console.WriteLine("Form on command {0}", id); + if(Menu != null) { + MenuItem mi = Menu.GetMenuItemByID( id); + if( mi != null) { + mi.PerformClick(); + } + } + return IntPtr.Zero; + } + + protected virtual IntPtr OnWmCommand (ref Message m) + { + uint wNotifyCode = (uint) ( ((uint)m.WParam.ToInt32() & 0xFFFF0000) >> 16); + uint wID = (uint)(m.WParam.ToInt32() & 0x0000FFFFL); + if( m.LParam.ToInt32() == 0) { + if( wNotifyCode == 0) { + // Menu + return OnMenuCommand(wID); + } + else if( wNotifyCode == 1) { + // Accelerator + } + } + else { + // Control notification + System.Console.WriteLine("Control notification Code {0} Id {1} Hwnd {2}", wNotifyCode, wID, m.LParam.ToInt32()); + } + return new IntPtr(1); + } + + protected override bool ProcessCmdKey ( ref Message msg, Keys keyData) + { + return base.ProcessCmdKey (ref msg, keyData); + } + + protected override bool ProcessDialogKey (Keys keyData) + { + return base.ProcessDialogKey (keyData); + } + + protected override bool ProcessKeyPreview (ref Message m) + { + return base.ProcessKeyPreview (ref m); + } + + protected override bool ProcessTabKey (bool forward) + { + return base.ProcessTabKey (forward); + } + + protected override void ScaleCore (float x, float y) + { + base.ScaleCore (x, y); + } + + protected override void SetBoundsCore ( + int x, int y, int width, int height, + BoundsSpecified specified) + { + base.SetBoundsCore (x, y, width, height, specified); + } + + protected override void SetClientSizeCore (int x, int y) + { + base.SetClientSizeCore (x, y); + } + + protected override void SetVisibleCore (bool value) + { + base.SetVisibleCore (value); + } + + //public void Select(bool b1, bool b2) + //{ + // throw new NotImplementedException (); + //} + + //protected void UpdateBounds() + //{ + // throw new NotImplementedException (); + //} + + protected override void WndProc (ref Message m) + { + base.WndProc (ref m); + + switch (m.Msg) { + case (int)Msg.WM_CLOSE: + EventArgs closeArgs = new EventArgs(); + OnClosed (closeArgs); + break; + //case ?: + //OnCreateControl() + //break; + case (int)Msg.WM_FONTCHANGE: + EventArgs fontChangedArgs = new EventArgs(); + OnFontChanged (fontChangedArgs); + break; + case (int)Msg.WM_CREATE: + EventArgs handleCreatedArgs = new EventArgs(); + OnHandleCreated (handleCreatedArgs); + break; + case (int)Msg.WM_DESTROY: + EventArgs destroyArgs = new EventArgs(); + OnHandleDestroyed (destroyArgs); + break; + case (int)Msg.WM_INPUTLANGCHANGE: + //InputLanguageChangedEventArgs ilChangedArgs = + // new InputLanguageChangedEventArgs(); + //OnInputLanguageChanged (ilChangedArgs); + break; + case (int)Msg.WM_INPUTLANGCHANGEREQUEST: + //InputLanguageChangingEventArgs ilChangingArgs = + // new InputLanguageChangingEventArgs(); + //OnInputLanguagedChanging (ilChangingArgs); + break; + /* + case Win32.WM_SHOWWINDOW: + EventArgs e; + OnLoad (e); + break; + */ + // case ?: + // OnMaximizedBoundsChanged(EventArgs e) + // break; + // case ?: + // OnMaximumSizedChanged(EventArgs e) + //break; + case (int)Msg.WM_MDIACTIVATE: + EventArgs mdiActivateArgs = new EventArgs(); + OnMdiChildActivate (mdiActivateArgs); + break; + case (int)Msg.WM_EXITMENULOOP: + EventArgs menuCompleteArgs = new EventArgs(); + OnMenuComplete (menuCompleteArgs); + break; + case (int)Msg.WM_ENTERMENULOOP: + EventArgs enterMenuLoopArgs = new EventArgs(); + OnMenuStart (enterMenuLoopArgs); + break; + // case ?: + // OnMinimumSizeChanged(EventArgs e) + // break; + case (int)Msg.WM_PAINT: + //PaintEventArgs paintArgs = new PaintEventArgs(); + //OnPaint (paintArgs); + break; + case (int)Msg.WM_SIZE: + EventArgs resizeArgs = new EventArgs(); + OnResize (resizeArgs); + break; + //case ?: + //OnStyleChanged(EventArgs e) + //break; + case (int)Msg.WM_SETTEXT: + EventArgs textChangedArgs = new EventArgs(); + OnTextChanged (textChangedArgs); + break; + case (int)Msg.WM_SHOWWINDOW: + EventArgs visibleChangedArgs = new EventArgs(); + OnVisibleChanged (visibleChangedArgs); + break; + case (int)Msg.WM_COMMAND: + OnWmCommand (ref m); + break; + } + } + + //sub class + //System.Windows.Forms.Form.ControlCollection.cs + // + //Author: + // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu) + // + // (C) 2002 Ximian, Inc + // + // + // <summary> + // This is only a template. Nothing is implemented yet. + // + // </summary> + // TODO: implement support classes and derive from + // proper classes + // FIXME: use this or the one defined on Control? + public class ControlCollectionX : + System.Windows.Forms.Control.ControlCollection + /*,ICollection*/ { + + // --- Constructor + // base class not defined (yet!) + public ControlCollectionX (Form owner) : base(owner) { + + } + + // --- Public Methods + + // TODO: see what causes this compile error + public override void Add(Control value) { + base.Add (value); + } + + public override bool Equals (object o) { + throw new NotImplementedException (); + } + + //public static bool Equals(object o1, object o2) { + // throw new NotImplementedException (); + //} + + public override int GetHashCode () { + //FIXME add our proprities + return base.GetHashCode (); + } + + //public override int GetChildIndex(Control c) { + //return base.GetChildIndex (c); + //} + + public override void Remove(Control value) { + base.Remove (value); + } + } // end of Subclass + } + }

     

    Previous message: [Mono-patches] mcs/mcs ChangeLog,1.888,1.889 class.cs,1.305,1.306 ecore.cs,1.186,1.187 expression.cs,1.383,1.384 typemanager.cs,1.200,1.201 Next message: [Mono-patches] mcs/class/System.XML/System.Xml XmlImplementation.cs,1.6,1.7 ChangeLog,1.138,1.139 Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]  

    最新回复(0)