G
gourmete
Hello!
I have a huge problem!
I have a custom-shaped form with no borders and some transparent
controls on it.
I implemented the resizing functionality via sendmessage:
private void resizeBorder_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, 10, 0);
}
The problem occurs while resizing from right to left and from top to
bottom: The background of the transparent controls does not update.
If I use a form with borders and let windows do all the resizing work
everything is allright. Even resizing via sendMessage works correctly
in case of the form having a border.
I tried to invalidate the controls, refresh, force repaint and so on,
but nothing worked.
So my question is: What additional tricks does windows do on resizing a
form having borders???
I tracked the problem down to a very simple example:
Use Form1(false) to create a working form and Form1(true) to create the
problem form. Click on the left gray panel to resize.
------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication2
{
public class Form1 : Form
{
private Panel resizeBorder;
private Panel panel1;
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.resizeBorder = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
this.resizeBorder.BackColor =
System.Drawing.SystemColors.Control;
this.resizeBorder.Dock =
System.Windows.Forms.DockStyle.Left;
this.resizeBorder.Location = new System.Drawing.Point(0,
0);
this.resizeBorder.Name = "resizeBorder";
this.resizeBorder.Size = new System.Drawing.Size(12, 266);
this.resizeBorder.TabIndex = 0;
this.resizeBorder.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.resizeBorder_MouseDown);
this.panel1.BackColor = System.Drawing.Color.Fuchsia;
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(12, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(280, 266);
this.panel1.TabIndex = 1;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.panel1);
this.Controls.Add(this.resizeBorder);
this.Name = "Form1";
this.Text = "Form1";
this.TransparencyKey = System.Drawing.Color.Fuchsia;
this.ResumeLayout(false);
}
public Form1(bool problem)
{
InitializeComponent();
if (problem)
this.FormBorderStyle = FormBorderStyle.None;
}
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int
wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
private const int WM_NCLBUTTONDOWN = 0xA1;
private void resizeBorder_MouseDown(object sender,
MouseEventArgs e)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, 10, 0);
}
}
}
I have a huge problem!
I have a custom-shaped form with no borders and some transparent
controls on it.
I implemented the resizing functionality via sendmessage:
private void resizeBorder_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, 10, 0);
}
The problem occurs while resizing from right to left and from top to
bottom: The background of the transparent controls does not update.
If I use a form with borders and let windows do all the resizing work
everything is allright. Even resizing via sendMessage works correctly
in case of the form having a border.
I tried to invalidate the controls, refresh, force repaint and so on,
but nothing worked.
So my question is: What additional tricks does windows do on resizing a
form having borders???
I tracked the problem down to a very simple example:
Use Form1(false) to create a working form and Form1(true) to create the
problem form. Click on the left gray panel to resize.
------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication2
{
public class Form1 : Form
{
private Panel resizeBorder;
private Panel panel1;
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.resizeBorder = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
this.resizeBorder.BackColor =
System.Drawing.SystemColors.Control;
this.resizeBorder.Dock =
System.Windows.Forms.DockStyle.Left;
this.resizeBorder.Location = new System.Drawing.Point(0,
0);
this.resizeBorder.Name = "resizeBorder";
this.resizeBorder.Size = new System.Drawing.Size(12, 266);
this.resizeBorder.TabIndex = 0;
this.resizeBorder.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.resizeBorder_MouseDown);
this.panel1.BackColor = System.Drawing.Color.Fuchsia;
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(12, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(280, 266);
this.panel1.TabIndex = 1;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.panel1);
this.Controls.Add(this.resizeBorder);
this.Name = "Form1";
this.Text = "Form1";
this.TransparencyKey = System.Drawing.Color.Fuchsia;
this.ResumeLayout(false);
}
public Form1(bool problem)
{
InitializeComponent();
if (problem)
this.FormBorderStyle = FormBorderStyle.None;
}
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int
wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
private const int WM_NCLBUTTONDOWN = 0xA1;
private void resizeBorder_MouseDown(object sender,
MouseEventArgs e)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, 10, 0);
}
}
}