public static CHARFORMATA Create(Control control, bool selection) { CHARFORMATA retVal = null; if (control.IsHandleCreated) { retVal = new CHARFORMATA(); SendMessage(new HandleRef(control, control.Handle), EM_GETCHARFORMAT, selection ? SCF_SELECTION : SCF_DEFAULT, retVal); } return(retVal); }
public static float?GetSelectionSize(RichTextBox control) { var lParam = new CHARFORMATA(); lParam.cbSize = Marshal.SizeOf(lParam); // Get the underline style SendMessage(new HandleRef(control, control.Handle), EM_GETCHARFORMAT, SCF_SELECTION, lParam); if ((lParam.dwMask & -CFM_SIZE) != 0) { float emSize = ((float)lParam.yHeight) / 20f; if ((emSize == 0f) && (lParam.yHeight > 0)) { emSize = 1f; } return(emSize); } else { return(null); } }
public static CHARFORMATA Create(Control control, bool selection) { CHARFORMATA retVal = null; if (control.IsHandleCreated) { retVal = new CHARFORMATA(); SendMessage(new HandleRef(control, control.Handle), EM_GETCHARFORMAT, selection ? SCF_SELECTION : SCF_DEFAULT, retVal); } return retVal; }
private static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, [In, Out, MarshalAs(UnmanagedType.LPStruct)] CHARFORMATA lParam);