コード例 #1
0
ファイル: Structs.cs プロジェクト: formist/LinkMe
        public static CHARFORMAT2W Create()
        {
            CHARFORMAT2W s = new CHARFORMAT2W();

            s.cbSize = Marshal.SizeOf(typeof(CHARFORMAT2W));
            return(s);
        }
コード例 #2
0
ファイル: RichTextBox.cs プロジェクト: formist/LinkMe
        public void SelectedTextToLink(bool hyperlink)
        {
            Win32.CHARFORMAT2W format = Win32.CHARFORMAT2W.Create();

            format.dwMask    = Constants.Win32.CFM_LINK;
            format.dwEffects = (hyperlink ? Constants.Win32.CFE_LINK : 0);

            IntPtr result = UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle),
                                                            Constants.Win32.Messages.EM_SETCHARFORMAT, (IntPtr)Constants.Win32.SCF_SELECTION, ref format);

            if (result == (IntPtr)0)
            {
                throw new Win32Exception();
            }
        }