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 font if(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; }
时间: 2024-10-12 16:25:21