diff --git a/Client/Forms/FrmChat.Designer.cs b/Client/Forms/FrmChat.Designer.cs index e6f4bf4..5bc7c96 100644 --- a/Client/Forms/FrmChat.Designer.cs +++ b/Client/Forms/FrmChat.Designer.cs @@ -95,6 +95,7 @@ private void InitializeComponent() this.lblChannelIndicator = new System.Windows.Forms.Label(); this.LogoTopRight = new System.Windows.Forms.PictureBox(); this.btnDisconnect = new System.Windows.Forms.Button(); + this.btnShadowTest = new System.Windows.Forms.Button(); this.menuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabWho.SuspendLayout(); @@ -708,6 +709,16 @@ private void InitializeComponent() this.btnDisconnect.MouseEnter += new System.EventHandler(this.btnDisconnect_MouseEnter); this.btnDisconnect.MouseLeave += new System.EventHandler(this.btnDisconnect_MouseLeave); // + // btnShadowTest + // + this.btnShadowTest.Location = new System.Drawing.Point(409, 42); + this.btnShadowTest.Name = "btnShadowTest"; + this.btnShadowTest.Size = new System.Drawing.Size(85, 45); + this.btnShadowTest.TabIndex = 27; + this.btnShadowTest.Text = "TEST RTB SHADOW"; + this.btnShadowTest.UseVisualStyleBackColor = true; + this.btnShadowTest.Click += new System.EventHandler(this.btnShadowTest_Click); + // // FrmChat // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -715,6 +726,7 @@ private void InitializeComponent() this.BackColor = System.Drawing.Color.Black; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.ClientSize = new System.Drawing.Size(1032, 541); + this.Controls.Add(this.btnShadowTest); this.Controls.Add(this.btnDisconnect); this.Controls.Add(this.tabControl1); this.Controls.Add(this.cBStatusFlag); @@ -822,5 +834,6 @@ private void InitializeComponent() private PictureBox LogoTopRight; private ListView listWho; private Button btnDisconnect; + private Button btnShadowTest; } } \ No newline at end of file diff --git a/Client/Forms/FrmChat.cs b/Client/Forms/FrmChat.cs index 07f0226..ac2689a 100644 --- a/Client/Forms/FrmChat.cs +++ b/Client/Forms/FrmChat.cs @@ -57,6 +57,14 @@ public struct CHARFORMAT2 const int CFM_LCID = 0x2000000; const int CFM_REVAUTHOR = 0x8000; const int EM_SETCHARFORMAT = 0x444; + + private const Int32 SCF_SELECTION2 = 0x0001; + private const UInt32 WM_USER = 0x0400; + private const UInt32 EM_GETCHARFORMAT = (WM_USER + 58); + const UInt32 CFE_BOLD = 0x0001; + const UInt32 CFM_BOLD = 0x00000001; + const UInt32 CFM_SHADOW = 0x0400; + const int SCF_SELECTION = 0x1; const int SCF_WORD = 0x2; @@ -277,7 +285,8 @@ private void AppendText(RichTextBox box, string text, Color color, bool bold = f else { box.SelectionColor = color; - } + } + box.AppendText(text); box.SelectionColor = box.ForeColor; box.ScrollToCaret(); @@ -359,6 +368,29 @@ private void clickableUserName(string username, string fullmsg) Marshal.StructureToPtr(myFormat, lParam, false); SendMessage(ChatWindow.Handle, (UInt32)EM_SETCHARFORMAT, (IntPtr)(SCF_SELECTION + SCF_WORD), lParam); } + + private void SetEffectTest(UInt32 mask, UInt32 effect, bool valid) + { + CHARFORMAT2 fmt = new CHARFORMAT2(); + fmt.cbSize = Marshal.SizeOf(fmt); + fmt.dwMask = (int)mask; + fmt.dwEffects = valid ? (int)effect : 0; + IntPtr lParam = Marshal.AllocCoTaskMem(Marshal.SizeOf(fmt)); + Marshal.StructureToPtr(fmt, lParam, false); + SendMessage(ChatWindow.Handle, EM_SETCHARFORMAT, (IntPtr)SCF_SELECTION2, lParam); + } + + //did not got this working, but its a solution to the chatwindow color. + //https://stackoverflow.com/questions/1268009/reset-rtf-in-richtextbox + private void btnShadowTest_Click(object sender, EventArgs e) + { + CHARFORMAT2 _charFormat = new CHARFORMAT2(); + _charFormat.cbSize = Marshal.SizeOf(_charFormat); + IntPtr lParam = Marshal.AllocCoTaskMem(Marshal.SizeOf(_charFormat)); + Marshal.StructureToPtr(_charFormat, lParam, false); + SendMessage(ChatWindow.Handle, EM_GETCHARFORMAT, (IntPtr)SCF_SELECTION, lParam); + SetEffectTest(CFM_SHADOW, CFM_SHADOW, true); + } private void FrmChat_Load(object sender, EventArgs e) {