D
Dotnet_Is_Love
I am trying to create my own skins for a win form. I want to display
images as the border.I have 8 images. ( topLeft.bmp, topmid.bmp
topright.bmp left.bmp, right.bmp bottomLeft.bmp. bottomMid.bmp and
BottomRight.bmp)
I tried to capture wm_ncpaint and did following. I seem to get only
the top set and not the bottom
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if ( m.Msg == 132 )
{
//handle hits here
}
else
if(m.Msg == 0x85) // (WM_NCPAINT)
{
Graphics g = Graphics.FromHdc(GetWindowDC(this.Handle));
Rectangle aRect2 = new Rectangle ();
GetWindowRect(this.Handle , ref aRect2);
Point pt = new Point ( aRect2.Left,aRect2.Top );
ScreenToClient( this.Handle,ref pt);
Point pt2 = new Point ( aRect2.Right,aRect2.Bottom);
ScreenToClient( this.Handle,ref pt2);
Rectangle aRect = new Rectangle (0 ,0,aRect2.Right - aRect2.Left ,
aRect2.Bottom - aRect2.Top );
Image imgTopLeft = Image.FromFile( @"c:\skins\TopLeft.BMP");
Image imgTopMid = Image.FromFile( @"c:\skins\TopMid.BMP");
Image imgTopRight = Image.FromFile( @"c:\skins\TopRight.BMP");
Image imgBottomLeft = Image.FromFile( @"c:\skins\BottomLeft.bmp");
Image imgBottomMid = Image.FromFile( @"c:\skins\Bottom.bmp");
Image imgBottomRight = Image.FromFile(
@"c:\skins\BottomRight.bmp");
Image imgRight = Image.FromFile( @"c:\skins\Right.bmp");
Image imgLeft = Image.FromFile( @"c:\skins\Left.bmp");
g.DrawImageUnscaled(imgTopLeft,0,0);
g.DrawImage ( imgTopMid,imgTopLeft.Width ,0,
(Width - (imgTopRight.Width + imgTopLeft.Width) + 2) ,
imgTopMid.Height );
g.DrawImage ( imgTopRight,Width - imgTopRight.Width ,aRect.Top ,
imgTopRight.Width,imgTopRight.Height );
g.DrawImage (imgBottomLeft,aRect.Left,Height - imgBottomLeft.Height
,
imgBottomLeft.Width , imgBottomLeft.Height );
g.DrawImage (imgBottomMid,imgBottomLeft.Width ,Height -
imgBottomMid.Height ,
Width - imgBottomLeft.Width , imgBottomMid.Height );
g.DrawImage (imgBottomRight,Width - imgBottomRight.Width
,imgBottomRight.Height ,
imgBottomRight.Width , imgBottomRight.Height );
g.DrawImage (imgRight,Width-imgRight.Width ,imgTopRight.Height ,
imgRight.Width,Height - imgBottomRight.Height );
g.DrawImage (imgLeft,Left,imgTopLeft.Height ,
imgLeft.Width,Height);
g.Dispose ();
}
else
base.WndProc(ref m);
}
Any help>
images as the border.I have 8 images. ( topLeft.bmp, topmid.bmp
topright.bmp left.bmp, right.bmp bottomLeft.bmp. bottomMid.bmp and
BottomRight.bmp)
I tried to capture wm_ncpaint and did following. I seem to get only
the top set and not the bottom
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if ( m.Msg == 132 )
{
//handle hits here
}
else
if(m.Msg == 0x85) // (WM_NCPAINT)
{
Graphics g = Graphics.FromHdc(GetWindowDC(this.Handle));
Rectangle aRect2 = new Rectangle ();
GetWindowRect(this.Handle , ref aRect2);
Point pt = new Point ( aRect2.Left,aRect2.Top );
ScreenToClient( this.Handle,ref pt);
Point pt2 = new Point ( aRect2.Right,aRect2.Bottom);
ScreenToClient( this.Handle,ref pt2);
Rectangle aRect = new Rectangle (0 ,0,aRect2.Right - aRect2.Left ,
aRect2.Bottom - aRect2.Top );
Image imgTopLeft = Image.FromFile( @"c:\skins\TopLeft.BMP");
Image imgTopMid = Image.FromFile( @"c:\skins\TopMid.BMP");
Image imgTopRight = Image.FromFile( @"c:\skins\TopRight.BMP");
Image imgBottomLeft = Image.FromFile( @"c:\skins\BottomLeft.bmp");
Image imgBottomMid = Image.FromFile( @"c:\skins\Bottom.bmp");
Image imgBottomRight = Image.FromFile(
@"c:\skins\BottomRight.bmp");
Image imgRight = Image.FromFile( @"c:\skins\Right.bmp");
Image imgLeft = Image.FromFile( @"c:\skins\Left.bmp");
g.DrawImageUnscaled(imgTopLeft,0,0);
g.DrawImage ( imgTopMid,imgTopLeft.Width ,0,
(Width - (imgTopRight.Width + imgTopLeft.Width) + 2) ,
imgTopMid.Height );
g.DrawImage ( imgTopRight,Width - imgTopRight.Width ,aRect.Top ,
imgTopRight.Width,imgTopRight.Height );
g.DrawImage (imgBottomLeft,aRect.Left,Height - imgBottomLeft.Height
,
imgBottomLeft.Width , imgBottomLeft.Height );
g.DrawImage (imgBottomMid,imgBottomLeft.Width ,Height -
imgBottomMid.Height ,
Width - imgBottomLeft.Width , imgBottomMid.Height );
g.DrawImage (imgBottomRight,Width - imgBottomRight.Width
,imgBottomRight.Height ,
imgBottomRight.Width , imgBottomRight.Height );
g.DrawImage (imgRight,Width-imgRight.Width ,imgTopRight.Height ,
imgRight.Width,Height - imgBottomRight.Height );
g.DrawImage (imgLeft,Left,imgTopLeft.Height ,
imgLeft.Width,Height);
g.Dispose ();
}
else
base.WndProc(ref m);
}
Any help>