Search Results

Search found 5657 results on 227 pages for 'delphi 2007'.

Page 108/227 | < Previous Page | 104 105 106 107 108 109 110 111 112 113 114 115  | Next Page >

  • Do I have to allocate and free records when using TList<T> in Delphi?

    - by afrazier
    The question more or less says it all. Given the following record structure: type TPerson = record Name: string; Age: Integer; end; PPerson = ^TPerson; TPersonList = TList<TPerson>; Is the following code valid? procedure ReadPeople(DataSet: TDataSet; PersonList: TPersonList); begin PersonList.Count := DataSet.RecordCount; if DataSet.RecordCount = 0 then Exit; DataSet.First; while not DataSet.Eof do begin PersonList[DataSet.RecNo].Name := DataSet.FieldByName('Name').AsString; PersonList[DataSet.RecNo].Age := DataSet.FieldByName('Age').AsInteger; DataSet.Next; end; end; Do I have to use GetMem/FreeMem to allocate and free records an instance of TPersonList, or am I free to directly access the TPersonList entries directly? My gut says that the code should be valid, though I'm not sure if there's any wrinkles related to record initialization or finalization.

    Read the article

  • Delphi: All constants are constant, but some are more constant than others?

    - by Ian Boyd
    Consider: clHotlight: TColor = $00FF9933; clLink = clHotLight; //alias of clHotlight [Error] file.pas: Constant expression expected and the alternate wording that works: clHotlight = TColor($00FF9933); clLink = clHotLight; //alias of clHotlight Explain. Then consider: AdministratorGUID: TGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}'; SuperuserGUID = AdministratorGUID; //alias of AdministratorGUID [Error] file.pas: Constant expression expected And fix.

    Read the article

  • In Delphi, Is there a way to adjust the line spacing of a TMemo?

    - by Kieran
    I'm working with a TMemo component to display some text in a limited space. Currently it's using a truetype font which doesn't ship with windows and is installed by the app when it runs. On my PC (Running Windows XP), the spacing between each line of text seems to be about eight pixels. On a different PC running Windows 7, the line spacing seems to be about 14 pixels, which is pushing the bottom row of text out of visibility on the memo. So, My question is really this: Is this caused by the different versions of Windows? It's all I could think that was different. Is there some way I can adjust this value so it would be consistent across all instances of the application, wherever it was running? Alternatatively, is there a different component I could use which might let me tweak this value?

    Read the article

  • Delphi - How can I prevent the main form capturing keystrokes in a TMemo on another non-modal form?

    - by user89691
    I have an app that opens a non-modal form from the main form. The non-modal form has a TMemo on it. The main form menu uses "space" as one of its accelerator characters. When the non-modal form is open and the memo has focus, every time I try to enter a space into the memo on the non-modal form, the main form event for the "space" shortcut fires! I have tried turning MainForm.KeyPreview := false while the other form is open but no dice. Any ideas? TIA

    Read the article

  • Delphi simple TCP server hangs. The form freezes but the server continues managing the clients.

    - by NeoNMD
    I'm using a form with an IdTCPServer on it managing strings from the client with a AThread.connection.readln/writeln system. The string handling works and that isn't the problem. The thing is, the form with the server on it hangs and will not load, but it still managed all the clients connected to it so it IS running but it just doesn't work as a form. I'll make a guess that its sitting on a readline or something... but I have NO idea how i can fix this at this moment in time. Please help. procedure TMonitorFrm.ServerExecute(AThread: TIdPeerThread); procedure post(PostMessage:string); begin try AThread.Connection.WriteLn(PostMessage); except showmessage('Cannot post'); end; end; var ActClient : PClient; sTemp, CommBlock, NewCommBlock, ReceiverName, sContent, sSQL, sCommand : String; iCount2, iCount : Integer; sldb : TSQLiteDatabase; sltb : TSQLiteTable; begin if not AThread.Terminated and AThread.Connection.Connected then begin CommBlock := AThread.Connection.ReadLn(); ActClient := PClient(AThread.Data); ActClient.LastAction := Now; sCommand := copy(CommBlock,0,pos(',',CommBlock)-1); {seperate command} sContent := copy(CommBlock,pos(',',CommBlock)+1,length(CommBlock)-(pos(',',CommBlock)+1)); {seperate data block} iCount:= 0 ; if sCommand = 'Announce' then //SPECIAL begin { Do stuff for this command...} end else if sCommand = 'CheckSect' then {Etcetera...} procedure TMonitorFrm.FormCreate(Sender: TObject); var sCompetitionID : string; sldb : TSQLiteDatabase; sltb : TSQLiteTable; begin Clients := TThreadList.Create; Server.Active := True; AreaPnlList := TComponentList.Create; SectionPnlList := TComponentList.Create; Repeat until InputQuery('Competition Select', 'Please type the ID of the competition', sCompetitionID); iCompetitionID:=StrToInt(sCompetitionID); OpenDatabase(slDb); sltb:=slDb.GetTable('SELECT * FROM SectionTable WHERE CompetitionID='+sCompetitionID); Frame31.CreateSections(sltb,Frame31); sltb.Free; CloseDatabase(slDb); { This section needs to check the SQLite databases for sections and list them in the display window and makes a drag n drop profile... } end;

    Read the article

  • Delphi: how to efficently read a big binary file, converting it to hexadecimal for passing it as a v

    - by user193655
    I need to convert a binary file (a zip file) into hexadecimal representation, to then send it to sql-server as a varbinary(max) function parameter. A full example (using a very small file!) is: 1) my file contains the following bits 000011110000111 2) I need a procedure to QUICKLY convert it to 0F0F 3) I will call a sql server function passing 0x0F0F as parameter The problem is that I have large files (up to 100MB, even if average file size is 100KB files are possible), so I need the fastest way to do this. Otherwise stated: I need to create the string '0x'+BinaryDataInHexadecimalRepresentation in the most efficient way. Related question: passing hexadecimal data to sql server

    Read the article

  • Delphi - How to prevent Forms/MsgBoxes to move under prior form?

    - by durumdara
    Hi! Many times we experienced after Windows 98 era that some dialogs are lost their Z-Order, and moved back to prior form. For example: Dialog1.ShowModal; Dialog1.OnClickButton() : ShowMessage('anything'); When MessageBox appears, sometimes not got focus, it is moved under Dialog1. The users confused on it, because they are say: application freezed!!! But if they are uses AltTab to move another app and back, the focus return to the MessageBox, and it will be the foreground Window. We experienced this with ShowMessage, MessageBox, normal forms, QuickReport forms also. Is anyone knows about this? Is it Windows bug? How to prevent it? How to catch this? Thanks for your help: dd

    Read the article

  • Delphi Unit local variables - how to make each instance unique?

    - by Justin
    Ok, this, I'm sure is something simple that is easy to do. The problem : I've inherited scary spaghetti code and am slowly trying to better it when new features need adding - generally when a refactor makes adding the new feature neater. I've got a bunch of code I'm packing into a single unit which, in different places in the application, controls the same physical thing in the outside world. The control appears in several places in the application and operates slightly differently in each instance. What I've done is to create a unit with all of the features I need which I can simply drop, as a frame, into each form that requires it. Each form then uses the unit's interface methods to customise the behaviour for each instance. The problem within the problem : In the unit in question (the frame) I have a variable declared in the IMPLEMENTATION section - local to the unit. I also have a procedure, declared in the TYPE section which takes an argument and assigns that argument to the local variable in question - each form passes a unique variable to each instance of the frame/unit. What I want it to do is for each instance of the frame to keep its own version of that variable, different from the others, and use that to define how it operates. What seems to be happening, however, is that all instances are using the same value, even if I explicitly pass each instance a different variable. ie: Unit FlexibleUnit; interface uses //the uses stuff type TFlexibleUnit=class(TFrame) //declarations including procedure makeThisInstanceX(passMeTheVar:integer); private // public // end; implementation uses //the uses var myLocalVar; procedure makeThisInstanceX(passMeTheVar:integer); begin myLocalVar:=passMeTheVar; end; //other procedures using myLocalVar //etc to the end; Now somewhere in another Form I've dropped this Frame onto the Design pane, sometimes two of these frames on one Form, and have it declared in the proper places, etc. Each is unique in that : ThisFlexibleUnit : TFlexibleUnit; ThatFlexibleUnit : TFlexibleUnit; and when I do a: ThisFlexibleUnit.makeThisInstanceX(var1); //want to behave in way "var1" ThatFlexibleUnit.makeThisInstanceX(var2); //want to behave in way "var2" it seems that they both share the same variable "myLocalVar". Am I doing this wrong, in principle? If this is the correct method then it's a matter of debugging what I have (which is too huge to post) but if this is not correct in principle then is there a way to do what I am suggesting? Thanks in advance, Stack Overflow - you guys (and gals!) are legendary.

    Read the article

  • Is there a Delphi standard function for escaping HTML?

    - by Mason Wheeler
    I've got a report that's supposed to take a grid control and produce HTML output. One of the columns in the grid can display any of a number of values, or <Any>. When this gets output to HTML, of course, it ends up blank. I could probably write up some routine to use StringReplace to turn that into &lt;Any&gt; so it would display this particular case correctly, but I figure there's probably one in the RTL somewhere that's already been tested and does it right. Anyone know where I could find it?

    Read the article

  • How can I measure TForm deserialization time in Delphi?

    - by mjustin
    For performance tests I need a way to measure the time needed for a form to load its definition from the DFM. All existing forms inherit a custom form class. To capture the current time, this base class needs overriden methods as "extension points": before the beginning of the deserialization process after the completion of deserialization (can be implemented by overriding the Loaded procedure) the moment just before the execution of the OnFormCreate event Which TObject (or TComponent) methods are best suited? Maybe there are other extension points in the form creation process, please feel free to make suggestions.

    Read the article

  • How can a Delphi TPersistent object calculate its own deserialization time?

    - by mjustin
    For performance tests I need a way to measure the time needed for a form to load its definition from the DFM. All existing forms inherit a custom form class. To capture the current time, this base class needs overriden methods as "extension points": start of the deserialization process after the deserialization (can be implemented by overriding the Loaded procedure) the moment just before the execution of the OnFormCreate event So the log for TMyForm.Create(nil) could look like: - 00.000 instance created - 00.010 before deserialization - 01.823 after deserialization - 02.340 before OnFormCreate Which TObject (or TComponent) methods are best suited? Maybe there are other extension points in the form creation process, please feel free to make suggestions.

    Read the article

  • RTTI Delphi Create as TValue an n-dimensional matrix.

    - by user558126
    Good day, I had tried to make recurrent function to return a TValue as a n-dimensional. matrix(2D, 3D, 4D...) for example, this procedure will show a n-dimensional matrix(it will list all elements from a n-dimensional matrix as TValue variable): Procedure Show(X:TValue); var i:integer; begin if x.IsArray then begin for i:=0 to x.GetArrayLength-1 do show(x.GetArrayElement(i)); writeln; end else write(x.ToString,' '); end; I don't understand how to create a function to create from a TValue an n-dimensional matrix. For example i need a Function CreateDynArray(Dimensions:array of integer; Kind:TTypeKind):TValue; and the function will return a TValue which is a dynamic array how contain the dimenssions for example: Return=CreateDynArray([2,3],tkInteger); will return a TValue as tkDynArray and if i will show(Return) will list 0 0 0 0 0 0 Thank you very much, and have a nice day!

    Read the article

  • Is it possible to smooth a scaled TBitmap in Delphi?

    - by Brian Frost
    I am using Stretched=True on a TBitmap with a 256x256 image. This gets scaled down by 1,2,4 or 8. As expected, text on the bitmap gets more horrible the more I depart from '1'. I notice though that Windows 7 explorer renders a scaled down version of the bitmap 'softer' and more pleasing. Is it possible to 'blur' a TBitmap in this way?

    Read the article

  • Delphi: How to call a method when i click a control?

    - by Ian Boyd
    i have a method: procedure Frob(Sender: TObject); that i want to call when i click a menu item. The method comes to me though an interface: animal: IAnimal; IAnimal = interface procedure Frob(Sender: TObject); end; The question revolves around what to assign to the OnClick event handler of a menu item (i.e. control): var animal: IAnimal; ... begin ... menuItem := TMenuItem.Create(FileMenu) menuItem.Caption := 'Click me!'; menuItem.OnClick := <-------- what to do ... end; The obvious choice, my first attempt, and the wrong answer is: menuItem.OnClick := animal.Frob; So how can i call a method when user clicks a control? See also Why doesn't it work?

    Read the article

  • Implicit linking vs. explicit linking of DLL in Delphi

    - by Tom
    I'm having trouble getting my dll to work when using explicit linking. Using implicit linking it works fine. Would someone google me a solution? :) No, just kidding, here's my code: This code works fine: function CountChars(_s: Pchar): integer; StdCall; external 'sample_dll.dll'; procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(IntToStr(CountChars('Hello world'))); end; This code doesn't work (I get an access violation): procedure TForm1.Button1Click(Sender: TObject); var LibHandle: HMODULE; CountChars: function(_s: PChar): integer; begin LibHandle := LoadLibrary('sample_dll.dll'); ShowMessage(IntToStr(CountChars('Hello world'))); // Access violation FreeLibrary(LibHandle); end; This is the DLL code: library sample_dll; uses FastMM4, FastMM4Messages, SysUtils, Classes; {$R *.res} function CountChars(_s: PChar): integer; stdcall; begin Result := Length(_s); end; exports CountChars; begin end.

    Read the article

  • I really need help with Delphi... text files and arrays with sorting?

    - by DTB
    I have read a text file (of names) into an array and I need how to sort those names into alphabetical order and display that in a rich edit? Please give me the code from this point onwards: readln(myfile,arr[i]); 'myfile' is the text file and 'arr' is the array of string. Also, I have declared 'i' as an integer even though it is a array of string. Is that OK?

    Read the article

< Previous Page | 104 105 106 107 108 109 110 111 112 113 114 115  | Next Page >