delphi开发实例:保存字体设置的方法

delphi操作word delphi操作word一、Delphi程序启动Word采用CreateOleObjects的方法来启动Word,调用VBA代码,具体实现过程为:首先使用GetActiveOleObject(Word.Application)判断当前内存中是否存在Word程序,如果存在,则直接连接,如果没有Word程序,则使用CreateOleObject(Word.Application)启动Wor 阅读详情
记得一年前软件里面用到字体设置时,想把字体信息保存到配置文件里面都是把相应的属性分开来保存一下,这样一直使用,最近想delphi自己的dfm文件也同样会保存这些信息,它又是怎样保存的呢。。 

用记事本打开dfm文件会看到类似这样的文本: 

object Label1: TLabel 
Left = 24 
Top = 32 
Width = 140 
Height = 46 
Caption = #20445#23384#23454#20363 
Font.Charset = GB2312_CHARSET 
Font.Color = clBlue 
Font.Height = -35 
Font.Name = #24494#36719#38597#40657 
Font.Style = [fsBold, fsUnderline, fsStrikeOut] 
ParentFont = False 
end 

自己写了个直接保存成文件文件的,记录一下 

unit Font2String; 

interface 

uses 
Classes, SysUtils, Dialogs, Graphics; 

function Font2File(AFont: TFont; APath: string): Boolean; 
function File2Font(APath: string; AFont: TFont): Boolean; 

implementation 

function Font2File(AFont: TFont; APath: string): Boolean; 
var 
FD: TFontDialog; 
begin 
Result := False; 
FD := TFontDialog.Create(nil); 
try 
FD.Font.Assign(AFont); 
WriteComponentResFile(APath, FD); 
Result := True; 
finally 
FD.Free; 
end; 
end; 

function File2Font(APath: string; AFont: TFont): Boolean; 
var 
FD: TFontDialog; 
begin 
Result := False; 
FD := TFontDialog.Create(nil); 
try 
ReadComponentResFile(APath, FD);//如果此外为nil,下面的注册去掉 
AFont.Assign(FD.Font); 
Result := True; 
finally 
FD.Free; 
end; 
end; 

//initialization 
//RegisterClass(TFontDialog); 

end. 

例子:

procedure TForm1.Button1Click(Sender: TObject); 
begin 
Font2File(Label1.Font, 'd:\Font.fnt');//把字体保存成文件 
end; 

procedure TForm1.Button2Click(Sender: TObject); 
begin 
File2Font( 'd:\Font.fnt', Label2.Font);//从文件里读取字体 
end;
Delphi中建立指定大小字体和读取该字体点阵信息的函数  Delphi中建立指定大小字体和读取该字体点阵信息的函数作者:ThermometerEmail:  webmaster@daheng-image.com  由于要控制硬件,需要把矢量的汉字转化为点阵信息写入eprom或在液晶屏上显示,因此用Delphi写了如下的函数,可以把指定的一个汉字(两个字符)转化为点阵信息保存到文件,每个点对应一个二进制位,有文字信息该位为1,否则为0。  阅读详情

相关推荐

Delphi操作Word文档:段落和字体处理示例程序

是Delphi中用于控制Microsoft Word应用程序的一个主要接口。它是基于COM(Component Object Model)技术的对象模型,允许开发者通过Delphi程序实现对Word文档的自动化处理,包括创建、打开、编辑、格式化文档以及其它各种复杂操作。该对象的重要之处在于,它提供了一个编程的方式来执行原本需要手动在Word软件中执行的任务,使得可以将这些任务集成到更大的应用程序中,实现高效的文档处理工作流程。

weixin_32287387的博客 958

delphi保存字体设置

记得一年前软件里面用到字体设置时,想把字体信息保存到配置文件里面都是把相应的属性分开来保存一下,这样一直使用,最近想delphi自己的dfm文件也同样会保存这些信息,它又是怎样保存的呢。。 用记事本打开dfm文件会看到类似这样的文本: object Label1: TLabel Left = 24 Top = 32 Width = 140 Hei...

weixin_30569153的博客 272

Delphi绘图工具开发实践教程

本文还有配套的精品资源,点击获取 简介:本资源主要关注使用Delphi语言进行Windows桌面应用程序的绘图。通过介绍TCanvas组件、绘图方法、颜色与刷子、图形变换、文本绘制及事件响应等关键技术点,结合具体实例代码,旨在帮助初学者掌握Delphi绘图的基础技巧。同时提供了图形保存与加载的方法,并附带了可能包含项目说明的"***.txt"文件。 1. Delp...

weixin_33481022的博客 1179

Delphi 样例-属性编辑器

运行效果如下 窗体布局 object Form1: TForm1 Left = 0 Top = 0 Caption = #31034#20363'-'#23646#24615#32534#36753#22120 ClientHeight = 243 ClientWidth = 527 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -

男神的专栏 1036

Delphi操作Excel的核心属性与方法指南

Delphi中实现Excel自动化的核心在于使用OLE(对象链接与嵌入)技术。通过这种方式,Delphi程序可以像操作本地对象一样操作Excel对象,包括但不限于工作簿、工作表以及单元格内容。自动化接口允许开发者在Delphi应用程序中直接创建和控制Excel进程,甚至无需用户交互即可完成复杂的数据操作任务。usesComObj;varbegin// 显示Excel进程// 更多操作...end;在上述代码中,我们首先引用了ComObj单元,这允许Delphi创建COM对象。

weixin_42430341的博客 1267

delphi XE10实现自定义字体

delphi XE10实现自定义字体,在窗口上或者任意控件上实现自带的字体显示效果,对注重程序效果的人来说是很实用的例子。

Delphi公共函数(二)

procedure TPub.ConSaveTreeViewToTextFile(Nodes: TTreeNodes; Filename: string);var  F: TextFile;   procedure ProcessNode(Node: TTreeNode; Depth: Integer);  begin    while Node     begin      Writeln(F,

平民 1188

Delphi 保存字体信息

Delphi,将字体信息保存在ini中,已实现

Delphi默认窗体随想

Delphi中新建一个Form或者Frame时,它的字体都是西文习惯,这样就有可能造成在其他机器上由于字体的原因,窗体十分不美观.怎样才能为Delphi设置一个默认窗体,让它的字体Font符合中国习惯呢,而不用新建时再手工去修改窗体的Font,下面就是解决这个问题的方法.并且随之引出了Delphi的一个非常好的功能:1.新建窗体符合中国字体习惯  (1)一定要将窗体的Font属性修改为:    

敦格 2503

delphi简单的字体、颜色设置、打开文件、保存等功能的简单实现完整源代码

我自己整理的delphi简单的字体、颜色设置、打开文件、保存等功能的简单实现完整源代码

Vivado XDMA仿真实战:从配置到链路训练全解析

本文深入解析了Vivado中XDMA IP核的仿真实战流程,重点剖析了PCIe链路训练状态机(LTSSM)的工作原理与调试方法。通过搭建仿真环境、解读日志与波形,手把手指导如何从配置、链路训练(LTSSM)到BAR映射与DMA启动进行全流程分析与问题定位,帮助工程师掌握核心调试技能,确保PCIe链路稳定与数据传输正确。

weixin_29197051的博客 154

delphi 应用程序开发工具

delphi   应用程序开发工具 Delphi,是Windows平台下著名的快速应用程序开发工具(Rapid Application Development,简称RAD)。它的前身,即是DOS时代盛行一时的“BorlandTurbo Pascal”,最早的版本由美国Borland(宝兰)公司于1995年开发。主创者为Anders Hejlsberg。经过数年的发展,

bestlove12345的博客 9775

PaddleOCR PP-OCRv5实战:5分钟搞定身份证信息提取(附完整代码)

本文详细介绍了如何利用PaddleOCR的PP-OCRv5模型,在5分钟内快速搭建身份证信息提取流程。文章从环境搭建、核心代码实战出发,深入解析了PP-OCRv5针对证件识别的优化特性,并提供了从OCR结果到结构化数据的完整处理方案与避坑指南,帮助开发者高效实现AI驱动的自动化信息提取。

salt9的博客 783

delphi 颜色,字体保存到INI文件

颜色转换成整型保存{也可以用ColorToString / stringTOColor}字体用下面的函数转换成字符串,然后保存unitxFonts;interfaceusesClasses,Graphics,SysUtils;procedureStringToFont(sFont:string;Font:TFont;bIncludeColor:Boolean...

dianqi2245的博客 361

60、拓扑码:从理论到应用

本博客深入探讨了拓扑码的基本理论、构造方法及其在量子计算中的应用。重点介绍了颜色码的拓扑起源、编码量子比特的计算方法、弦算子的构造与性质、边界条件的影响、同调描述以及与统计模型相关的错误阈值分析。同时,还涵盖了拓扑码的历史发展、与其他拓扑码的关系、与凝聚态系统的联系,以及其在激发态和高维中的表现。博客展示了拓扑码在容错量子计算和未来量子信息领域的广阔前景。

o1p2q3r的博客 129

LangGraph 实战教程:搭建一个智能办公多Agent协作平台

只存储必要的信息:不要把所有的原始数据都存储在状态中,比如销售数据可以存储在数据库或向量数据库中,状态中只存储数据的 ID 或摘要。使用类型提示:避免类型错误,提高代码的可维护性。支持增量更新:LangGraph 默认支持状态的增量更新(通过reduce函数),比如messages列表可以通过追加新消息的方式更新,而不是每次都重新创建整个列表。Normal Edge 的定义非常简单,只需要在StateGraph对象(稍后会详细讲解)上调用add_edge# 创建一个 StateGraph 对象。

SuperAGI2025 221

Delphi 操作Excel方法大全

Delphi操作Excel大全 原文地址:http://blog.youkuaiyun.com/lailai186/article/details/6664110 Delphi 控制Excel (一) 使用动态创建的方法 首先创建 Excel 对象,使用ComObj: var ExcelApp: Variant; ExcelApp := CreateOleObject( ‘Excel.Application’ ); 显示当前窗口: ExcelApp.Visible := True; 更改 Excel 标题栏: Ex

xiaobin_zb的博客 6613

用Excel或WPS做两独立样本的T检验

一般情况下收集数据时常用的是Excel或者WPS,但统计时却用SPSS等软件进行统计学分析,经常很多人找不到SPSS的安装包,或者苦于正版激活或忘记教程,其实Excel或WPS自带函数就足够了,均数、标准差以及统计检验都是一个函数而已。解释:先做F检验,如果F>0.05就做T检验,Ttset里的数据为两组的数据的比较,结果如下。A组的均数计算 =AVERAGE(B2:B6)A组的标准差计算 =STDEV(B2:B6)B组的标准差计算=STDEV(B7:B19)分组 数值 A组均数 A组标准差 p值。

Mrrunsen的博客 6752

【3.Delphi常用组件】8.对话框

8.对话框 在Delphi中提供了一系列标准对话框。 8.1 打开文件对话框OpenDialog 组件OpenDialog用于打开一个已经存在的文件,当选择一个文件后,选择的文件通过OpenDialog的FileName属性。其主要属性如下: 属性 说明 DefaultExt 设置默认的文件扩展名 Filter 设置可打开的文件类型 FilterIndex 设置默认的Filter值,索引从1开始 InitialDir 设置对话框打开的初始化路径 Op

chenhaiy的博客 1978

ArcGIS实验教程——实验二十五:大型商场选址经典案例

本实验基于ArcGIS平台进行商场选址分析,综合考虑道路、居民点、停车场和已有商场四个影响因素。通过缓冲区分析建立各要素的影响范围(道路50米、居民点100米、停车场100米、已有商场500米),采用叠加分析中的相交和擦除运算确定最优选址区域。实验建立了区位评价体系,通过属性赋值(1/-1)和联合运算生成综合评价结果,并实现分级可视化显示。注意事项包括距离参数设置对结果的影响以及正确选择空间分析工具。该流程为商业选址提供了科学的GIS解决方案。

智慧空间实验室 1万+

从苏宁电器到卡巴斯基(第二部)第14篇:我在卡巴的日子 XIV

目录 WannaCry 我的感慨 邻里矛盾 WannaCry 如果大家对于科技互联网圈子的新闻比较感兴趣的话,相信会对2017年5月的“WannaCry勒索病毒”事件记忆犹新,因为这个病毒在当时的全世界范围内掀起了极大的波澜,众多的企事业单位深受其害,造成的金钱和数据损失难以估量,从某种意义上来说,它甚至引领了勒索病毒新一轮的爆发浪潮。而通过这样的一次爆发,也让我对于卡巴斯基的技术实力有了更进一步的了解。 我记得很清楚,爆发的那天是周六,没记错的话Seth那天有事,就请假没来,只有我自己在公司值

Gleam的专栏 4919

delphi的StatusBar状态控件调整字体大小颜色

  最近在做一个小项目,是用delphi7 开发的,delphi刚学不久,也是自学的,应客户要求,状态栏的字体要变大一点,我在属性里面已经把字体调大了,但是F9运行以后还是不行,现在将方法贴出,以供参考。   1.找到 Statusbars.Panels   的属性编辑器 (点击Stat控件,在Object Inspector窗口的Panels属性,右边有个按钮),进去之后,将每个Panel...

cfeers 1916

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

delphi嵌入记事本_创建一个Delphi记事本:打开并保存

delphi嵌入记事本 While working with various Windows applications and Delphi, we've become accustomed to operating with one of the standarddialog boxesfor opening and saving a file, finding and replacing ...

cumao2792的博客 770

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

delphi 保存FontDialog设置到ini文件

public { Public declarations } procedure SetIniFile(Strtitle, StrName :String;FileName : String); function ReadIniFile(Strtitle, StrName :String): String; function TForm11.ReadI...

weixin_30553065的博客 249

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: Delphi遍历控件
下一篇: 如何取得 fontdialog 的字体名称、大小等内容
delphi308
博客等级 码龄18年 148粉丝 28原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值