# Region change the window style
# If! Debug
[Dllimport ("user32.dll")]
Private Static extern intptr getwindowdc (intptr hwnd );
[Dllimport ("user32.dll")]
Private Static extern int releasedc (intptr hwnd, intptr HDC );
Protected override void wndproc (ref message m)
...{
Base. wndproc (ref m );
Switch (M. msg)
...{
Case 0x86: // wm_ncactivate
Goto case 0x85;
Case 0x85: // wm_ncpaint
...{
Intptr HDC = getwindowdc (M. hwnd );
// Convert DC to. Net Graphics to easily use the drawing function provided by the framework.
Graphics GS = graphics. fromhdc (HDC );
Processing color # region processing color
Int ibox = 1;
If (this. maximizebox) ibox ++;
If (this. minimizebox) ibox ++;
// Obtain the background image.
Image imgpm = image. fromfile (application. startuppath + @ "main.bmp ");
// Gs. drawimage (imgbg, 3, 0, this. Width-(ibox * iboxwidh), systeminformation. captionheight + 2); // display the background image
// Display the background color in the title bar
Int xpos = This. Width-iboxwidh * ibox-2-ibox * 3;
Rectangle excluderect;
// The position in the title bar that does not need to be filled
For (INT I = 0; I <ibox; I ++)
...{
If (I> 0)
...{
Xpos = xpos + iboxwidh + 2;
}
Excluderect = new rectangle (xpos, 5, iboxwidh, iboxwidh + 1 );
GS. excludeclip (excluderect );
}
// Background area
Rectangle rbackground = new rectangle (0, 0, this. Width, systeminformation. captionheight + 3 );
// Gradient of the background color
System. Drawing. drawing2d. lineargradientbrush bbackground
= New system. Drawing. drawing2d. lineargradientbrush (rbackground, color. fromargb (100,145,175), color. fromargb (120,), lineargradientmode. Vertical );
// Fill the background color in the title bar
GS. fillrectangle (bbackground, rbackground );
// Display the icon file
GS. drawimage (imgpm );
# Endregion
Stringformat strfmt = new stringformat ();
// Strfmt. Alignment = stringalignment. Center;
// Strfmt. linealignment = stringalignment. Center;
// Gs. drawstring (this. text, this. Font, brushes. blchedalmond, m_rect, strfmt );
// Set the title Font
Font drawfont = new font ("", 10, system. Drawing. fontstyle. Bold );
// Set the title Color
Solidbrush drawbrush = new solidbrush (color. White );
// Re-draw the title
GS. drawstring (this. Text, drawfont, drawbrush, 30, 8 );
GS. Dispose ();
// Release the GDI resource
Releasedc (M. hwnd, HDC );
Break;
}
Case 0xa1: // wm_nclbuttondown
...{
Point mousepoint = new point (INT) M. lparam );
Mousepoint. offset (-This. Left,-This. Top );
// If (m_rect.contains (mousepoint ))
//{
//
// MessageBox. Show ("hello ");
//
//}
Break;
}
}
}
# Endif
# Endregion