WIN32的代码怎么在MFC中使用?
我的MFC是基于对话框的,想将按钮美化为PNG图片,找到一个帖子有写好的类,只是实例代码是WIN32的,能帮我改成在MFC下可用的吗?谢谢!http://www.cnbl...
我的MFC是基于对话框的,想将按钮美化为PNG图片,找到一个帖子有写好的类,只是实例代码是WIN32的,能帮我改成在MFC下可用的吗?谢谢!
http://www.cnblogs.com/hoodlum1980/archive/2011/02/15/1954779.html
示例代码:
#define IDC_BUTTON1 0x2014
#define IDC_BUTTON2 0x2015
#define IDC_BUTTON3 0x2016
#define IDC_BUTTON4 0x2017
// 全局变量:
CImgButton g_Buttons[4]; //四个大按钮
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void GetAppFolderFileName(LPTSTR buffer, LPCTSTR shortFileName);
void OnCreate(HWND hWnd);
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static TRACKMOUSEEVENT tme;
switch (message)
{
case WM_CREATE:
{
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hWnd;
OnCreate(hWnd);
}
break;
case WM_COMMAND:
{
WORD ctlId = LOWORD(wParam);
switch(ctlId)
{
case IDOK:
case IDCANCEL:
DestroyWindow(hWnd);
return TRUE;
case IDC_BUTTON1:
case IDC_BUTTON2:
case IDC_BUTTON3:
return TRUE;
}
}
break;
case WM_PAINT:
{
int i;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
for(i=0; i<4; i++)
{
g_Buttons[i].OnPaint(hdc);
}
EndPaint(hWnd, &ps);
}
return TRUE;
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
{
int i;
int x = GET_X_LPARAM(lParam);
int y = GET_Y_LPARAM(lParam);
for(i=0; i<4; i++)
{
g_Buttons[i].OnMouseDown(x, y);
}
}
return TRUE;
case WM_LBUTTONUP:
超出字数了,没有贴完整 展开
http://www.cnblogs.com/hoodlum1980/archive/2011/02/15/1954779.html
示例代码:
#define IDC_BUTTON1 0x2014
#define IDC_BUTTON2 0x2015
#define IDC_BUTTON3 0x2016
#define IDC_BUTTON4 0x2017
// 全局变量:
CImgButton g_Buttons[4]; //四个大按钮
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void GetAppFolderFileName(LPTSTR buffer, LPCTSTR shortFileName);
void OnCreate(HWND hWnd);
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static TRACKMOUSEEVENT tme;
switch (message)
{
case WM_CREATE:
{
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hWnd;
OnCreate(hWnd);
}
break;
case WM_COMMAND:
{
WORD ctlId = LOWORD(wParam);
switch(ctlId)
{
case IDOK:
case IDCANCEL:
DestroyWindow(hWnd);
return TRUE;
case IDC_BUTTON1:
case IDC_BUTTON2:
case IDC_BUTTON3:
return TRUE;
}
}
break;
case WM_PAINT:
{
int i;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
for(i=0; i<4; i++)
{
g_Buttons[i].OnPaint(hdc);
}
EndPaint(hWnd, &ps);
}
return TRUE;
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
{
int i;
int x = GET_X_LPARAM(lParam);
int y = GET_Y_LPARAM(lParam);
for(i=0; i<4; i++)
{
g_Buttons[i].OnMouseDown(x, y);
}
}
return TRUE;
case WM_LBUTTONUP:
超出字数了,没有贴完整 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询