码迷,mamicode.com
首页 > 其他好文 > 详细

hdlg WM_INITDIALOG

时间:2019-10-09 12:21:25      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:ase   hwnd   return   设置字体   end   nfa   cpp   文本   stat   

https://www.cnblogs.com/gakusei/articles/1585212.html

//   “关于”框的消息处理程序。   
  LRESULT   CALLBACK   About(HWND   hDlg,   UINT   message,   WPARAM   wParam,   LPARAM   lParam)   
  {   
  static   HFONT   hfont_static;   //   自定义字体的句柄   
  static   HWND   hwnd_static;   //   Static   控件的句柄   
    
  switch   (message)   
  {   
  case   WM_INITDIALOG:   
  //   建立自定义字体   
  LOGFONT   lgf;   
  GetObject(GetStockObject(DEFAULT_GUI_FONT),   sizeof(lgf),   &lgf);   
  lgf.lfWeight   =   FW_BOLD;   
  hfont_static   =   CreateFontIndirect(&lgf);   
  //   设置字体   
  hwnd_static   =   GetDlgItem(hDlg,   IDC_MYSTATIC);   //***   
  SendMessage(hwnd_static,   WM_SETFONT,   (WPARAM)hfont_static,   (LPARAM)TRUE);   //***   
  return   TRUE;   
    
  case   WM_CTLCOLORSTATIC:   
  //   改变文本颜色和背景颜色   
  if((HWND)lParam   ==   hwnd_static)   
  {   
  SetTextColor((HDC)wParam,   0xff0000);   //***   
  }   
  else   
  {   
  SetTextColor((HDC)wParam,   GetSysColor(COLOR_WINDOWTEXT));   
  }   
  SetBkColor((HDC)wParam,   GetSysColor(COLOR_BTNFACE));   
  SetWindowLong(hDlg,   DWL_MSGRESULT,   (LONG)TRUE);   
  return   (LRESULT)GetSysColorBrush(COLOR_BTNFACE);   
    
  case   WM_COMMAND:   
  if   (LOWORD(wParam)   ==   IDOK   ||   LOWORD(wParam)   ==   IDCANCEL)     
  {   
  DeleteObject(hfont_static);   
  EndDialog(hDlg,   LOWORD(wParam));   //   销毁自定义字体   
  return   TRUE;   
  }   
  break;   
  }   
  return   FALSE;   
  }

  

hdlg WM_INITDIALOG

标签:ase   hwnd   return   设置字体   end   nfa   cpp   文本   stat   

原文地址:https://www.cnblogs.com/hshy/p/11640682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!