delphi-7

Delphi - XE2 code to Delphi7 needed. Using wininet to download a file

╄→尐↘猪︶ㄣ 提交于 2019-12-13 19:23:17
问题 Note: I only want to use wininet, not urlmon-urldownloadtofile. Well, I have the following code which works perfectly in XE2 to download a file: procedure DownloadFile(URL: string; Path: string); const BLOCK_SIZE = 1024; var InetHandle: Pointer; URLHandle: Pointer; FileHandle: Cardinal; BytesRead: Cardinal; DownloadBuffer: Pointer; Buffer: array [1 .. BLOCK_SIZE] of byte; BytesWritten: Cardinal; begin InetHandle := InternetOpen(PWideChar(URL), 0, 0, 0, 0); URLHandle := InternetOpenUrl

How to iterate DOM nodes in Delphi Chromium Embedded without use of anonymous method?

雨燕双飞 提交于 2019-12-13 18:43:36
问题 Delphi Embedded Chrome Due to my limited skill, I cannot figure out how to do the same thing in Delphi 7, as it doesn't support an anonymous method! 回答1: procedure TheProcThatHandlesItAll(const doc: ICefDomDocument) var q: ICefDomNode; begin // "q" is the ID of the text input element q := doc.GetElementById('q'); if Assigned(q) then q.SetElementAttribute('value', 'Hello, world'); end procedure TMainForm.actDomExecute(Sender: TObject); begin crm.Browser.MainFrame.VisitDomProc

How can I repeat a song?

陌路散爱 提交于 2019-12-13 17:03:09
问题 I have a TMediaPlayer called MediaPlayer1 I then open a file(a song) I play it. now my problem is that I need the song to repeat until the program stops. The idea is that the form activates and then repeats the specified song until the form is closed. MediaPlayer1.Filename := 'filename'; Then it opens it MediaPlayer1.Open; Then it plays it MediaPlayer1.Play; So now the song is playing but when it ends I want it to play again(repeat) and then again until the form is closed. I tried what David

How to combine overload and stdcall in Delphi?

陌路散爱 提交于 2019-12-13 16:47:57
问题 I have a SOAP Data Module that exports this function function MyFunction(MyParam1, MyParam2): boolean; stdcall; I can use this function from another exe. Everything works. Now I want to use the same function from inside the same project it's in. I added its unit to the uses clause but it didn't recognise it (I got Undeclared Identifier). Then I added an overload but I can't get it to work. function MyFunction(MyParam1, MyParam2): boolean; stdcall; overload; function MyFunction(MyParam1,

Delphi, adding digets

≡放荡痞女 提交于 2019-12-13 09:14:41
问题 My textbook says I need to make a donation program with three buttons, each representing a certain amount of money. The "Amount donated" should be shown on a label after I press a button. For instance if I press the $10 button, it will say The total amount raised so far is $10 . And then if I press the $50 button, the label should caption The total amount raised so far is $60 . I'm in need of 3 buttons, a $10, $20 and $50 . I don't even know where to start with the coding side! Here's the

How to make custom sizing for window with non-sizeable borders?

倖福魔咒の 提交于 2019-12-13 09:14:21
问题 How to implement custom sizing routines for window which borders are not natively sizeable? e.g. a form with BorderStyle set to bsToolWindow 回答1: Here a customized form-class with implemented non-sizeable borders sizing and possibility to disable sizing for specified edges. Also it supports double clicks on borders to toggle between two rectangle-boundaries: AutoSizeRect to values of which form sides getting moved on dblclick and SavedSizeRect into which values form side coordinates saved

Access of violation at address 00404094 with AssignFile();

我是研究僧i 提交于 2019-12-13 08:24:44
问题 I'm just getting back into Delphi after a few months of not touching it. Just want to refresh my mind a bit. I keep getting an access violation at the part of AssignFile(); . What I'm doing is just reading a list of names into a rich edit via a text file. procedure TForm1.btn1Click(Sender: TObject); var k : Integer; MyArray : array[1..1000] of string; begin k := 1; AssignFile(MyFile, 'names.txt'); Reset(MyFile); while not Eof(MyFile) do // <-- Here is the error begin readln(MyFile, MyArray[k]

Can't get TClientSocket to receive buffer values

杀马特。学长 韩版系。学妹 提交于 2019-12-13 08:23:16
问题 On the server side, text is entered into a memobox. This text is then sent to the Server side using this code: var ftmpstr :String; buf :array[0..255] of char; msize, nyites :dword; i :Integer; .. Command := Socket.ReceiveText; if split(Command,'|', 0) = 'IBATCH' then begin ftmpstr := IBat.Memo1.Text; nyites := 1; msize := length(ftmpstr); Server.Socket.Connections[ListView1.Selected.Index].SendText(IntToStr(msize)); while msize>255 do begin for i := 0 to 255 do buf[i] := ftmpstr[nyites+i];

Delphi assembler: understanding the Result register

人盡茶涼 提交于 2019-12-13 04:48:11
问题 I'm messing around with ASM in Delphi. From my understanding, EAX holds Result. In the following, I have to put RET at the end, otherwise Result is not correct (it is correct if the input is 0). What am I doing wrong, or should I say, what don't I understand about this? function MSb(const Val: Integer): Integer; label Go; asm CMP EAX, 0 JNZ Go MOV EAX, -1 RET Go: BSR EBX, EAX MOV EAX, EBX RET end; If I say the following: MOV Result, EBX Then I get the following compilation: MOV [EPB-$04], EBX

Take a screenshot of a particular area in Delphi 7

南楼画角 提交于 2019-12-13 03:46:56
问题 I have a panel in the form delphi that contains pictures, labels and others. I need to take screenshots in the panel area. How can I perform this ? 回答1: Assuming that you have a panel named Panel1 to be screenshot, a button named Button1 to do the screen shoot, and Image1 to display the screenshot, here is simple code you can use: procedure TForm1.Button3Click(Sender: TObject); var bitmap: TBitmap; dc: HDC; begin bitmap := TBitmap.Create(); try dc := GetDC(Panel1.Handle); try bitmap.Width :=