我想在画布上绘制文本。为了进行轮换,我使用了https://forums.embarcadero.com/thread.jspa?messageID=440010 中的以下代码
//bm is a TImage
a := 45;
c:= bm.Canvas;
CurrentM := c.Matrix;
a:=-radian(a);
m.m11:= cos(a); m.m12:=sin(a); m.m13:=0;
m.m21:=-sin(a); m.m22:=cos(a); m.m23:=0;
m.m31:=0; m.m32:=0; m.m33:=1;
c.setmatrix(M);
c.BeginScene;
c.filltext(rectf(100,100,5000,5000), 'test rotated string', false,1,[],ttextalign.taLeading,ttextalign.taLeading);
c.EndScene;
Run Code Online (Sandbox Code Playgroud)
这工作正常。我已将矩形的右侧和底部设置为 5000,这样我就不必担心矩形太小了。
问题是我现在想更改我的 TextAlignment 属性。所以要从右到左绘制文本,我必须调整我的矩形,然后按以下方式绘制它:
c.BeginScene;
c.filltext(rectf((100 - 5000),100,100,5000), 'test rotated string', false,1,[],ttextalign.taTrailing,ttextalign.taLeading);
c.EndScene;
Run Code Online (Sandbox Code Playgroud)
所以基本上我移动了矩形 TopLeft 的 x 值并将其移回 5000(我再次使用 5000 来确保我的文本适合)。然后,我将矩形右下角的 x 值设置为 x 值在上一个示例矩形的 TopLeft 中的位置。这适用于 0 度旋转,但是一旦我更改了度数,我就不会在正确的位置绘制文本。我认为这是因为文本将围绕矩形的 TopLeft 位置旋转(更改为使文本从右向左书写)。
我有一个带有 nvarchar 数据的 MS SQL Server 数据库,特别是一个带有“?ABC?”的数据字段。在里面。我的 Delphi 桌面应用程序显示得很好,但是来自 Delphi XE4 中使用 TDataSetTableProducer 生成响应的 WebBroker 应用程序的相同数据不起作用。这是基本的示例代码:
procedure TWebModule1.WebModule1TestAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
Response.ContentEncoding := 'text/plain; charset="UTF-8"';
Response.Content := '<!DOCTYPE html>'
+ '<html>'
+ '<body>'
+ '<p> ?ABC? </p>'
+ '</body>'
+ '</html>'
end;
Run Code Online (Sandbox Code Playgroud)
在网络浏览器中查看时,结果是“?ABC?”。我尝试了很多东西(包括 UTF-16 和用 Char($FEFF) 作为响应前缀),但没有任何帮助。这样做的正确方法是什么?
我原以为OnRotate在XE4中会有一个事件,但它似乎OnResize被使用了.了解.
但是,我需要确定设备的方向.我确信它很简单,但谷歌无法帮助!
我希望尽可能快地接受传入的TCP连接.然而,我还希望为每个接收数据的连接都有一个额外的线程.
这是我的TThread类,它可以监听端口:
procedure TListenThread.Execute;
var
iSize : Integer;
begin
ConnectionAttempts := 0;
while not (terminated) do begin
iSize := SizeOf(cAddr);
hClient := Accept(hServer, @cAddr, @iSize);
if (hClient <> INVALID_SOCKET) then begin
inc (ConnectionAttempts);
SynchIP := inet_ntoa(cAddr.sin_addr);
Synchronize(WriteToLog); // Processes very fast!
with TReceiveThread.Create(TRUE) do begin // This takes the longest...
FreeOnTerminate := TRUE;
hSocket := hClient;
TheForm := aForm;
Host := SynchIP;
Resume;
end;
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)
我发现API CreateThread需要很长时间才能处理.有没有办法更快地接受连接(所以accept优先级高于ListenerThread)?
例如,accept具有2秒的最高优先级(在服务器已经接受大约200个连接的2秒内)然后立即创建(200)线程,或类似的东西.建议,帮助将不胜感激.
PS.:我不想在连接发生之前创建任何线程.(这会限制连接并填充内存).我也想远离Indy - 我已经测试了它,它似乎是相同的速度.
我Incompatible types: 'PPointerList' and 'TPointerList'在跟随功能时遇到错误.
function MyFunction: PPointerList;
begin
result := FList.List;
end;
Run Code Online (Sandbox Code Playgroud)
FList.List返回TPointerList类型.这段代码在Delphi 7代码中工作正常但在Delphi XE4中抛出错误.
PPointerList和TPointerList在System.Classes中声明
在System.Classes中
PPointerList = ^TPointerList;
TPointerList = array of Pointer;
Run Code Online (Sandbox Code Playgroud)
当我将TPointerList转换为PPointerList时,它就像是一样
function MyFunction: PPointerList;
begin
result := PPointerList(FList.List);
end;
Run Code Online (Sandbox Code Playgroud)
这是正确的解决方案,或者我应该怎么做才能摆脱这个错误.
通过双击打开dfm文件时,我收到以下错误:
Class TMyClass not found. Ignore the error and continue? Note: Ignoring the error may cause components to be deleted or property values to be lost.
Run Code Online (Sandbox Code Playgroud)
当我单击取消时,我收到以下消息
Error creating form: Class TMyClass not found.
Run Code Online (Sandbox Code Playgroud)
当我单击"确定"时,仅打开pas文件.
在pas文件中添加了MyClass单元(其中包含了TMyClass定义),并且它的路径也添加到了我的搜索路径中(按住单击名称的Ctrl,将我带到单元文件)
一切都很好,就像我一样.我不知道为什么我收到此错误,为什么我无法在RAD工作室中打开此dfm文件?请帮忙.
我可以使用FindWindow按标题获取窗口句柄,但如果窗口最小化,则无法获得窗口句柄.如何获得最小化窗口的句柄?
hWindow := FindWindow(nil, iWindowTitle);
Run Code Online (Sandbox Code Playgroud) 我正在使用teechart和delphi XE4.我认为我的问题非常基本,但我找不到解决方案.
在一个简短的例子中,我有一个TChartSeries,其中包含OnCLick事件的事件处理程序.在我的事件处理代码中,我执行以下操作:
if Button=mbRight then
begin
clkSerie:=Sender;
clkValue:=ValueIndex;
GetCursorPos(P);
pm1.Popup(P.X,p.Y);
end;
Run Code Online (Sandbox Code Playgroud)
然后,在pm1.MyAction.OnClick
st:=InputBox('Agregar nota','Ingrese texto','');
if st<>'' then
begin
clkserie.Marks.Item[clkValue].Text.Clear;
clkserie.Marks.Item[clkValue].Text.Add(st);
clkserie.Marks.Item[clkValue].Visible:=True;
end;
Run Code Online (Sandbox Code Playgroud)
它工作正常,唯一的问题是,当我退出这个程序时,回到我的图表没有弹出菜单或输入框,我正处于"平移"状态,似乎图表看不到我的MOUSE_UP事件.
我试图模拟鼠标点击,mouse_event()但没有奏效.唯一有效的是禁用图表平移,但我不想采取这种方式.我知道除此之外必须有一个解决方案.
我将继续尝试并阅读相关内容.
提前致谢.
在Delphi7中,TControl.Perform()接受负值wParam参数,这是它是如何应该做的,因为例如,EM_LINEFROMCHAR WINAPI消息所期望-1的wParam.
但是在Delphi XE4下,数据类型wParam已更改为NativeUInt,这将不接受负整数.
这是Delphi RTL的一个错误,或者我错误地理解它?谢谢.
绑定到Delphi XE4编译器的条件编译器指令是什么?我虽然这样:
{$ifdef VerDXE4}
code segment compiled only by the Delphi XE4 compiler
{$endif}
Run Code Online (Sandbox Code Playgroud) delphi ×10
delphi-xe4 ×10
vcl ×2
delphi-7 ×1
firemonkey ×1
ios ×1
teechart ×1
utf-8 ×1
webbroker ×1
winsock ×1