Many programmers have this experience, their own program is very beautiful, but in the Windows Platform Development program is always not escape the Windows default style constraints. The title bar, the toolbar, the same style makes the creative works fade. Here we have a surgical procedure for the dialog box application, which is intended to introduce a method to your readers and hope that you will have further development on this basis.
This example is based on a dialog application, painting a non-customer area, finishing the application landscaping, the code will run the following effect diagram:
Now let's explore the specific implementation process
First, define resources:
Add a bitmap resource for the system button (use 10 bitmaps in this example to display Help, minimize, maximize, restore, and turn off the normal state and focus state of the button, which can be customized as required by the program)
Second, define global variables and functions:
CRect m_rtButtExit; //关闭按钮位置
CRect m_rtButtMax; //最大化按钮位置
CRect m_rtButtMin; //最小化按钮位置
CRect m_rtButtHelp; //帮助按钮位置
CRect m_rtIcon; //图标位置
void DrawTitleBar(CDC *pDC); //画非客户区主函数
Third, function implementation:
This example requires the following message to be overloaded DefWindowProc, On_wm_ncmousemove, On_wm_nclbuttondown.
The function implementation body is as follows:
Main function, which can be used to draw the form according to the actual situationvoid CTitleBarDlg::DrawTitleBar(CDC *pDC)
{
if (m_hWnd)
{
CBrush Brush(RGB(0,100,255));
CBrush* pOldBrush = pDC->SelectObject(&Brush);
CRect rtWnd, rtTitle, rtButtons;
GetWindowRect(&rtWnd);
……………………………..
//因代码过长,未贴,见源程序
……………………………...
}
}