Hi Lance,
Thank you for your feedback.
After doing more research, I work out how to mimic the appearance of the
splitter control's icon. That is to create a bitmap in the project and
create a pattern brush on this bitmap. Select the patter brush into the
device context(DC) of the screen and then call the Gdi32 function PatBlt to
draw the sizing border of the form.
Firstly, double-click the Resources.resx in the Solution Explorer and add a
bitmap in the Resources.resx. The new bitmap is named Image1 and displayed
in an image editor automatically. Resize the bitmap to the size of 2*2.
Color the top-left and bottom-right panes to Black.
Modifiy the code I provided in my previous reply as follows:
using System.Runtime.InteropServices;
public partial class Form1 : Form
{
[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError =
true, ExactSpelling = true)]
public static extern bool PatBlt(IntPtr hdc, int left, int top, int
width, int height, int rop);
[DllImport("gdi32.dll")]
public static extern IntPtr CreatePatternBrush(IntPtr hbmp);
[DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr
hgdiobj);
[DllImport("user32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")]
public static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
int PATINVERT = 0x5A0049;
private void MyDrawReversibleFrame(Point point1, Point point2)
{
point1 = PointToScreen(point1);
point2 = PointToScreen(point2);
//ControlPaint.DrawReversibleFrame(
// new Rectangle(point1.X - 3, point1.Y - 23,
point2.X-point1.X + 3, point2.Y-point1.Y+23),
// Color.Black,
// FrameStyle.Thick);
using (Graphics g = this.CreateGraphics())
{
IntPtr hbitmap =
ControlPaint.CreateHBitmap16Bit(Properties.Resources.Image1,
Color.Transparent);
IntPtr hbrush = CreatePatternBrush(hbitmap);
IntPtr hScreenDC = GetDC(IntPtr.Zero);
SelectObject(hScreenDC,hbrush);
int x = point1.X - 3;
int y = point1.Y - 23;
int width = point2.X - point1.X + 3;
int height = point2.Y - point1.Y + 23;
PatBlt(hScreenDC,x-2 ,y-2, 2 ,height+4 , PATINVERT);
PatBlt(hScreenDC, x, y - 2, width, 2, PATINVERT);
PatBlt(hScreenDC, x, y + height, width, 2, PATINVERT);
PatBlt(hScreenDC, x + width , y -2, 2, height + 4,
PATINVERT);
ReleaseDC(IntPtr.Zero, hScreenDC);
}
}
}
Hope this helps.
If you need, I could send you a sample project.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support