⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fontcontrols.h

📁 在vc环境下通过比较简单的方法实现了修改字体、字体颜色和修改背景颜色等基本功能。
💻 H
字号:
#ifndef FONTCONTROLS_H
#define	FONTCONTROLS_H

#define STRICT
#include <windows.h>
#include <commctrl.h>
#pragma comment(lib,"comctl32.lib")

#define CHANGETEXT	1000
#define CHANGEBKG	1001
#define CHANGEFONT	1002
//NEW CODE
#define NTXFONTHEIGHT(PointSize, hDC) (-MulDiv((PointSize), GetDeviceCaps(hDC, LOGPIXELSY), 72))
//
	HWND			main,combo,edit,button,list,stat,
					changetxtcolor,changebkcolor;
	HDC				hdc,hdc2;
	PAINTSTRUCT		ps;
	COLORREF		backcolor = RGB(255,255,255),
					textcolor = RGB(0,0,0),
					currentcolor = RGB(0,0,0);
	CHOOSECOLOR		choosecolor;
	HBRUSH			hbrush;
	//new stuff
	HWND			changefont;
	HFONT			currentfont;
	CHOOSEFONT		choosefont;
	LOGFONT			logfont;

void SetupChooseColor(CHOOSECOLOR *cc,COLORREF *customclrs,HWND hwnd,COLORREF &init)
{
	int ca;
	for(ca = 0;ca<16;ca++){*(customclrs+ca) = RGB(255,255,255);}
	cc->lStructSize = sizeof(CHOOSECOLOR);
	cc->hwndOwner = hwnd;
	cc->rgbResult = init;
	cc->lpCustColors = customclrs;
	cc->Flags = CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
}
//NEW CODE
void SetupChooseFont(HWND hwnd,HFONT &cfont,LOGFONT &lfont)
{
	choosefont.lStructSize = sizeof(CHOOSEFONT);
	choosefont.hwndOwner = hwnd;
	choosefont.lpLogFont = &lfont;
	choosefont.rgbColors = RGB(0,0,0);
	choosefont.Flags = CF_FORCEFONTEXIST|CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT;
	cfont = CreateFont(NTXFONTHEIGHT(10,GetDC(hwnd)),0,0,0,FW_REGULAR,0,0,0,ANSI_CHARSET,0,0,PROOF_QUALITY,DEFAULT_PITCH,"Tahoma");
}
void SetFont(HWND fhwnd)
{
		SendMessage(fhwnd,WM_SETFONT,(WPARAM)currentfont,MAKELPARAM(true,0));
}
void UpdateFonts(void)
{
	SetFont(main);
	SetFont(changefont);
	SetFont(combo);
	SetFont(button);
	SetFont(list);
	SetFont(stat);
	SetFont(changetxtcolor);
	SetFont(changebkcolor);
	SetFont(edit);
}
//

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -