/************************主窗口回调函数(放置编辑框的窗口)************************/
LRESULT CALLBACK ProcMain(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_CLOSE:
EndDialog(hDlg, 0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return 0;
}
case WM_CLOSE://单击了“关闭”之后,进入最小化状态
ShowWindow(hDlg, SW_MINIMIZE);
break;
WNDPROC OldProc;//设置自己的窗口过程函数
OldProc = (WNDPROC)SetWindowsLong(hWnd, GWL_WNDPROC, (LONG)NewProc/*自己的窗口过程函数*/);
case WM_CTLCOLORSTATIC://设置静态文本框颜色(一个超级链接)
if (GetDlgItem(hDlg, IDC_ST_HOMEPAGE) == (HWND)lParam)
{
SetTextColor((HDC)wParam, 0xff0000);
SetBkMode((HDC)wParam, TRANSPARENT);
return (LRESULT)CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
}
break;
/************************子窗口回调函数(编辑框窗口)************************/
case WM_INITDIALOG://设置窗口过程函数
EditProc = (WNDPROC)SetWindowLong(GetDlgItem(hDlg, IDC_EDIT), GWL_WNDPROC, (LONG)ProcFloat);//编辑框
StaticProc = (WNDPROC)SetWindowLong(GetDlgItem(hDlg, IDC_ST_HOMEPAGE), GWL_WNDPROC, (LONG)ProcLink);//静态文本框 break;
/************************编辑框回调函数(编辑框窗口)************************/
LRESULT CALLBACK ProcFloat(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if (Msg == WM_CHAR && wParam != ''.'' && (wParam <= ''0'' || wParam >= ''9'') && wParam != VK_BACK)/*不完善自己完善,其他可以加剪贴板*/
{
MessageBeep(MB_OK);
return 0;
}
else
return CallWindowProc(EditProc, hWnd, Msg, wParam, lParam);
}
/************************静态文本框回调函数(编辑框窗口)************************/
LRESULT CALLBACK ProcLink(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_SETCURSOR://设置鼠标在上面时候形状(手型)
SetCursor(LoadCursor(NULL, IDC_HAND));
break;
case WM_LBUTTONDOWN://实现超级链接
ShellExecute(NULL, "open", "http://home.ncust.edu.cn/~titilima", NULL, NULL, SW_SHOWNORMAL);
break;
default:
return CallWindowProc(StaticProc, hWnd, Msg, wParam, lParam);//消息回调
}
return 0;
}