[ATL/WTL]_[初级]_[常用的界面对象操作]

来源:互联网 发布:淘宝2017销售额下滑 编辑:程序博客网 时间:2024/05/17 01:11


1. 获取指定大小字体

HFONT AppUtil::GetFont(int pixel,bool bold,const wchar_t* font_name){LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); // zero out structure lf.lfHeight = pixel; // request a 8-pixel-height fontif(bold){lf.lfWeight = FW_BOLD;  }lstrcpy(lf.lfFaceName, font_name); // request a face name "Arial"HFONT font = ::CreateFontIndirect(&lf);return font;}

2.  使用默认浏览器打开超链接

void AppUtil::OpenUrl(std::string url){::ShellExecuteA(NULL, "open", url.c_str(),NULL, NULL, SW_SHOWNORMAL);}

3.  打开文件夹

void AppUtil::OpenFolder(std::wstring output_dir_){::ShellExecute(NULL, L"explore",output_dir_.c_str(), NULL, NULL, SW_SHOWNORMAL);}

4.  获取DC的作用Bitmap大小

BITMAP GetDCBitmapSize(HDC hdc){BITMAP structBitmapHeader;memset( &structBitmapHeader, 0, sizeof(BITMAP) );HGDIOBJ hBitmap = GetCurrentObject(hdc, OBJ_BITMAP);GetObject(hBitmap, sizeof(BITMAP), &structBitmapHeader);return structBitmapHeader;}


5. 设置CComboBox的文本框只读 (20150714)

CEdit edit_text = box->GetWindow(GW_CHILD);edit_text.EnableWindow(TRUE);edit_text.SetReadOnly(TRUE);




0 0
原创粉丝点击