我正在将用Delphi 2007 .Net编写的应用程序迁移到Delphi Prism,这是替换TStringList和TStrings类的最佳选择吗?
提前致谢.
再见.
这个问题可能看似重复,但我在测试程序时遇到了这个问题,我对你如何解决它感到困惑.
我有一个winform,它有一个表单结束事件.在这种情况下,我弹出一个消息框,询问用户"你确定要关闭窗口吗?" 如果他们按下"是"按钮,应用程序将关闭窗口并阻止其按预期处理.所以,我可以再打开它.但是,如果他们没有按下任何按钮,它仍会关闭窗口,但现在窗户已被丢弃.因此,当我尝试再次打开它时,它引发了一个异常,"无法访问已处置的对象".当没有按下按钮时,我希望winform保持打开状态而不是处理掉.
这是我的代码:
method PPMain.PPMain_FormClosing(sender: System.Object; e: System.Windows.Forms.FormClosingEventArgs);
begin
if MessageBox.Show('Are you sure you want to close the window?','PPMain',MessageBoxButtons.YesNo) = DialogResult.Yes then
begin
e.Cancel := true;
Hide;
end
else
e.Cancel := false;
end;
Run Code Online (Sandbox Code Playgroud)
我想,因为你必须设置e.Cancel = true来关闭窗口并告诉它隐藏,做相反的事情(e.Cancel = false并且没有隐藏)将阻止winform关闭和被处理.
你是如何解决这个问题的?
预先感谢,
我一直在试验Oxygene中的Lambda表达式.非常简单的递归lambda表达式来计算斐波那契数:
var fib : Func<int32, int32>;
fib := n -> iif(n > 1, fib(n - 1) + fib(n - 2), n);
fib(3);
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我得到一个nullreferenceexception.关于我做错了什么的任何想法?
我知道CodeGear制作的BabelCode使用Code DOM将C#转换为Delphi for .NET.我很好奇是否还有其他类似工具将C#转换为Delphi Prism?如果没有,使用Code DOM创建一个是什么(是的,这是开放式的!)
更新:现在已经内置到Delphi Prism中.只需粘贴或导入您的C#,您就拥有了Oxygene即Delphi Prism Code.
我正在将用Delphi 2007编写的应用程序迁移到Delphi Prism,这是替换TList类的最佳选择吗?
提前致谢.
再见.
是否有一个简单的语句可以在Delphi中给出类似于paramstr()的结果?
对于这个问题,我确实梳理了Stackoverflow类似的问题以获得答案.虽然他们中的很多人都很有帮助,但他们并没有解决我的问题.我的程序使用graphics.DrawLines方法在winform上绘制多边形,如下所示.
g.DrawLines(thepen,pts);
Run Code Online (Sandbox Code Playgroud)
但是不断提高,"参数无效",错误.所以,我按如下方式改变了这行代码,看它是否有任何区别.
g.DrawLines(new pen(color.Black),pts);
Run Code Online (Sandbox Code Playgroud)
再一次,它提出了同样的错误.pts是system.drawing.point的数组,thepen是system.drawing.pen.
如果我完全评论它,我的程序没有问题,它不会引起任何错误.然而,奇怪的是,过去3或4个月内,相同的代码工作得很好.从昨天开始,我似乎无法让它再次运作.
是否需要设置winform的属性设置?
更新这是实际的绘制方法
method TMakerPoly.Draw;
var
pts: Array of point;
i:integer;
theBrush1:HatchBrush;
theBrush2:SolidBrush;
begin
if (theBrushStyle = HatchStyle.Wave) then
theBrush1 := new HatchBrush(theBrushStyle,Color.Transparent,color.Transparent)
else if (theBrushStyle = HatchStyle.ZigZag) then
thebrush2 := new SolidBrush(FillColor)
else
theBrush1 := new HatchBrush(theBrushStyle,FillColor,color.Transparent);
if (thePen.DashStyle = DashStyle.Custom) then
thepen.Color := Color.Transparent;
pts := new point[pcount];
if pcount >= 2 then
begin
if Active then
begin
for i := 0 to pcount-1 do
pts[i] := point(points[i]);
Translate(var pts,pcount);
thepen.Color …Run Code Online (Sandbox Code Playgroud) 在Delphi中,有一个函数StrToInt()将字符串转换为整数值; 还有IntToStr(),它反过来.这些函数似乎不是Oxygene的一部分,我找不到对可以做到的东西的引用.怎么做到呢?
我在winform上有datagridview,你可以添加和删除它.虽然我能够成功地做到这一点,但它很奇怪.
它要求将其属性RowCount设置为1或更大.因此,即使没有添加任何项目,也始终显示单行网格.
你如何克服这个缺点?或者有办法吗?
谢谢,
oxygene ×10
delphi-prism ×7
delphi ×6
winforms ×2
.net ×1
c# ×1
codedom ×1
datagridview ×1
fibonacci ×1
formclosing ×1
graphics ×1
lambda ×1
rowcount ×1
tlist ×1
tstringlist ×1