我试图在Delphi XE2中将一个组件从一个数据模块复制并粘贴到另一个数据模块中.该组件是快速报告数据源链接组件.数据模块是全新的,仅在XE2中创建了第二个.
其他人有同样的问题并在质量中心上报告为106369和相同的错误消息导致我这个神秘的DocWiki条目.
因此,数据模块现在具有框架关联性和仅设计时的伪属性,根据文档:
"因为ClassGroup伪属性仅由IDE使用,而不是编译器生成的属性(因此,'伪属性'),所以在编译器生成的库参考中没有记录ClassGroup.您正在阅读的页面是ClassGroup的文档."
所以,我第一次学习这个存在就是它阻止我从现有的一组设计时构建块中复制和粘贴组件到我的数据模块中,我不希望从头开始重建.
一旦我改变了数据模块的亲和力,我就可以将东西粘贴到数据模块中,而不会让我烦恼.谢天谢地,谷歌那个错误或者我被困住了.
如果它旨在帮助我们编写跨平台数据模块,但它只影响IDE,根据文档,这与你在设计时使用它时得到的警告不一致,这是你在改变时得到的错误它:
EInvalidType : The following component(s) are not available in the specified
class group. This is likely to cause compile or runtime errors.
frxDBSet.TfrxDBDataset.
Run Code Online (Sandbox Code Playgroud)
我看不到的是错误信息是如何正确的,文档也可以是正确的.
如果设置不正确,警告似乎表明编译,链接和运行时错误.想要知道真正发生了什么的好奇心灵想知道:这是什么东西以及为什么它被添加到XE2中的数据模块中.我预计其他人会偶然发现这个奇怪的功能,感觉他们已经介入恐龙粪便之类的东西,并想知道这个功能是什么.
我在这一点上的最佳答案是TPersistent的数据模块亲和性,这意味着,在XE2术语中,该数据模块不需要非可视控件,这是VCL特定的.在Delphi的未来版本中,也许类似的标记允许我们将表单标记为"清除对VCL或Windows的依赖"?
更新1:数据模块的.PAS源代码以类似于编译器指令的方式存储此伪属性,如下所示:
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
Run Code Online (Sandbox Code Playgroud) 请在标记为重复之前阅读.
我正在创建一组依赖智能卡进行身份验证的应用程序.到目前为止,每个应用程序都单独控制了智能卡读卡器.几周后,我的一些客户将同时使用多个应用程序.所以,我想也许创建一个控制身份验证过程的服务应用程序会更实际.我希望我的桌面应用程序告诉他们对身份验证过程感兴趣的服务应用程序,然后服务应用程序会向他们提供有关当前用户的信息.这个部分很容易使用named pipes.难的是,如何能服务告知已发生的事件的桌面应用程序(UserLogIn,UserLogOut,PermissionsChanged,...仅举几例).到目前为止,我有两种方法.CallBack功能,和Messages.有没有人有更好的主意?我确定有人.
在Win2008R2上的PowerShell 2.0中,如果我想从注册表项获得相同的输出,"REG QUERY"将以可读的格式提供给我,使用来自特定注册表项的值,如下所示:
reg query hkcu\Software\Microsoft\CharMap
HKEY_CURRENT_USER\Software\Microsoft\CharMap
Advanced REG_DWORD 0x0
CodePage REG_SZ Unicode
Font REG_SZ Arial
Run Code Online (Sandbox Code Playgroud)
我如何使用PowerShell做到这一点?PowerShell的行为再一次使我神秘.
Get-ItemProperty示例:
Get-ItemProperty HKCU:\Software\Microsoft\CharMap
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\CharMap
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft
PSChildName : CharMap
PSDrive : HKCU
PSProvider : Microsoft.PowerShell.Core\Registry
Advanced : 0
CodePage : Unicode
Font : Arial
Run Code Online (Sandbox Code Playgroud)
在我上面的设计示例中,我希望看到"高级","CodePage"和"字体",但不是任何PowerShell元数据(以PS开头的名称).遗憾地过滤名称"PS"对我来说不起作用,因为我并不真正尝试阅读MS Windows字符映射设置,我只是选择它们作为一个注册表项,可能每个人都有Windows,所以每个人都可以看到完全如此不同于使用PowerShell的经验是看一下注册表,相比之下说该REG.EXE程序.有理由说任何人可能想要从注册表项中获取注册表值而不获取任何元数据,并且任何在PowerShell中编写工具的人都可能想要执行这个简单的任务.
我希望输出类似REG QUERY但仍然是原生PowerShell格式,而不仅仅是扁平化为文本.我用谷歌搜索并搜索到了,似乎无法解决这个问题.
我希望能够做到这一点:
$all = GetRealRegistryKeysFrom( HKCU:\Software\Microsoft\CharMap )
for ($item in $all) { ... }
Run Code Online (Sandbox Code Playgroud)
更新使用下面的功能,效果很好....
例 Get-RegistryKeyPropertiesAndValues -path HKCU:\Software\.....
昨天我问如何使用 minidom用子节点替换节点上的文本。
今天我也试图<node/>用 <node>text</node>
不幸的是,我觉得我的结果是一个可怕的黑客:
import xml.dom.minidom
from xml.dom.minidom import Node
def makenode(text):
n = xml.dom.minidom.parseString(text)
return n.childNodes[0]
def setText(node, newText):
if node.firstChild==None:
str = node.toxml();
n = len(str)
str = str[0:n-2]+'>'+newText+'</'+node.nodeName+'>' #DISGUSTINGHACK!
node.parentNode.replaceChild( makenode(str),node )
return
if node.firstChild.nodeType != node.TEXT_NODE:
raise Exception("setText: node "+node.toxml()+" does not contain text")
node.firstChild.replaceWholeText(newText)
def test():
olddoc = '<test><test2/></test>'
doc=xml.dom.minidom.parseString(olddoc)
node = doc.firstChild.firstChild # <test2/>
print "before:",olddoc
setText(node,"textinsidetest2")
newdoc = doc.firstChild.toxml()
print "after: ", newdoc
# desired result:
# newdoc='<test><test2>textinsidetest2</test2></test>' …Run Code Online (Sandbox Code Playgroud) 我想做这样的事情,但它不会编译因为无法分配对.
var
MyDictionary: TDictionary<TGuid, TCustomRecord>;
Pair: TPair<TGuid, TCustomRecord>;
begin
// ... create and populate my dictionary ...
foreach Pair in MyDictionary do
begin
PairRef.Value.MyField := PairRef.Value.MyField + 1;
end;
end
Run Code Online (Sandbox Code Playgroud)
为了清楚起见,我知道如何通过更多代码实现这一目标,我正在寻找简洁易读的东西.
在Pharo和Squeak中,如果它已经安装,你可以键入CommandShell open.,它将打开一个命令窗口,它基本上就像一个"bash shell"或"终端窗口",但它使用的是一个近乎微观尺寸的默认字体.我似乎无法弄清楚如何改变它.
我发现smalltalk中的一般方法是浏览类的实现,看看你是否可以找到你可以对类说的东西,告诉它你想要什么,或者你可以修改类的一些方法让它回答一些问题不同于其他一些类,造成了预期的效果.类似的东西anInstanceOfCommandShell someViewOrControllerThingy setDefaultFont:blahblahblah或类似的东西.
似乎CommandShell使用ShellWindowMorph并且它接受setFont消息.我是Smalltalk和Squeak的新人,不知道下一步该做什么.
我正在使用Pharo 2.0,但如果有人知道如何在Squeak中做到这一点,我相信它会大致相同.
请注意,我已经找到了pharo的设置,并且常规设置更改会影响主要抄本窗口,但不会CommandShellTranscript以任何方式影响特殊内容或其内容.

我用来以编程方式更改其余字体的代码是另一个问题的答案.它说这样做:
|font codeFont|
font := LogicalFont familyName: 'Consolas' pointSize: 10.
codeFont := LogicalFont familyName: 'Consolas' pointSize: 9.
StandardFonts listFont: codeFont.
...
Run Code Online (Sandbox Code Playgroud) 就像早期测试版 (dnx) 中的这个问题一样,我正在尝试将代码移植到 .net core 1.0 rtm,并且代码在以下包含 ValidationAttribute 类型和其他内容的单元上回复:
using System.ComponentModel.DataAnnotations;
namespace Hl7.Fhir.Introspection
{
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public sealed class FhirElementAttribute : ValidationAttribute
...
Run Code Online (Sandbox Code Playgroud)
如何将此类代码移植到 dotnet core 1.0 rtm?
对这个问题的回答表明,在delphi中通过类型库导入使用WinHTTP是多么容易.
我为WinHTTP导入了类型库,然后尝试使用该API编写文件下载帮助程序函数.这是我有多远:
我似乎无法弄清楚如何将IWinHttpRequest.ResponseStream(在TLB文件中声明为OleVariant)作为Stream保存到磁盘.
// IWinHttpRequest is defined by importing type library of WinHTTP.
// Microsoft WinHTTP Services, version 5.1 (Version 5.1) C:\Windows\system32\winhttp.dll
function Download(const url, filename: String): Boolean;
var
http: IWinHttpRequest;
wUrl: WideString;
fs:TFileStream;
FileStream:IStream;
sz,rd,wr:Int64;
begin
try
wUrl := url;
http := CoWinHttpRequest.Create;
http.open('GET', wurl, False);
http.send(EmptyParam);
FStatus := http.status; // 200=OK!
result := FStatus=200;
if result then
begin
fs := TFileStream.Create(filename, fmCreate, fmShareExclusive );
try
FileStream := TStreamAdapter.Create(fs, soReference) as IStream;
sz := http.ResponseStream.Size;
http.ResponseStream.CopyTo(FileStream,sz,rd,wr);
finally …Run Code Online (Sandbox Code Playgroud) 我在项目组中分组了很多项目.所有信息都在project.bpg中.现在我想自动构建它们.
如何使用命令行构建所有项目?
我还在使用Delphi 7.
我想扩展DbGrid功能,在奇数行和偶数行上添加颜色.所以我写了这个
procedure TGridx.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
var
row : Integer;
begin
inherited;
row := Self.DataSource.DataSet.RecNo;
if (row mod 2 = 0) then
Self.Canvas.Brush.Color := FColor1 //some color
else
Self.Canvas.Brush.Color := FColor2; //some color
end;
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
delphi ×6
delphi-7 ×2
.net-core ×1
build ×1
c# ×1
components ×1
datamodule ×1
delphi-xe ×1
delphi-xe2 ×1
download ×1
ipc ×1
pharo ×1
powershell ×1
python ×1
registry ×1
service ×1
smalltalk ×1
squeak ×1
winhttp ×1
xml ×1