private void DisplayUndockableContextMenu(IntPtr handle, IntPtr lParam) { if (_menuHandle == IntPtr.Zero) { _menuHandle = NativeMethods.CreatePopupMenu(); if (_menuHandle == IntPtr.Zero) { _logger.Warn("Cannot create menu handle"); return; } if (!NativeMethods.InsertMenu(_menuHandle, 0, MF_BYPOSITION, (UIntPtr)WM.RUBBERDUCK_UNDOCKABLE_CONTEXT_MENU, "Dockable" + char.MinValue)) { _logger.Warn("Failed to insert a menu item for dockable command"); } } var param = new LParam { Value = (uint)lParam }; if (!NativeMethods.TrackPopupMenuEx(_menuHandle, 0x0, param.LowWord, param.HighWord, handle, IntPtr.Zero)) { _logger.Warn("Failed to set the context menu for undockable tool windows"); } ; }
public unsafe static extern int LCMapStringEx( char *lpLocaleName, LocaleMapFlags dwMapFlags, char *lpSrcStr, int cchSrc, char *lpDestStr, int cchDest, NlsVersionInfoExtended *lpVersionInformation, void *lpReserved, LParam sortHandle);
/// <summary> /// Gets a hash code for the message. /// </summary> /// <returns>Hash code for this message.</returns> public override int GetHashCode() { int hash = WindowHandle.GetHashCode(); hash = hash * 31 + Msg.GetHashCode(); hash = hash * 31 + WParam.GetHashCode(); hash = hash * 31 + LParam.GetHashCode(); hash = hash * 31 + Time.GetHashCode(); hash = hash * 31 + Point.GetHashCode(); return(hash); }
private void OnCallBackEvent(object sender, SubClassingWindowEventArgs e) { if (!e.Closing) { var param = new LParam { Value = (uint)e.LParam }; Size = new Size(param.LowWord, param.HighWord); } else { Debug.WriteLine("DockableWindowHost removed event handler."); _subClassingWindow.CallBackEvent -= OnCallBackEvent; } }
bool OnWM_MESSAGE256(ref System.Windows.Interop.MSG msg, ref bool handled) { // // add extra variables to observe with Debugger // IntPtr HWND, WParam, LParam; HWND = msg.hwnd; WParam = msg.wParam; LParam = msg.lParam; this.txt_HWND.Text = HWND.ToString(); this.txt_WParam.Text = WParam.ToString(); this.txt_LParam.Text = LParam.ToString(); this.txt_KeyData.Text = KeyInterop.KeyFromVirtualKey(WParam.ToInt32()).ToString();//keyData.ToString(); return(true); }
// old stuff from old _DockableWindowHost --------------------------------------- [START] private void OnCallBackEvent(object sender, SubClassingWindowEventArgs e) { if (e.Closing) { return; } var param = new LParam { Value = (uint)e.LParam }; // The VBE passes a special value to the HighWord when docking into the VBE Codepane // instead of docking into the VBE itself. // that special value (0xffef) blows up inside the guts of Window management because it's // apparently converted to a signed short somewhere and then considered "negative" // that is why we drop the signbit for shorts off our values when creating the control Size. const ushort signBitMask = 0x8000; _userControl.Size = new Size(param.LowWord & ~signBitMask, param.HighWord & ~signBitMask); }
private static LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: s_baseUnits = Windows.GetDialogBaseUnits(); s_btnWidth = s_baseUnits.Width * 8; s_btnHeight = s_baseUnits.Height * 4; // Create the owner-draw pushbuttons var createMessage = new Message.Create(lParam); s_hwndSmaller = Windows.CreateWindow("button", style: WindowStyles.Child | WindowStyles.Visible | (WindowStyles)ButtonStyles.OwnerDrawn, bounds: new Rectangle(0, 0, s_btnWidth, s_btnHeight), parentWindow: window, menuHandle: (MenuHandle)ID_SMALLER, instance: createMessage.Instance); s_hwndLarger = Windows.CreateWindow("button", style: WindowStyles.Child | WindowStyles.Visible | (WindowStyles)ButtonStyles.OwnerDrawn, bounds: new Rectangle(0, 0, s_btnWidth, s_btnHeight), parentWindow: window, menuHandle: (MenuHandle)ID_LARGER, instance: createMessage.Instance); return(0); case MessageType.Size: s_cxClient = lParam.LowWord; s_cyClient = lParam.HighWord; // Move the buttons to the new center s_hwndSmaller.MoveWindow( new Rectangle(s_cxClient / 2 - 3 * s_btnWidth / 2, s_cyClient / 2 - s_btnHeight / 2, s_btnWidth, s_btnHeight), repaint: true); s_hwndLarger.MoveWindow( new Rectangle(s_cxClient / 2 + s_btnWidth / 2, s_cyClient / 2 - s_btnHeight / 2, s_btnWidth, s_btnHeight), repaint: true); return(0); case MessageType.Command: Rectangle rc = window.GetWindowRectangle(); // Make the window 10% smaller or larger switch ((int)(uint)wParam) { case ID_SMALLER: rc.Inflate(rc.Width / -10, rc.Height / -10); break; case ID_LARGER: rc.Inflate(rc.Width / 10, rc.Height / 10); break; } window.MoveWindow(rc, repaint: true); return(0); case MessageType.DrawItem: var drawItemMessage = new Message.DrawItem(lParam); // Fill area with white and frame it black using (DeviceContext dc = drawItemMessage.DeviceContext) { Rectangle rect = drawItemMessage.ItemRectangle; dc.FillRectangle(rect, StockBrush.White); dc.FrameRectangle(rect, StockBrush.Black); // Draw inward and outward black triangles int cx = rect.Right - rect.Left; int cy = rect.Bottom - rect.Top; Point[] pt = new Point[3]; switch ((int)drawItemMessage.ControlId) { case ID_SMALLER: pt[0].X = 3 * cx / 8; pt[0].Y = 1 * cy / 8; pt[1].X = 5 * cx / 8; pt[1].Y = 1 * cy / 8; pt[2].X = 4 * cx / 8; pt[2].Y = 3 * cy / 8; Triangle(dc, pt); pt[0].X = 7 * cx / 8; pt[0].Y = 3 * cy / 8; pt[1].X = 7 * cx / 8; pt[1].Y = 5 * cy / 8; pt[2].X = 5 * cx / 8; pt[2].Y = 4 * cy / 8; Triangle(dc, pt); pt[0].X = 5 * cx / 8; pt[0].Y = 7 * cy / 8; pt[1].X = 3 * cx / 8; pt[1].Y = 7 * cy / 8; pt[2].X = 4 * cx / 8; pt[2].Y = 5 * cy / 8; Triangle(dc, pt); pt[0].X = 1 * cx / 8; pt[0].Y = 5 * cy / 8; pt[1].X = 1 * cx / 8; pt[1].Y = 3 * cy / 8; pt[2].X = 3 * cx / 8; pt[2].Y = 4 * cy / 8; Triangle(dc, pt); break; case ID_LARGER: pt[0].X = 5 * cx / 8; pt[0].Y = 3 * cy / 8; pt[1].X = 3 * cx / 8; pt[1].Y = 3 * cy / 8; pt[2].X = 4 * cx / 8; pt[2].Y = 1 * cy / 8; Triangle(dc, pt); pt[0].X = 5 * cx / 8; pt[0].Y = 5 * cy / 8; pt[1].X = 5 * cx / 8; pt[1].Y = 3 * cy / 8; pt[2].X = 7 * cx / 8; pt[2].Y = 4 * cy / 8; Triangle(dc, pt); pt[0].X = 3 * cx / 8; pt[0].Y = 5 * cy / 8; pt[1].X = 5 * cx / 8; pt[1].Y = 5 * cy / 8; pt[2].X = 4 * cx / 8; pt[2].Y = 7 * cy / 8; Triangle(dc, pt); pt[0].X = 3 * cx / 8; pt[0].Y = 3 * cy / 8; pt[1].X = 3 * cx / 8; pt[1].Y = 5 * cy / 8; pt[2].X = 1 * cx / 8; pt[2].Y = 4 * cy / 8; Triangle(dc, pt); break; } // Invert the rectangle if the button is selected if ((drawItemMessage.ItemState & OwnerDrawStates.Selected) != 0) { dc.InvertRectangle(rect); } if ((drawItemMessage.ItemState & OwnerDrawStates.Focus) != 0) { rect = Rectangle.FromLTRB( rect.Left + cx / 16, rect.Top + cy / 16, rect.Right - cx / 16, rect.Bottom - cy / 16); dc.DrawFocusRectangle(rect); } } return(0); case MessageType.Destroy: Windows.PostQuitMessage(0); return(0); } return(Windows.DefaultWindowProcedure(window, message, wParam, lParam)); }
// Token: 0x06000045 RID: 69 RVA: 0x00002830 File Offset: 0x00001830 public override string ToString() { return(string.Format("msg=0x{0:x} ({1}) hwnd=0x{2:x} wparam=0x{3:x} lparam=0x{4:x} pt=0x{5:x}", (int)Message, Message, HWnd.ToInt32(), WParam.ToInt32(), LParam.ToInt32(), Point)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: window.SetTimer(ID_TIMER, 1000); return(0); case MessageType.Timer: Windows.MessageBeep(); fFlipFlop = !fFlipFlop; window.Invalidate(); return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { using (BrushHandle brush = Gdi.CreateSolidBrush(fFlipFlop ? Color.Red : Color.Blue)) { dc.FillRectangle(window.GetClientRectangle(), brush); } } return(0); case MessageType.Destroy: window.KillTimer(ID_TIMER); break; } return(base.WindowProcedure(window, message, wParam, lParam)); }
private LResult ScrollProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { int id = (int)window.GetWindowLong(WindowLong.Id).ToInt64(); switch (message) { case MessageType.KeyDown: if ((VirtualKey)wParam == VirtualKey.Tab) { window.GetParent().GetDialogItem( (id + ((Windows.GetKeyState(VirtualKey.Shift) & KeyState.Down) != 0 ? 2 : 1) % 3)) .SetFocus(); } break; case MessageType.SetFocus: idFocus = id; break; } return(Windows.CallWindowProcedure(OldScroll[id], window, message, wParam, lParam)); }
private int _iDeltaPerLine, _iAccumDelta; // for mouse wheel logic protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: base.WindowProcedure(window, message, wParam, lParam); // Fall through for mouse wheel information goto case MessageType.SettingChange; case MessageType.SettingChange: uint ulScrollLines = Windows.SystemParameters.GetWheelScrollLines(); // ulScrollLines usually equals 3 or 0 (for no scrolling) // WHEEL_DELTA equals 120, so iDeltaPerLine will be 40 if (ulScrollLines > 0) { _iDeltaPerLine = (int)(120 / ulScrollLines); } else { _iDeltaPerLine = 0; } return(0); case MessageType.MouseWheel: if (_iDeltaPerLine == 0) { break; } _iAccumDelta += (short)wParam.HighWord; // 120 or -120 while (_iAccumDelta >= _iDeltaPerLine) { window.SendMessage(MessageType.VerticalScroll, (uint)ScrollCommand.LineUp, 0); _iAccumDelta -= _iDeltaPerLine; } while (_iAccumDelta <= -_iDeltaPerLine) { window.SendMessage(MessageType.VerticalScroll, (uint)ScrollCommand.LineDown, 0); _iAccumDelta += _iDeltaPerLine; } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Size: cxBlock = lParam.LowWord / DIVISIONS; cyBlock = lParam.HighWord / DIVISIONS; return(0); case MessageType.LeftButtonDown: int x = lParam.LowWord / cxBlock; int y = lParam.HighWord / cyBlock; if (x < DIVISIONS && y < DIVISIONS) { fState[x, y] ^= true; Rectangle rect = Rectangle.FromLTRB ( x * cxBlock, y * cyBlock, (x + 1) * cxBlock, (y + 1) * cyBlock ); window.InvalidateRectangle(rect, false); } else { Windows.MessageBeep(0); } return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { for (x = 0; x < DIVISIONS; x++) { for (y = 0; y < DIVISIONS; y++) { dc.Rectangle(new Rectangle( x * cxBlock, y * cyBlock, (x + 1) * cxBlock, (y + 1) * cyBlock)); if (fState[x, y]) { dc.MoveTo(new Point(x * cxBlock, y * cyBlock)); dc.LineTo(new Point((x + 1) * cxBlock, (y + 1) * cyBlock)); dc.MoveTo(new Point(x * cxBlock, (y + 1) * cyBlock)); dc.LineTo(new Point((x + 1) * cxBlock, y * cyBlock)); } } } } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Size: cxClient = lParam.LowWord; cyClient = lParam.HighWord; return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.MoveTo(new Point(0, cyClient / 2)); dc.LineTo(new Point(cxClient, cyClient / 2)); for (int i = 0; i < apt.Length; i++) { apt[i].X = i * cxClient / apt.Length; apt[i].Y = (int)(cyClient / 2 * (1 - Math.Sin(Math.PI * 2 * i / apt.Length))); } dc.Polyline(apt); } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: _chunk = _sb.GetChunk(); goto case MessageType.DisplayChange; case MessageType.DisplayChange: // Get maximum size of client area cyClientMax = Windows.GetSystemMetrics(SystemMetric.MaximizedHeight); // Get character size for fixed-pitch font using (DeviceContext dc = window.GetDeviceContext()) { dc.SelectObject(StockFont.SystemFixed); dc.GetTextMetrics(out TextMetrics tm); cyChar = tm.Height; } cLinesMax = cyClientMax / cyChar; pmsg = new WindowMessage[cLinesMax]; cLines = 0; goto CalculateScroll; case MessageType.Size: cxClient = lParam.LowWord; cyClient = lParam.HighWord; CalculateScroll: rectScroll = Rectangle.FromLTRB(0, cyChar, cxClient, cyChar * (cyClient / cyChar)); window.Invalidate(true); return(0); case MessageType.KeyDown: case MessageType.KeyUp: case MessageType.Char: case MessageType.DeadChar: case MessageType.SystemKeyDown: case MessageType.SystemKeyUp: case MessageType.SystemChar: case MessageType.SystemDeadChar: // Rearrange storage array for (int i = cLinesMax - 1; i > 0; i--) { pmsg[i] = pmsg[i - 1]; } // Store new message pmsg[0] = new WindowMessage(window, message, wParam, lParam); cLines = Math.Min(cLines + 1, cLinesMax); // Scroll up the display window.ScrollWindow(new Point(0, -cyChar), rectScroll, rectScroll); break; // i.e., call DefWindowProc so Sys messages work case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.SelectObject(StockFont.SystemFixed); dc.SetBackgroundMode(BackgroundMode.Transparent); dc.TextOut(default, "Message Key Char Repeat Scan Ext ALT Prev Tran".AsSpan()); dc.TextOut(default, "_______ ___ ____ ______ ____ ___ ___ ____ ____".AsSpan()); for (int i = 0; i < Math.Min(cLines, cyClient / cyChar - 1); i++) { bool iType; switch (pmsg[i].Type) { case MessageType.Char: case MessageType.SystemChar: case MessageType.DeadChar: case MessageType.SystemDeadChar: iType = true; break; default: iType = false; break; } _sb.Clear(); _sb.AppendFormat(iType ? "{0,-13} {1,3} {2,15} {3,6} {4,4} {5,3} {6,3} {7,4} {8,4}" : "{0,-13} {1,3} {2,-15} {3,6} {4,4} {5,3} {6,3} {7,4} {8,4} VirtualKey: {9}", pmsg[i].Type, pmsg[i].WParam.ToString(), iType ? $"0x{((uint)pmsg[i].WParam):X4} {(char)(uint)pmsg[i].WParam}" : Windows.GetKeyNameText(pmsg[i].LParam), pmsg[i].LParam.LowWord, pmsg[i].LParam.HighWord & 0xFF, (0x01000000 & pmsg[i].LParam) != 0 ? "Yes" : "No", (0x20000000 & pmsg[i].LParam) != 0 ? "Yes" : "No", (0x40000000 & pmsg[i].LParam) != 0 ? "Down" : "Up", (0x80000000 & pmsg[i].LParam) != 0 ? "Up" : "Down", (VirtualKey)pmsg[i].WParam); dc.TextOut(new Point(0, (cyClient / cyChar - 1 - i) * cyChar), _chunk.Span.Slice(0, _sb.Length)); } } return(0); }
private static LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: Multimedia.PlaySound(PlaySoundAlias.SystemHand, PlaySoundOptions.Async | PlaySoundOptions.NoDefault); return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.DrawText( "Hello, Windows 98!", window.GetClientRectangle(), TextFormat.SingleLine | TextFormat.Center | TextFormat.VerticallyCenter); } return(0); case MessageType.Destroy: Windows.PostQuitMessage(0); return(0); } return(Windows.DefaultWindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Size: cxClient = lParam.LowWord; cyClient = lParam.HighWord; CursorHandle hCursor = Windows.SetCursor(CursorId.Wait); Windows.ShowCursor(true); hRgnClip.Dispose(); Span <RegionHandle> hRgnTemp = stackalloc RegionHandle[6]; hRgnTemp[0] = Gdi.CreateEllipticRegion(Rectangle.FromLTRB(0, cyClient / 3, cxClient / 2, 2 * cyClient / 3)); hRgnTemp[1] = Gdi.CreateEllipticRegion(Rectangle.FromLTRB(cxClient / 2, cyClient / 3, cxClient, 2 * cyClient / 3)); hRgnTemp[2] = Gdi.CreateEllipticRegion(Rectangle.FromLTRB(cxClient / 3, 0, 2 * cxClient / 3, cyClient / 2)); hRgnTemp[3] = Gdi.CreateEllipticRegion(Rectangle.FromLTRB(cxClient / 3, cyClient / 2, 2 * cxClient / 3, cyClient)); hRgnTemp[4] = Gdi.CreateRectangleRegion(Rectangle.FromLTRB(0, 0, 1, 1)); hRgnTemp[5] = Gdi.CreateRectangleRegion(Rectangle.FromLTRB(0, 0, 1, 1)); hRgnClip = Gdi.CreateRectangleRegion(Rectangle.FromLTRB(0, 0, 1, 1)); hRgnTemp[4].CombineRegion(hRgnTemp[0], hRgnTemp[1], CombineRegionMode.Or); hRgnTemp[5].CombineRegion(hRgnTemp[2], hRgnTemp[3], CombineRegionMode.Or); hRgnClip.CombineRegion(hRgnTemp[4], hRgnTemp[5], CombineRegionMode.Xor); for (int i = 0; i < 6; i++) { hRgnTemp[i].Dispose(); } Windows.SetCursor(hCursor); Windows.ShowCursor(false); return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.SetViewportOrigin(new Point(cxClient / 2, cyClient / 2)); dc.SelectClippingRegion(hRgnClip); double fRadius = Hypotenuse(cxClient / 2.0, cyClient / 2.0); for (double fAngle = 0.0; fAngle < TWO_PI; fAngle += TWO_PI / 360) { dc.MoveTo(default); dc.LineTo(new Point( (int)(fRadius * Math.Cos(fAngle) + 0.5), (int)(-fRadius * Math.Sin(fAngle) + 0.5))); } }
/// <summary> /// Determines whether the <see href="LParam"/> field of this window message matches the specified <paramref name="lParam"/>. /// </summary> /// <param name="lParam"> /// <see href="User.LParam"/> value to check for equality. /// </param> /// <returns> /// <c>true</c> if the <see href="LParam"/> field of this window message matches the specified <paramref name="lParam"/>; otherwise <c>false</c>. /// </returns> public bool Is(LParam lParam) { return(LParamInt32Value == lParam.ToInt32()); }
static LResult CallDefaultProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { return(Windows.DefaultWindowProcedure(window, message, wParam, lParam)); }
private static LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Size: s_cxClient = lParam.LowWord; s_cyClient = lParam.HighWord; return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.Rectangle(Rectangle.FromLTRB(s_cxClient / 8, s_cyClient / 8, 7 * s_cxClient / 8, 7 * s_cyClient / 8)); dc.MoveTo(new Point(0, 0)); dc.LineTo(new Point(s_cxClient, s_cyClient)); dc.MoveTo(new Point(0, s_cyClient)); dc.LineTo(new Point(s_cxClient, 0)); dc.Ellipse(Rectangle.FromLTRB(s_cxClient / 8, s_cyClient / 8, 7 * s_cxClient / 8, 7 * s_cyClient / 8)); dc.RoundRectangle( Rectangle.FromLTRB(s_cxClient / 4, s_cyClient / 4, 3 * s_cxClient / 4, 3 * s_cyClient / 4), new Size(s_cxClient / 4, s_cyClient / 4)); } return(0); case MessageType.Destroy: Windows.PostQuitMessage(0); return(0); } return(Windows.DefaultWindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: _initialMonitor = window.MonitorFromWindow(); _screen = Windows.GetMonitorInfo(_initialMonitor).Monitor; window.SetTimer(_timerId, 200); return(0); case MessageType.Size: _client = new Rectangle(default, new Message.Size(wParam, lParam).NewSize); return(0); case MessageType.Timer: // Update via timer if we aren't primarily on the main monitor if (window.MonitorFromWindow() != _initialMonitor) { window.Invalidate(); } return(0); case MessageType.Move: window.Invalidate(); return(0); case MessageType.Paint: using (DeviceContext clientDC = window.BeginPaint()) using (DeviceContext screenDC = Gdi.GetDeviceContext()) { clientDC.SetStretchBlitMode(StretchMode.HalfTone); screenDC.StretchBlit(clientDC, _screen, _client, RasterOperation.Common.SourceCopy); } return(0); case MessageType.Destroy: window.KillTimer(_timerId); break; } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: // Create the white-rectangle window against which the // scroll bars will be positioned. The child window ID is 9. hwndRect = Windows.CreateWindow( className: "static", style: WindowStyles.Child | WindowStyles.Visible | (WindowStyles)StaticStyles.WhiteRectangle, parentWindow: window, menuHandle: (MenuHandle)9, instance: ModuleInstance); for (int i = 0; i < 3; i++) { // The three scroll bars have IDs 0, 1, and 2, with // scroll bar ranges from 0 through 255. hwndScroll[i] = Windows.CreateWindow( className: "scrollbar", style: WindowStyles.Child | WindowStyles.Visible | WindowStyles.TabStop | (WindowStyles)ScrollBarStyles.Veritcal, parentWindow: window, menuHandle: (MenuHandle)i, instance: ModuleInstance); hwndScroll[i].SetScrollRange(ScrollBar.Control, 0, 255, false); hwndScroll[i].SetScrollPosition(ScrollBar.Control, 0, false); // The three color-name labels have IDs 3, 4, and 5, // and text strings “Red”, “Green”, and “Blue”. hwndLabel[i] = Windows.CreateWindow( className: "static", windowName: szColorLabel[i], style: WindowStyles.Child | WindowStyles.Visible | (WindowStyles)StaticStyles.Center, parentWindow: window, menuHandle: (MenuHandle)(i + 3), instance: ModuleInstance); // The three color-value text fields have IDs 6, 7, // and 8, and initial text strings of “0”. hwndValue[i] = Windows.CreateWindow( className: "static", windowName: "0", style: WindowStyles.Child | WindowStyles.Visible | (WindowStyles)StaticStyles.Center, parentWindow: window, menuHandle: (MenuHandle)(i + 6), instance: ModuleInstance); OldScroll[i] = hwndScroll[i].SetWindowProcedure(_scrollProcedure = ScrollProcedure); hBrush[i] = Gdi.CreateSolidBrush(crPrim[i]); } hBrushStatic = Gdi.GetSystemColorBrush(SystemColor.ButtonHighlight); cyChar = Windows.GetDialogBaseUnits().Height; return(0); case MessageType.Size: int cxClient = lParam.LowWord; int cyClient = lParam.HighWord; rcColor = Rectangle.FromLTRB(cxClient / 2, 0, cxClient, cyClient); hwndRect.MoveWindow(new Rectangle(0, 0, cxClient / 2, cyClient), repaint: true); for (int i = 0; i < 3; i++) { hwndScroll[i].MoveWindow( new Rectangle((2 * i + 1) * cxClient / 14, 2 * cyChar, cxClient / 14, cyClient - 4 * cyChar), repaint: true); hwndLabel[i].MoveWindow( new Rectangle((4 * i + 1) * cxClient / 28, cyChar / 2, cxClient / 7, cyChar), repaint: true); hwndValue[i].MoveWindow( new Rectangle((4 * i + 1) * cxClient / 28, cyClient - 3 * cyChar / 2, cxClient / 7, cyChar), repaint: true); } window.SetFocus(); return(0); case MessageType.SetFocus: hwndScroll[idFocus].SetFocus(); return(0); case MessageType.VerticalScroll: int id = (int)((WindowHandle)lParam).GetWindowLong(WindowLong.Id); switch ((ScrollCommand)wParam.LowWord) { case ScrollCommand.PageDown: color[id] += 15; goto case ScrollCommand.LineDown; case ScrollCommand.LineDown: color[id] = Math.Min(255, color[id] + 1); break; case ScrollCommand.PageUp: color[id] -= 15; goto case ScrollCommand.LineUp; case ScrollCommand.LineUp: color[id] = Math.Max(0, color[id] - 1); break; case ScrollCommand.Top: color[id] = 0; break; case ScrollCommand.Bottom: color[id] = 255; break; case ScrollCommand.ThumbPosition: case ScrollCommand.ThumbTrack: color[id] = wParam.HighWord; break; default: return(0); } hwndScroll[id].SetScrollPosition(ScrollBar.Control, color[id], true); hwndValue[id].SetWindowText(color[id].ToString()); // We'll dispose when we set the next brush BrushHandle brush = Gdi.CreateSolidBrush(Color.FromArgb(color[0], color[1], color[2])); window.SetClassBackgroundBrush(brush).Dispose(); window.InvalidateRectangle(rcColor, true); return(0); case MessageType.ControlColorScrollBar: return((BrushHandle)hBrush[(int)((WindowHandle)lParam).GetWindowLong(WindowLong.Id)]); case MessageType.ControlColorStatic: id = (int)((WindowHandle)lParam).GetWindowLong(WindowLong.Id); if (id >= 3 && id <= 8) { DeviceContext dc = (DeviceContext)wParam; dc.SetTextColor(crPrim[id % 3]); dc.SetBackgroundColor(Windows.GetSystemColor(SystemColor.ButtonHighlight)); return((BrushHandle)hBrushStatic); } break; case MessageType.SystemColorChange: hBrushStatic = Gdi.GetSystemColorBrush(SystemColor.ButtonHighlight); return(0); case MessageType.Destroy: window.SetClassBackgroundBrush(StockBrush.White).Dispose(); for (int i = 0; i < 3; i++) { hBrush[i].Dispose(); } break; } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: window.SetTimer(ID_TIMER, 100); return(0); case MessageType.Timer: Point pt = Windows.GetCursorPosition(); using (DeviceContext dc = Gdi.CreateDesktopDeviceContext()) { cr = dc.GetPixel(pt); if (cr != crLast) { crLast = cr; window.GetDeviceContext().SetBackgroundColor(cr); window.Invalidate(erase: false); } } return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.SelectObject(StockFont.SystemFixed); Rectangle rc = window.GetClientRectangle(); dc.FillRectangle(rc, dc.GetCurrentBrush()); dc.DrawText($"0x{cr.R:X2} 0x{cr.G:X2} 0x{cr.B:X2}".AsSpan(), rc, TextFormat.SingleLine | TextFormat.Center | TextFormat.VerticallyCenter); } return(0); case MessageType.Destroy: window.KillTimer(ID_TIMER); break; } return(base.WindowProcedure(window, message, wParam, lParam)); }
public Size(WParam wParam, LParam lParam) { NewSize = new System.Drawing.Size(lParam.LowWord, lParam.HighWord); SizeType = (SizeType)(int)wParam; }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: _editClass = new EditClass(EditStyles.Multiline | EditStyles.Left | EditStyles.AutoHorizontalScroll | EditStyles.AutoVerticalScroll); _editHandle = _editClass.CreateWindow( style: WindowStyles.Child | WindowStyles.Visible | WindowStyles.HorizontalScroll | WindowStyles.VerticalScroll | WindowStyles.Border, parentWindow: window); return(0); case MessageType.SetFocus: _editHandle.SetFocus(); return(0); case MessageType.Size: var size = new Message.Size(wParam, lParam); _editHandle.MoveWindow(new Rectangle(new Point(), size.NewSize), repaint: true); return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected unsafe override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: hwndEdit = Windows.CreateWindow("edit", "", WindowStyles.Child | WindowStyles.Visible | WindowStyles.HorizontalScroll | WindowStyles.VerticalScroll | WindowStyles.Border | (WindowStyles)EditStyles.Left | (WindowStyles)EditStyles.Multiline | (WindowStyles)EditStyles.AutoHorizontalScroll | (WindowStyles)EditStyles.AutoVerticalScroll, ExtendedWindowStyles.Default, new Rectangle(), window, (MenuHandle)ID_EDIT, ModuleInstance, IntPtr.Zero); return(0); case MessageType.SetFocus: hwndEdit.SetFocus(); return(0); case MessageType.Size: hwndEdit.MoveWindow(new Rectangle(0, 0, lParam.LowWord, lParam.HighWord), repaint: true); return(0); case MessageType.Command: if (wParam.LowWord == ID_EDIT && (wParam.HighWord == (ushort)EditNotification.ErrorSpace || wParam.HighWord == (ushort)EditNotification.MaxText)) { window.MessageBox("Edit control out of space.", "PopPad1", MessageBoxType.Ok | MessageBoxType.IconStop); } return(0); case MessageType.Destroy: Windows.PostQuitMessage(0); return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected unsafe override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: _baseUnits = Windows.GetDialogBaseUnits(); _btnWidth = _baseUnits.Width * 8; _btnHeight = _baseUnits.Height * 4; // Create the owner-draw pushbuttons _hwndSmaller = Windows.CreateWindow("button", "", WindowStyles.Child | WindowStyles.Visible | (WindowStyles)ButtonStyles.OwnerDrawn, ExtendedWindowStyles.Default, new Rectangle(0, 0, _btnWidth, _btnHeight), window, (MenuHandle)ID_SMALLER, ModuleInstance, IntPtr.Zero); _hwndLarger = Windows.CreateWindow("button", "", WindowStyles.Child | WindowStyles.Visible | (WindowStyles)ButtonStyles.OwnerDrawn, ExtendedWindowStyles.Default, new Rectangle(0, 0, _btnWidth, _btnHeight), window, (MenuHandle)ID_LARGER, ModuleInstance, IntPtr.Zero); return(0); case MessageType.Size: _cxClient = lParam.LowWord; _cyClient = lParam.HighWord; // Move the buttons to the new center _hwndSmaller.MoveWindow( new Rectangle(_cxClient / 2 - 3 * _btnWidth / 2, _cyClient / 2 - _btnHeight / 2, _btnWidth, _btnHeight), repaint: true); _hwndLarger.MoveWindow( new Rectangle(_cxClient / 2 + _btnWidth / 2, _cyClient / 2 - _btnHeight / 2, _btnWidth, _btnHeight), repaint: true); return(0); case MessageType.Command: Rectangle rc = window.GetWindowRectangle(); // Make the window 10% smaller or larger switch ((int)(uint)wParam) { case ID_SMALLER: rc.Inflate(rc.Width / -10, rc.Height / -10); break; case ID_LARGER: rc.Inflate(rc.Width / 10, rc.Height / 10); break; } window.MoveWindow(new Rectangle(rc.Left, rc.Top, rc.Right - rc.Left, rc.Bottom - rc.Top), repaint: true); return(0); case MessageType.DrawItem: DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam; // Fill area with white and frame it black using (DeviceContext dc = new DeviceContext(pdis->hDC)) { Rectangle rect = pdis->rcItem; dc.FillRectangle(rect, StockBrush.White); dc.FrameRectangle(rect, StockBrush.Black); // Draw inward and outward black triangles int cx = rect.Right - rect.Left; int cy = rect.Bottom - rect.Top; Point[] pt = new Point[3]; switch ((int)pdis->CtlID) { case ID_SMALLER: pt[0].X = 3 * cx / 8; pt[0].Y = 1 * cy / 8; pt[1].X = 5 * cx / 8; pt[1].Y = 1 * cy / 8; pt[2].X = 4 * cx / 8; pt[2].Y = 3 * cy / 8; Triangle(dc, pt); pt[0].X = 7 * cx / 8; pt[0].Y = 3 * cy / 8; pt[1].X = 7 * cx / 8; pt[1].Y = 5 * cy / 8; pt[2].X = 5 * cx / 8; pt[2].Y = 4 * cy / 8; Triangle(dc, pt); pt[0].X = 5 * cx / 8; pt[0].Y = 7 * cy / 8; pt[1].X = 3 * cx / 8; pt[1].Y = 7 * cy / 8; pt[2].X = 4 * cx / 8; pt[2].Y = 5 * cy / 8; Triangle(dc, pt); pt[0].X = 1 * cx / 8; pt[0].Y = 5 * cy / 8; pt[1].X = 1 * cx / 8; pt[1].Y = 3 * cy / 8; pt[2].X = 3 * cx / 8; pt[2].Y = 4 * cy / 8; Triangle(dc, pt); break; case ID_LARGER: pt[0].X = 5 * cx / 8; pt[0].Y = 3 * cy / 8; pt[1].X = 3 * cx / 8; pt[1].Y = 3 * cy / 8; pt[2].X = 4 * cx / 8; pt[2].Y = 1 * cy / 8; Triangle(dc, pt); pt[0].X = 5 * cx / 8; pt[0].Y = 5 * cy / 8; pt[1].X = 5 * cx / 8; pt[1].Y = 3 * cy / 8; pt[2].X = 7 * cx / 8; pt[2].Y = 4 * cy / 8; Triangle(dc, pt); pt[0].X = 3 * cx / 8; pt[0].Y = 5 * cy / 8; pt[1].X = 5 * cx / 8; pt[1].Y = 5 * cy / 8; pt[2].X = 4 * cx / 8; pt[2].Y = 7 * cy / 8; Triangle(dc, pt); pt[0].X = 3 * cx / 8; pt[0].Y = 3 * cy / 8; pt[1].X = 3 * cx / 8; pt[1].Y = 5 * cy / 8; pt[2].X = 1 * cx / 8; pt[2].Y = 4 * cy / 8; Triangle(dc, pt); break; } // Invert the rectangle if the button is selected if ((pdis->itemState & OwnerDrawStates.Selected) != 0) { dc.InvertRectangle(rect); } if ((pdis->itemState & OwnerDrawStates.Focus) != 0) { rect = Rectangle.FromLTRB( rect.Left + cx / 16, rect.Top + cy / 16, rect.Right - cx / 16, rect.Bottom - cy / 16); dc.DrawFocusRectangle(rect); } } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: window.SetTimer(ID_TIMER, 1000); _previousTime = SystemInformation.GetLocalTime(); return(0); case MessageType.Size: _clientSize = new Message.Size(wParam, lParam).NewSize; return(0); case MessageType.Timer: SystemTime time = SystemInformation.GetLocalTime(); bool drawAllHands = time.Hour != _previousTime.Hour || time.Minute != _previousTime.Minute; using (DeviceContext dc = window.GetDeviceContext()) { SetIsotropic(dc); DrawHands(dc, _previousTime, erase: true, drawAllHands); DrawHands(dc, time); } _previousTime = time; return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { SetIsotropic(dc); DrawClock(dc); DrawHands(dc, _previousTime); } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
internal WimFileProgressEventArgs(WIM_MSG message, IntPtr wParam, IntPtr lParam) : base(message, wParam, lParam) { Percent = wParam.ToInt32(); MillisecondsRemaining = LParam.ToInt32(); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: using (DeviceContext dc = window.GetDeviceContext()) { dc.GetTextMetrics(out TextMetrics tm); cxChar = tm.AverageCharWidth; cxCaps = ((tm.PitchAndFamily.PitchTypes & FontPitchTypes.VariablePitch) != 0 ? 3 : 2) * cxChar / 2; cyChar = tm.Height + tm.ExternalLeading; } return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { int i = 0; foreach (SystemMetric metric in Metrics.SystemMetrics.Keys) { dc.TextOut(new Point(0, cyChar * i), metric.ToString().AsSpan()); dc.TextOut(new Point(22 * cxCaps, cyChar * i), Metrics.SystemMetrics[metric].AsSpan()); dc.SetTextAlignment(new TextAlignment(TextAlignment.Horizontal.Right, TextAlignment.Vertical.Top)); dc.TextOut(new Point(22 * cxCaps + 40 * cxChar, cyChar * i), Windows.GetSystemMetrics(metric).ToString().AsSpan()); dc.SetTextAlignment(new TextAlignment(TextAlignment.Horizontal.Left, TextAlignment.Vertical.Top)); i++; } } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.KeyDown: switch ((VirtualKey)wParam) { case VirtualKey.Home: window.SendMessage(MessageType.VerticalScroll, (uint)ScrollCommand.Top, 0); break; case VirtualKey.End: window.SendMessage(MessageType.VerticalScroll, (uint)ScrollCommand.Bottom, 0); break; case VirtualKey.Prior: window.SendMessage(MessageType.VerticalScroll, (uint)ScrollCommand.PageUp, 0); break; case VirtualKey.Next: window.SendMessage(MessageType.VerticalScroll, (uint)ScrollCommand.PageDown, 0); break; case VirtualKey.Up: window.SendMessage(MessageType.VerticalScroll, (uint)ScrollCommand.LineUp, 0); break; case VirtualKey.Down: window.SendMessage(MessageType.VerticalScroll, (uint)ScrollCommand.LineDown, 0); break; case VirtualKey.Left: window.SendMessage(MessageType.HorizontalScroll, (uint)ScrollCommand.PageUp, 0); break; case VirtualKey.Right: window.SendMessage(MessageType.HorizontalScroll, (uint)ScrollCommand.PageDown, 0); break; } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }