小编War*_* P的帖子

Delphi XE2中的TDataModule.ClassGroup伪属性真的有用吗?

我试图在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)

delphi datamodule delphi-xe2

4
推荐指数
1
解决办法
1898
查看次数

如何从另一个Delphi应用程序中激活Delphi应用程序中的事件?

请在标记为重复之前阅读.

我正在创建一组依赖智能卡进行身份验证的应用程序.到目前为止,每个应用程序都单独控制了智能卡读卡器.几周后,我的一些客户将同时使用多个应用程序.所以,我想也许创建一个控制身份验证过程的服务应用程序会更实际.我希望我的桌面应用程序告诉他们对身份验证过程感兴趣的服务应用程序,然后服务应用程序会向他们提供有关当前用户的信息.这个部分很容易使用named pipes.难的是,如何能服务告知已发生的事件的桌面应用程序(UserLogIn,UserLogOut,PermissionsChanged,...仅举几例).到目前为止,我有两种方法.CallBack功能,和Messages.有没有人有更好的主意?我确定有人.

delphi service ipc

4
推荐指数
2
解决办法
2210
查看次数

Powershell Get-ChildProperty可以获得REG QUERY等真正的注册表项列表而无需额外的噪音吗?

在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\.....

registry powershell

4
推荐指数
1
解决办法
1万
查看次数

如何在python中的xml.minidom中没有任何孩子的xml节点上设置文本?

昨天我问如何使用 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)

python xml

4
推荐指数
1
解决办法
2257
查看次数

有没有简洁的方法来更新记录的TDictionary中的所有值?

我想做这样的事情,但它不会编译因为无法分配对.

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)

为了清楚起见,我知道如何通过更多代码实现这一目标,我正在寻找简洁易读的东西.

delphi

4
推荐指数
1
解决办法
1165
查看次数

如何在pharo或squeak中更改CommandShell窗口中的字体?

在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)

smalltalk squeak pharo

4
推荐指数
1
解决办法
612
查看次数

无法在 .net core 1.0 中使用数据注释

就像早期测试版 (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?

c# data-annotations visual-studio-2015 .net-core

4
推荐指数
1
解决办法
1277
查看次数

使用Delphi XE将通过WinHTTP下载的文件保存到磁盘

这个问题的回答表明,在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)

delphi download winhttp delphi-xe

3
推荐指数
1
解决办法
3599
查看次数

如何使用命令行编译Delphi 7项目组文件(.bpg)?

我在项目组中分组了很多项目.所有信息都在project.bpg中.现在我想自动构建它们.

如何使用命令行构建所有项目?

我还在使用Delphi 7.

delphi continuous-integration build delphi-7

3
推荐指数
1
解决办法
4208
查看次数

使用某些行颜色扩展DBGrid

我想扩展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 components delphi-7

3
推荐指数
1
解决办法
1380
查看次数