在设置按钮自绘的时候, 按钮必须设置为 所有者 自绘 这个属性,也就是BS_OWNERDRAW属性。
如果按钮是直接拖到对话框的,那么则需要勾选上所有者绘制 这个选项,如下图
。 这是第一步。
然后就是处理你所在窗口过程中的 WM_DRAWITEM消息。
下面是具体的实例代码,代码很简单。 不多说了。
也可以直接去 我上传的资源中下载 就可以看到效果。
// test90.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include <stdio.h>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
HINSTANCE app;
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LR