简单的步骤:在Windows中,每个窗体都有自己的字体.要改变其字体首先要CFont::CreateFont创建一个字体,然后用CWnd::SetFont选择此字体,赋给控件.但很多人可能会因为CreateFont的参数之多,望而却步.下面我介绍一下参数.
函数原型:
BOOL CreateFont( int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename );
参数说明:
nHeight :字体高度.>0:字体的高度值;=0:字体采用缺省直.<0:此值的绝对值为高度.
nWidth :字体宽度.
nEscapement :文本行的倾斜度.
nOrientation :字符基线的倾斜度.
nWeight :字体的粗细.如下:
.FW_DONTCARE
.FW_THIN
.FW_EXTRALIGHT
.....
bItalic :字体是否为斜体
bUnderline :字体是否带下划线
cStrikeOut :字体是否带删除线
nCharSet :字体的字符集
.ANSI_CHARSET
.DEFAULT_CHARSET
.SYMBOL_CHARSET
......
nOutPrecision :字符的输出精度
nClipPrecision :字符裁剪的精度
nQuality :字符的输出质量
nPitchAndFamily :字符间距和字体族(低位说明间距,高位说明字符族)
lpszFacename :字体名称
[程序实现]
假设你已有了名为My的对话框工程.并有一个ID=IDC_EDIT1的Edit控件.
class CMyDlg : public CDialog
{
public:
CFont m_Font;
........
};
BOOL CTMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//CFont m_Font;
m_Font.CreateFont(-11,0,0,0,100,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_SWISS,"Arial");
CEdit *m_Edit=(CEdit *)GetDlgItem(IDC_EDIT1);
m_Edit->SetFont(&m_Font,FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
小小说明:在OnInitDialog()中的//CFont m_Font;前的"//"号去掉,将类声明中的CFont m_Font;去掉会是什么结果?请自己试试.
相关推荐
设置Richedit控件中的字体格式
一、首先定义字体CHARFORMAT cf;ZeroMemory(&cf, sizeof(CHARFORMAT));cf1.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE |CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;cf1.dwEffects = CFE_BOLD; // 粗体(或其他CFE_ITALIC
MFC学习之修改设置控件字体显示和颜色参数
MFC控件是MFC类库中的一部分,提供了各种可视化界面元素,用于构建用户界面。以下是一些常见的MFC控件及其功能和属性设置:1、CButton(按钮):用于触发特定操作或执行选定动作的控件。可以设置文本、图像、样式等。2、CEdit(编辑框):用于接收和显示文本输入的控件。可以设置文本内容、大小、样式、限制输入等。3、CListCtrl(列表控件):用于以列表形式展示数据的控件。支持单列或多列数据,可以设置每列的数据类型、宽度、排序等。
MFC窗口各控件的颜色和字体的设置
很多人定义了基于MFC的程序项目,当设计界面使用控件时,却不知道如何对各控件进行字体与颜色的设计;其实这些修改是需要动手添加代码的,这方面的修改在控件属性里是没有现成的,这不同于.net定义的项目,它的是有直接属性修改的。我在原文的基础上做了修改与完善,也可参见原文 原文:http://www.study-code.com/visual-studio/vc/74759.htm 1、改变对话框的
如何修改几种控件的颜色和字体
设置控件颜色的主要目的是为了解决控件文字背景色不透明的问题。当向一个有背景色的界面上放置控件后,由于控件文字的背景色与界面背景色不符,使文字背后留下难看的灰块。现在我定义了可设置背景色和前景色的控件,只要使控件背景色与界面背景色相同,问题就解决了。设置控件颜色和字体时必须重载该控件对应的类,在其中加入相关的颜色控制和字体函数。各种控件的做法完全相同,只是重载的类不一样。注:对于静态文本控件
自绘CStatic背景、字体颜色
自绘CStatic背景、字体颜色
对static控件字体大小及颜色的设置
可以直接创建对象,进行设置。非常方便 能满足平常需要
更改static字体大小和颜色
1. 改变CStatic字体大小
Snort源代码编译 _ 采坑之旅(for Windows VS2015)
系统环境:Windows7 sp1 x64 编译环境:VS2015 SP1 Snort版本:2.9.12 daq版本:2.0.6 Snort官网:https://www.snort.org/downloads#snort-downloads 背景 最近需要实现一个类似网络防火墙的产品,主要参考Snort源码,先花了点时间简单读了下网上比较流行的《...
CStatic字体设置
CFont font;font.CreateFont(36,0,0,0,700,0,0,0, ANSI_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "arial");GetDlgItem("IDC_L
看完这篇爽文我终于学会了示波器(一)
示波器基础篇的介绍,希望对你有用,下次分享一下如何测试。
vivado2025安装教程:手把手带你完成环境配置
详细讲解vivado2025的安装步骤与环境配置技巧,帮助开发者快速搭建FPGA开发平台。涵盖常见问题解决方案,确保vivado2025稳定运行,提升开发效率。
CStatic设置字体大小及背景透明的方法
1.设置字体 方法:创建CFont m_Font.CreateFont(40, 25, 0, 0, 300, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP
防反接电路、防倒灌电路、过流保护和ESP相关知识
1.开关电源给负载供电, 如果负载是电池或者其他感性负载(比如像 电机 有线圈 当电源突然断掉时 会产生感应电动势)时, 当220V断掉的时候,可能会出现 电池反向给开关电源 的 输出端 供电,导致开关电源的一些莫名损坏。2.系统在不同的 输出电压 之间 切换时,会存在高压电压倒灌到低压电压源中。例如:系统 有两个电源供电 比如 一个电池 一个 充电器 充电器的电压一般会高于电池 如果没有防倒灌的电路 可能充电器的电压会直接倒灌给电池 造成电池的损坏。
如何在 ActiveX 控件中使用字体
字体的使用是ActiveX控件制作过程中不可缺少的部分。本文将深入浅出地介绍在ActiveX控件中制作过程中如何使用字体。本文所提及的ActiveX控件制作是指利用VC++6.0的MFC ActiveX ControlWizard 工具,用其它方法制作 ActiveX 控件本文不作讨论。 本文专门设置了一些例程,以便您能够更好地掌握这些内容。这些例程都是完整的ActiveX控件制作源代码。为
基于大模型的急性重症胰腺炎全流程预测与诊疗方案研究
本研究构建了基于大模型的急性重症胰腺炎(SAP)全流程预测与诊疗系统,实现了从术前风险评估到术后康复管理的精准诊疗闭环。通过整合临床信息、实验室检查和影像学等多源数据,模型在测试集上预测准确率达X%,AUC为X,显著优于传统评分系统。研究创新性地将预测结果应用于手术方案制定、麻醉决策、并发症防控及个性化护理,形成智能化诊疗方案。验证结果显示模型具有良好的稳定性和临床适用性,同时配套的健康教育体系提升了患者自我管理能力。尽管存在样本局限性和模型可解释性等不足,该研究为SAP的精准诊疗提供了新范式,未来可通过扩
超声波雾化驱动设计:专用芯片FM8118替代MCU的工程实践
超声波雾化是一种基于压电陶瓷谐振原理的高频能量转换技术,其核心在于在1.6–2.4MHz频段精准激励雾化片以实现高效水分子破碎。传统采用通用MCU配合分立MOSFET的方案受限于PWM频率上限、栅极驱动能力不足及EMI控制困难,导致雾化效率低、温升高、可靠性差。专用雾化芯片(如FM8118)通过集成2.1MHz振荡器、零电压开关(ZVS)控制与过流/过热双重保护,从架构层面解决高频功率驱动的本质约束,显著提升驱动效率(达83.7%)与系统鲁棒性。该技术广泛适用于桌面加湿器、医疗雾化器、农业微喷等对体积、功耗
修改按钮控件上的字体
有时候需要修改某一个按钮上的字体,可用如下方法: //令控件字体变大变粗 HWND m_hName=::GetDlgItem(m_hWnd,IDC_PRTSTP_SET);//通过控件ID获取控件句柄 HFONT hFont = (HFONT)::SendMessage( m_hName, WM_GETFONT, 0, 0 ); //得到设备字体 if(hFont==0)
Jupyter notebook教程系列(二)Jupyter notebook的基本用法
Jupyter notebook的基本使用 一. 主页面 如图1-1 我们先介绍一下主页面上的内容: 1.Files页面是用于管理创建文件相关类目的。 2.Running页面主要展示的是当前正在运行当中的终端和“ipynb”格式的notebook。若想要关闭已经打开的终端和“ipynb”格式的notebook,仅仅关闭其页面是无法彻底退出程序的,需要在Running页面点击其对...
android控件字体设置,android 设置控件的颜色字体的方法
1.用代码设置控件的颜色:int b = getresources().getcolor(r.drawable.blue);//得到配置文件里的颜色mbutton.settextcolor(b);2.设置空间的字体:方式一:mtext.settypeface(typeface.createfromasset(getassets(),"fonts/handmadetypewriter.ttf"))...
如何在 Linux 上安装 RTX 5090 / 5080 /5070 Ti / 5070 驱动程序 — 详细指南
Linux 上的 NVIDIA 5090 是 AI、游戏和渲染的强大引擎,但需要耐心。如果稳定性是首要考虑因素,请坚持使用开源驱动程序,并关注 NVIDIA 论坛以获取未来更新。
Camera2Demo
在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作
MFC控件内字体大小随控件改变
达到的效果是EDIT控件变大字体也相应的变大,EDIT控件变小字体也相应的变小。 步骤一:在Dlg类中增加一个类成员变量 在VS2015中,点击VS左上方的项目选项,选择类导向 点击添加自定义。添加的类成员变量如下: CFont m_editFont; 步骤二:为edit控件绑定一个控制变量 找到edit控件,鼠标右击选择添加变量 步骤三:在OnInitDialog()中添加如...
复分析 阿尔福斯(Ahlfors) 第三版答案 英文
答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案
vc中控件字体的设置
和所有初学者一样,刚开始接触新的东西,总想把画面做的漂亮些,可是在vc中很难做到,比如对话框中按钮等控件的字体设置,就颇费了我一番功夫。 一。做成一个函数,改变字体大小,方法如下: 1。在最开头声明一个全局的字体指针 CFont *my_font=new CFont();//注意初始化,不能为空 2。在需要改变字体的地方调用函数: set_font(60
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
TMS_WebGMaps_1.9.8.0_Full_Source
TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder
VC中控件字体与文本颜色的设置
VC中控件字体与文本颜色的设置 标签: VC中控件字体与文本颜色的设置 设置字体 函数原型: BOOL CreateFont( int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE b
控件字体及颜色设置
<br />很多人定义了基于MFC的程序项目,当设计界面使用控件时,却不知道如何对各控件进行字体与颜色的设计;其实这些修改是需要动手添加代码的,这方面的修改在控件属性里是没有现成的,这不同于.net定义的项目,它的是有直接属性修改的。我在原文的基础上做了修改与完善,也可参见原文<br />原文:http://www.study-code.com/visual-studio/vc/74759.htm<br /><br />1、改变对话框的底色<br />在对话框的类中添加一个 private : CBrush
Qml控件设置字体样式
Qml中的部分组件支持设置字体样式,如Control控件有font属性,可以用来设置字体样式(除了字体的颜色),按照正确的格式编写才可以运行正常。 正确编写格式如下: import QtQuick 2.0 import QtQuick.Controls 2.14 Button { text: "测试" font{ pixelSize: 20 } // 1.这种方式设置错误 // font:{ // pixe
更改控件字体和字号
这个是在一个讨论里面找到的,还是可以用的。 具体可以看代码 //设置字体参数 LOGFONT LogFont; ::memset(&LogFont, 0, sizeof(LOGFONT)); lstrcpy(LogFont.lfFaceName,TEXT ("宋体"));//具体名称可查C:\WINDOWS\Fonts LogFont.lfWeight = 400;//字体线条宽度 LogFont.lfHeight = 20;//字体大小 LogFont.lfCharSe
7162




被折叠的 条评论
为什么被折叠?



