Search Results

Search found 4237 results on 170 pages for 'delphi 2009'.

Page 32/170 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • [Delphi] How would you refactor this code?

    - by Al C
    This hypothetical example illustrates several problems I can't seem to get past, even though I keep trying!! ... Suppose the original code is a long event handler, coded in the UI, triggered when a user clicks a cell in a grid. Expressed as pseudocode it's: if Condition1=true then begin //loop through every cell in row, //if aCell/headerCellValue>1 then //color aCell red end else if Condition2=true then begin //do some other calculation adding cell and headerCell values, and //if some other product>2 then //color the whole row green end else show an error message I look at this and say "Ah, refactor to the strategy pattern! The code will be easier to understand, easier to debug, and easier to later extend!" I get that. And I can easily break the code into multiple procedures. The problem is ultimately scope related. Assume the pseudocode makes extensive use of grid properties, values displayed in cells, maybe even built-in grid methods. How do you move all that to another unit, without referencing the grid component in the UI--which would break all the "rules" about loose coupling that make OOP valuable? ... I'm really looking forward to responses. Thanks, as always -- Al C.

    Read the article

  • KaZip for C++Builder2009/Delphi

    - by Katsumi
    Hi. I have download and install KaZip2.0 on C++Builder2009 (with little minor changes = only set type String to AnsiString). I have write: KAZip1->FileName = "test.zip"; KAZip1->CreateZip("test.zip"); KAZip1->Active = true; KAZip1->Entries->AddFile("pack\\text.txt","xxx.txt"); KAZip1->Active = false; KAZip1->Close(); now he create a test.zip with included xxx.txt (59byte original, 21byte packed). I open the archiv in WinRAR successful and want open the xxx.txt, but WinRAR says file is corrupt. :( What is wrong? Can somebody help me? Extract not working, because file is corrupt? KAZip1->FileName = "test.zip"; KAZip1->Active = true; KAZip1->Entries->ExtractToFile("xxx.txt","zzz.txt"); KAZip1->Active = false; KAZip1->Close();

    Read the article

  • Correct Delphi compiler switches to stop in the user's code, not my component's

    - by Jeremy Mullin
    I'm modifying our VCL components so the end user's application links to our dcu files, instead of building our source code each time. We have everything working, but I want the debugger to stop on the user's code when an exception is raised. At first it would stop in our dcu and open the CPU window. I was able to prevent that by removing debug info from the dcu files. But now it still doesn't stop in the users code (like DevExpress libraries and others do). The following screencast is a short example. The first time I cause an exception in the DevExpress code, and the debugger correctly stops in my button event. The second time I cause an exception in my components, but the debugger doesn't have my button event on the call stack, and doesn't show me where the problem was. Any ideas why? http://screencast.com/t/NjhlOTRk Currently building the DCU's with these options: -$W+ -$D- -h -w -q Update: The TDataSet methods in between my component and the button event seem to cause this behavior. If I instead call a direct method of my table, I get the expected behavior. I'm guessing there isn't anything I can do about this, but I'm still curious why it happens.

    Read the article

  • Delphi: Multiple tokens edit component

    - by Dorin
    Hello, I'm looking for an enchanced edit component that allow users to input multiple tokens (items) manually separated by some symbol, or to select them from another source. It's something like "TO" field in outlook or facebook that allow you to input multiple recipients. Can anyone suggest any solution? Thanks in advice!

    Read the article

  • deleting dublicates in listview delphi

    - by radick
    hi all I am trying to remove dublicates in my listview my function like this below procedure RemoveDuplicates(const LV:TbsSkinListView); var i,j: Integer; begin LV.Items.BeginUpdate; LV.SortType := stText; try for i := 0 to LV.Items.Count-1 do begin for j:=i+1 to LV.Items.Count-1 do begin if SameText(LV.Items[i].SubItems[0], LV.Items[j].SubItems[0]) and SameText(LV.Items[i].SubItems[1], LV.Items[j].SubItems[1]) and SameText(LV.Items[i].SubItems[2], LV.Items[j].SubItems[2]) and SameText(LV.Items[i].SubItems[3], LV.Items[j].SubItems[3]) then LV.Items.Delete(j); end; end; finally LV.SortType := stNone; LV.Items.EndUpdate; end; ShowMessage('Deleted'); end; but its not doing what i intended can anyone help me ?

    Read the article

  • Delphi VirtualStringTree - Check for Duplicates?

    - by Jeff
    Hello S.O! Yeah, I know I post a lot of questions, but thats because I either need assurance that I am doing it right, what I am doing wrong, or if I am totally clueless, and cant find anything in the documentation. Anyways, I am trying to check for duplicate nodes. Here is how I would want to do it: Loop thru my nodes, and compare each single node's text (record), but if I got many nodes, wouldnt that be too time and memory consuming? Would there be a better approach for this? Thanks! - Jeff.

    Read the article

  • Load two instances of the same DLL in Delphi

    - by Tom
    Here's my problem: I would like to create two separate instances of the same DLL. The following doesn't work because Handle1 and Handle2 will get the same address Handle1 := LoadLibrary('mydll.dll'); Handle2 := LoadLibrary('mydll.dll'); The following works, but I have to make a copy of the DLL and rename it to something else (which seems a bit silly) Handle1 := LoadLibrary('mydll.dll'); Handle2 := LoadLibrary('mydll2.dll'); Is there a way to have only one DLL file, but load several instances of it?

    Read the article

  • Passing parameters to a delphi TFrame

    - by ajob
    To avoid singletons and global variables I'd like to be able to pass parameters to a TFrame component. However since a TFrame normally is included on form at design time it is only possible to use the default constructor. The parent form can of course set some properties in the OnCreate callback after the TFrame has been created. However this does not ensure that a property is not forgotten, and the dependencies are not as clear as using a constructor. A nice way would be if it was possible to register a factory for creating components while the dfm file is being read. Then the required parameters could be passed to the TFrame constructor when created by the factory. Is there a way of accomplishing this? Or does anyone have a better solution on how to pass parameters to a TFrame?

    Read the article

  • Loading specific icon size into TIcon from stream (Delphi XE)

    - by moodforaday
    My application downloads and displays favicons for specific websites. I followed Bing's solution for detecting image format from stream, but have hit another snag. Assuming an actual icon image, the code goes like this: var icon : TIcon; begin icon := TIcon.Create; try icon.LoadFromStream( faviconStream ); spFavicon.Glyph.Assign( icon ); finally icon.Free; end; end; (spFavicon is TRzGlyphStatus from Raize Components. Its Glyph property is a TBitmap) Now, this works, but sometimes the downloaded icon contains multiple images in different sizes, e.g. 32x32 in addition to the expected 16x16. For some reason the control's Glyph property picks the larger size. How can I load only the 16x16 size into TIcon, or from TIcon into TBitmap? Test favicon: http://www.kpfa.org/favicon.ico On edit: If at all possible, I'd rather avoid saving the icon to a file first.

    Read the article

  • Error : Implementation for method missing (Delphi Prism)

    - by Ilya
    I wrote my method: LangChange type MainForm = partial class(System.Windows.Forms.Form) private ... method LangChange(); protected method Dispose(disposing: Boolean); override; public constructor; end; implementation ... method LangChange(); begin ... end; However,I have an error Error 1 (PE33) Implementation for method "Compiler.MainForm.LangChange" missing What is wrong?Help please!

    Read the article

  • Delphi fast large bitmap creation (without clearing)

    - by Ritsaert Hornstra
    When using the TBitmap wrapper for a GDI bitmap from the unit Graphics I noticed it will always clear out the bitmap (using a PatBlt call) when setting up a bitmap with SetSize( w, h ). When I copy in the bits later on (see routine below) it seems ScanLine is the fastest possibility and not SetDIBits. function ToBitmap: TBitmap; var i, N, x: Integer; S, D: PAnsiChar; begin Result := TBitmap.Create(); Result.PixelFormat := pf32bit; Result.SetSize( width, height ); S := Src; D := Result.ScanLine[ 0 ]; x := Integer( Result.ScanLine[ 1 ] ) - Integer( D ); N := width * sizeof( longword ); for i := 0 to height - 1 do begin Move( S^, D^, N ); Inc( S, N ); Inc( D, x ); end; end; The bitmaps I need to work with are quite large (150MB of RGB memory). With these iomages it takes 150ms to simply create an empty bitmap and a further 140ms to overwrite it's contents. Is there a way of initializing a TBitmap with the correct size WITHOUT initializing the pixels itself and leaving the memory of the pixels uninitialized (eg dirty)? Or is there another way to do such a thing. I know we could work on the pixels in place but this still leaves the 150ms of unnessesary initializtion of the pixels.

    Read the article

  • delphi "Invalid use of keyword" in TQuery

    - by Baldric
    I'm trying to populate a TDBGrid with the results of the following TQuery against the file Journal.db: select * from Journal where Journal.where = "RainPump" I've tried both Journal."Where" and Journal.[Where] to no avail. I've also tried: select Journal.[Where] as "Location" - with the same result. Journal.db is a file created by a third party and I am unable to change the field names. The problem is that the field I'm interested in is called 'where' and understandably causes the above error. How do I reference this field without causing the BDE (presumably) to explode?

    Read the article

  • saving a records containing a member of type string to a file (Delphi, Windows)

    - by wonderer
    I have a record that looks similar to: type TNote = record Title : string; Note : string; Index : integer; end; Simple. The reason I chose to set the variables as string (as opposed to an array of chars) is that I have no idea how long those strings are going to be. They can be 1 char long, 200 or 2000. Of course when I try to save the record to a type file (file of...) the compiler complains that I have to give a size to string. Is there a way to overcome this? or a way to save those records to an untyped file and still maintain a sort of searchable way? Please do not point me to possible solutions, if you know the solution please post code. Thank you

    Read the article

  • Subtracting Delphi Time Ranges from a Date Range, Calculate Remaining Time

    - by Anagoge
    I'm looking for an algorithm that will help calculate a workday working time length. It would have an input date range and then allow subtracting partially or completely intersecting time range slices from that date range and the result would be the number of minutes (or the fraction/multiple of a day) left in the original date range, after subtracting out the various non-working time slices. For Example: Input date range: 1/4/2010 11:21 am - 1/5/2010 3:00 pm Subtract out any partially or completely intersecting slices like this: Remove all day Sunday Non-Sundays remove 11:00 - 12:00 Non-Sundays remove time after 5:00 pm Non-Sundays remove time before 8:00 am Non-Sundays remove time 9:15 - 9:30 am Output: # of minutes left in the input date range I don't need anything overly-general. I could hardcode the rules to simplify the code. If anyone knows of sample code or a library/function somewhere, or has some pseudo-code ideas, I'd love something to start with. I didn't see anything in DateUtils, for example. Even a basic function that calculates the number of minutes of overlap in two date ranges to subtract out would be a good start.

    Read the article

  • Delphi: Transporting Objects to remote computers

    - by pr0wl
    Hallo. I am writing a tier2 ordering software for network usage. So we have client and server. On the client I create Objects of TBest in which the Product ID, the amount and the user who orders it are saved. (So this is a item of an Order). An order can have multiple items and those are saved in an array to later send the created order to the server. The class that holds the array is called TBestellung. So i created both TBest.toString: string; and TBest.fromString(source: string): TBest; Now, I send the toString result to the server via socket and on the server I create the object using fromString (its parsing the attributes received). This works as intended. Question: Is there a better and more elegant way to do that? Serialisation is a keyword, yes, but isn't that awful / difficult when you serialize an object (TBestellung in this case) that contains an Array of other Objects (TBest in this case)? //Small amendment: Before it gets asked. Yes I should create an extra (static) class for toString and fromString because otherwise the server needs to create an "empty" TBest in order to be able to use fromString.

    Read the article

  • Ideas for storing e-mail messages in a Delphi client server application

    - by user193655
    There are many suggestions here and there for storing e-mail messages. Somehow what I am doing is writing an Outlook addin to send emails from inbox/sent folders directly to my application. So only what is really interesting is saved. And I decide where to save it. Imagine this case: I recieve an email from a customer. It's up to me to decide whether I should save it on the customer or on the order 24 that that customer did. So this is why I am doing the add in, and not some automatic storing of emails = noise after some time. This said, how to store the emails? For the emails that I recieve or send through Outlook the idea could be save the whole file in a blob field (so the eml file), may be I can save also other info (like the subject) in another text field. But the problem comes when I write an email from my application. In this case I am not generating an eml file, I send through MAPI data to Outlook to compose an email that I will send with Outlook (so in this case I cannot save the eml), or I directly send it with Indy. Also in this case I don't have the eml file... One idea could be that the all the emails that I auto compose have a special flag that the Add in recognises and therefore when I send the mail it is stored back to the DB. So in this case I can save the eml also of the mails I sent from my application. May you comment?

    Read the article

  • Delphi set Panel visible after post

    - by Daan Kleijngeld
    this is my code: if DRelatiebeheer.ContactpersoonID.Post = Action then KJSMDBGrid1.RefreshData; KJPanel4.Visible := true; my question is how can i set the panel on visible when the post is succesfully ended. I dont know how to fix it, tried many ways but didn't find a solution for the problem. I think the code doesn't work, because i put it invisible on the OnGetCellParams event. And I only want to set the last panel visible when the information is posted procedure TFRelatiebeheer.KJSMDBGrid1GetCellParams(Sender: TObject); begin if DRelatiebeheer.ACCID.AsInteger <= 0 then KJPanel3.Visible := false; KJPanel4.Visible := false; else begin KJPanel3.Visible := true; end; this is my OnGetCellParams event, this is the other procedure TFRelatiebeheer.SaveCancel(Sender: TObject); begin if (DRelatiebeheer.CID.State in [dsEdit, dsInsert]) then DRelatiebeheer.CID.Post; DRelatiebeheer.AID.Post; if DRelatiebeheer.CID.Post = Action then KJSMDBGrid1.RefreshData; KJPanel4.Visible := true; end;

    Read the article

  • Delphi Math: Why is 0.7<0.70?

    - by Al C
    If I have variables a, b, an c of type double, let c:=a/b, and give a and b values of 7 and 10, then c's value of 0.7 registers as being LESS THAN 0.70. On the other hand, if the variables are all type extended, then c's value of 0.7 does not register as being less than 0.70. This seems strange. What information am I missing?

    Read the article

  • Delphi SQLite Update causing errors to appear.

    - by NeoNMD
    I have used Inserts, selects, updates, deleted without problem all over the program but for some reason this specific section causes it to except and not run the SQL I send it. I am trying to "UPDATE SectionTable(AreaID) VALUES ('+IntToStr(ActClient.AreaID)+') WHERE SectionID='+IntToStr(iCount)" The section with the ID "iCount" exists deffinately. The ActClient.AreaID is "2" and its overwriting null data in the "SectionTable" table. What is the problem here? OpenDatabase(slDb); sltb:=sldb.GetTable('SELECT * FROM SectionTable WHERE SectionID='+IntToStr(iCount)); OutputDebugString(PAnsiChar(sltb.FieldAsString(sltb.FieldIndex['SectionID'])+sltb.FieldAsString(sltb.FieldIndex['Gender'])+sltb.FieldAsString(sltb.FieldIndex['CompetitionID']))); sSQL := 'UPDATE SectionTable(AreaID) VALUES ('+IntToStr(ActClient.AreaID)+') WHERE SectionID='+IntToStr(iCount); sldb.ExecSQL(sSQL); CloseDatabase(slDb); I get this error message appear when this is ran. --------------------------- Debugger Exception Notification --------------------------- Project CompetitionServer.exe raised exception class ESQLiteException with message 'Error executing SQL. Error [1]: SQL error or missing database. "UPDATE SectionTable(AreaID) VALUES (2) WHERE SectionID=2": near "(": syntax error'. Process stopped. Use Step or Run to continue. --------------------------- OK Help ---------------------------

    Read the article

  • Add code before initialization of units in Delphi

    - by Alan Clark
    Is there a place where I can add code that will be executed before unit initialization? The reason I want to do this is I need to change the DecimalSeparator, this has to be done before the initialization of some units. I have put it in the project source, before Application.Initialize but it is too late by then. As I see it the only choice I have is to put it in the initialization of the unit that needs the DecimalSeparator to be changed, is this the case? Thanks in advance for any advice.

    Read the article

  • extending the delphi TEditCopy action to also copy listbox items to clipboard

    - by PA
    I have a form with most of its functionality implemented using standard TAction. I have a menu, a toolbar, and some toobuttons. I have implemented clipboard copy/paste with no code at all, just using TEditCopy and TEditPaste actions. It works perfect in the TEdit and TMemo boxes I have. Now, I want it to work with TListBox, too. Specifically, I want to be able to copy the selected list item in a TListBox using the very same menuitems, key shortcuts and toolbuttons. So, I believe I will need to extend the TEditCopy Action. But it doesn't seem very straight forward to me. In particular, the TEditAction checks for the focused control to be a TCustomEdit control, which a TListBox it is not. I am a little affraid that it will be just too much work. The obvious alternative is to just forget about the standard actions and implement the copy to clipbard in the OnExecute method of a generic TAction. But, before giving up, do you have some idea, hint or trick that would help me extend the standard TEditCopy action?

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >