Delphi

Using C++ interface in delphi/pascal

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-03 05:56:09
问题 I have the following interface defined in a dll: class TestInterface { public: int foo(int)=0; }; And the following functions let's me create objects of this type: extern "C" declspec(dllexport) TestInterface* __stdcall CreateInterface(); The interface is implemented in the dll and I can use it in C++ without any problems (I've also defined the .def file to make sure everything works correctly). However when it comes to using it in pascal I have problems. Here's how I'm trying to use the

Logging application wide mouse clicks in Delphi

笑着哭i 提交于 2020-01-03 05:38:05
问题 I am trying to track and log what a user does in my app. One way to help is to have a list of what buttons and menu etc they click as they use the program. Then if the program crashes for any reason I have a log of the exact steps they took to try and reproduce the issue. So I drop an ApplicationEvents component on the main form and then under OnMessage I use... procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;var Handled: Boolean); var Target: TControl; Point: TPoint; begin Handled

Why is Fast Report VCL in Delphi raising a stack overflow exception when editing a variable?

半世苍凉 提交于 2020-01-03 05:32:26
问题 I am using Delphi 5 and Fast Report 4 to make a report application. I have defined a variable "ReportTitle" in MyReport.f3 at design time and I assigned a value for it at runtime. Why is my code raising an EStackOverflow Exception? Here is the code sample frxrprt1.LoadFromFile('c:\MyReport.fr3'); frxrprt1.Variables['ReportTitle'] := 'Sales Summary Report'; frxrprt1.ShowReport; 回答1: Use this: frxrprt1.Variables['ReportTitle'] := '''Sales Summary Report'''; The "variable" values are actually

Is DateTimeToString in Delphi XE5 doesn't work?

五迷三道 提交于 2020-01-03 05:29:10
问题 I have small piece of code: DateTimeToString(DiffString, 't.zzz', TDT); ShowMessage('TDT: ' + DateTimeToStr(TDT)); ShowMessage('DiffString: ' + DiffString); which result with first ShowMessage gives random nice DateTime TDT value... second where DiffString is exacly 00:00.000 Could anyone check it in other IDE? 回答1: In fact DateTimeToString works just fine and is behaving exactly as designed. It is doing precisely what you asked it to. Here is the SSCCE that you should have provided: {

What regex can I use to extract URLs from a Google search?

拟墨画扇 提交于 2020-01-03 05:27:15
问题 I'm using Delphi with the JCLRegEx and want to capture all the result URL's from a google search. I looked at HackingSearch.com and they have an example RegEx that looks right, but I cannot get any results when I try it. I'm using it similar to: Var re:JVCLRegEx; I:Integer; Begin re := TJclRegEx.Create; With re do try Compile('class="?r"?>.+?href="(.+?)".*?>(.+?)<\/a>.+?class="?s"?>(.+?)<cite>.+?class="?gl"?><a href="(.+?)"><\/div><[li|\/ol]',false,false); If match(memo1.lines.text) then

How to copy multiple selected rows of listview into clipboard in Delphi

倖福魔咒の 提交于 2020-01-03 04:46:15
问题 I have put together this code Selected rows into clipboard from a lisview. procedure TFmainViewTCP.Copy1Click(Sender: TObject); var Str:String; k :Integer; lItem:TListItem; begin repeat lItem:=lvConnection.Selected; Str:=lItem.Caption; for k:=0 to lvConnection.Columns.Count-2 do begin Str:=Str+' '+lItem.SubItems[k]; end; Clipboard.AsText:=Clipboard.AsText+ sLineBreak +Str; {copy into clipboard} until lItem.Selected=True; end; I am not sure if this is working correctly, it does not copy out

Delphi POS打印的处理

本小妞迷上赌 提交于 2020-01-03 04:37:13
Delphi POS打印的处理 2007年8月4日 delphi 小票打印 {打印代码} procedure TForm1.Button1Click(Sender: TObject); var RPrinter:TextFile; i:integer; begin {设置打印机} Assignfile(RPrinter,'lpt1'); {准备写文件} Rewrite(RPrinter); {打印} for i := 0 to memo1.lines.Count - 1 do Writeln(RPrinter,memo1.lines[i]); {向后倒纸} Writeln(RPrinter,chr($b)+chr(27)+'K'+chr(40)); {向前进纸} Writeln(RPrinter,chr($b)+chr(27)+'J'+chr(140)); {开钱箱} writeln(f,CHR(27)+CHR(112)+CHR(0)+CHR(17)+CHR(8)); write(f,CHR(27)+CHR(112)+CHR(0)+CHR(17)+CHR(8)); Chr(27)+'p'+chr(0)+chr(60)+chr(255) {关闭打印机} CloseFile(RPrinter); end; 建议看看Printers单元 uses Printers,然后看看里面的函数 1

Delphi下POS机

爱⌒轻易说出口 提交于 2020-01-03 04:33:12
procedure tform1.OpenSerialPort; var cc:TCommConfig; Temp:string; begin Temp:='Com'+inttostr(RadioGroup1.ItemIndex+1); hSerialPort:=CreateFile(PChar(Temp),GENERIC_READ or GENERIC_WRITE,0,nil,OPEN_EXISTING,0,0); if (hSerialPort=invalid_handle_value) then begin MessageBox(0,'打开串口失败','',MB_OK); Exit; end; GetCommState(hSerialPort,cc.dcb); cc.dcb.BaudRate:=CBR_9600; cc.dcb.ByteSize:=8; cc.dcb.Parity:=NOPARITY; cc.dcb.StopBits:=ONESTOPBIT; if not SetCommState(hSerialPort,cc.dcb) then begin ShowMessage('不能设置串口'); CloseHandle(hSerialPort); Exit; end else ShowMessage('打开,并设置成功!'); end; procedure

Delphi下POS机控制钱箱,客显,打印机

混江龙づ霸主 提交于 2020-01-03 04:32:28
1、控制POS机的客户显示屏 procedure TFrmMain.ShowMoney(Money_Port: String;Money_String:String); //Moneey_Port:顾显接口Com1 or Com2 Money_String:顾显显示的内容 var PrnFileName:TextFile; begin Assignfile(PrnFileName,Money_Port); printer.Canvas.Font.Name:='宋体'; printer.Canvas.Font.Size:=8; printer.Canvas.Font.Charset:=GB2312_CHARSET; Rewrite(PrnFileName); write(PRNFileName,chr(12)); //清除顾显 write(PRNFileName,chr(27)+chr(81)+chr(65)+Money_String+chR(13)); //显示信息 CloseFile(PRNFileName); end; 2、不换页走纸的打印 procedure TFrmMain.AddPrintStrings(Strings: TStrings); var Prn: TextFile; i: word; begin Assignfile(Prn,'lpt1'); printer

MySQL User Defined Function to send a windows message

ε祈祈猫儿з 提交于 2020-01-03 04:18:27
问题 G'Day, I want to use the Windows API Postmessage() call from inside a MySQL UDF on MySQL 5.1.51 (XP SP3). I know the UDF (Written in Delphi 2006) is working by setting a bogus result for the UDF. The syntax of the UDF takes two integer params, one for a window handle and the other for a message number. However a call to PostMessage() from inside my UDF causes an exception in mysqld and the service stops. Any ideas or pointers? Alternatively if anyone can tell me how I am able to simulate IB