Ejemplo n.º 1
0
 private IntPtr ReplacementWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
 {
     if (msg == (uint)Win32.WM_LBUTTONDOWN || msg == (uint)Win32.WM_LBUTTONDBLCLK)
     {
         Win32.POINT loc = new Win32.POINT();
         loc.X = MousePosition.X;
         loc.Y = MousePosition.Y;
         Win32.ScreenToClient(DropDownHandle, ref loc);
         Win32.RECT dropdown_rect = new Win32.RECT();
         Win32.GetClientRect(DropDownHandle, out dropdown_rect);
         if (dropdown_rect.Left <= loc.X && loc.X < dropdown_rect.Right && dropdown_rect.Top <= loc.Y && loc.Y < dropdown_rect.Bottom)
         {
             int index = (int)Win32.SendMessage(DropDownHandle, Win32.LB_ITEMFROMPOINT, IntPtr.Zero, (IntPtr)(loc.X + (loc.Y << 16)));
             if (index >> 16 == 0)
             {
                 Object o = Items[index];
                 if (o is ToStringWrapper<SR>)
                     return IntPtr.Zero;
             }
         }
     }
     return Win32.CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam);
 }
Ejemplo n.º 2
0
        private IntPtr HookProc(IntPtr hdlg, int msg, IntPtr wParam, IntPtr lParam)
        {
            switch (msg)
            {
                case Win32.WM_INITDIALOG:
                    // Center the dialog on its owner
                    Win32.RECT sr = new Win32.RECT();
                    Win32.RECT cr = new Win32.RECT();
                    IntPtr parent = Win32.GetParent(hdlg);
                    Win32.GetWindowRect(parent, ref cr);

                    Win32.GetWindowRect(Owner.Handle, ref sr);

                    int x = (sr.Right + sr.Left - (cr.Right - cr.Left)) / 2;
                    int y = (sr.Bottom + sr.Top - (cr.Bottom - cr.Top)) / 2;

                    Win32.SetWindowPos(parent, IntPtr.Zero, x, y, cr.Right - cr.Left, cr.Bottom - cr.Top + 32, Win32.SWP_NOZORDER);

                    IntPtr fileTypeWindow = Win32.GetDlgItem(parent, 0x441);
                    IntPtr fontHandle = Win32.SendMessage(fileTypeWindow, Win32.WM_GETFONT, IntPtr.Zero, IntPtr.Zero);

                    //we now need to find the combo-box to position the new tick box under

                    IntPtr fileComboWindow = Win32.GetDlgItem(parent, 0x470);
                    Win32.RECT aboveRect = new Win32.RECT();
                    Win32.GetWindowRect(fileComboWindow, ref aboveRect);

                    Win32.POINT point = new Win32.POINT();
                    point.X = aboveRect.Left;
                    point.Y = aboveRect.Bottom;
                    Win32.ScreenToClient(parent, ref point);

                    Win32.POINT rightPoint = new Win32.POINT();
                    rightPoint.X = aboveRect.Right;
                    rightPoint.Y = aboveRect.Top;

                    Win32.ScreenToClient(parent, ref rightPoint);

                    //we create the new combobox

                    IntPtr comboHandle = Win32.CreateWindowEx(0, "BUTTON", "", Win32.WS_VISIBLE | Win32.WS_CHILD | Win32.WS_TABSTOP | Win32.BS_AUTOCHECKBOX, point.X, point.Y + 8, rightPoint.X - point.X, 16, parent, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                    fontHandle = Win32.SendMessage(fileTypeWindow, Win32.WM_GETFONT, IntPtr.Zero, IntPtr.Zero);

                    Win32.SendMessage(comboHandle, Win32.WM_SETFONT, fontHandle, IntPtr.Zero);
                    Win32.SendMessage(comboHandle, Win32.WM_SETTEXT, IntPtr.Zero, Messages.EXPORT_VM_VERIFY_POST_INSTALL);
                    Win32.SendMessage(comboHandle, Win32.BM_SETCHECK, (IntPtr)(Verify ? Win32.BST_CHECKED : Win32.BST_UNCHECKED), IntPtr.Zero);

                    //remember the handles of the controls we have created so we can destroy them after
                    ComboHandle = comboHandle;
                    break;

                case Win32.WM_DESTROY:
                    //destroy the handles we have created
                    if (ComboHandle != IntPtr.Zero)
                    {
                        Win32.DestroyWindow(ComboHandle);
                    }
                    break;

                case Win32.WM_NOTIFY:

                    //we need to intercept the CDN_FILEOK message
                    //which is sent when the user selects a filename

                    Win32.NMHDR nmhdr = (Win32.NMHDR)Marshal.PtrToStructure(lParam, typeof(Win32.NMHDR));

                    if (nmhdr.code == Win32.CDN_FILEOK)
                    {
                        Verify = Win32.SendMessage(ComboHandle, Win32.BM_GETCHECK, IntPtr.Zero, IntPtr.Zero) == (IntPtr)Win32.BST_CHECKED;
                    }
                    else if (nmhdr.code == Win32.CDN_HELP)
                    {
                        Help.HelpManager.Launch("ExportVMDialog");
                    }
                    break;
            }
            return IntPtr.Zero;
        }