Delphi Pages Forums  

Go Back   Delphi Pages Forums > Search Forums

Lost Password?

Showing results 1 to 50 of 500
Search took 0.43 seconds.
Search: Posts Made By: chris_w
Forum: General 04-20-2009, 11:20 PM
Replies: 6
Views: 1,539
Posted By chris_w
RE: problem with saving Objects in a Objectarray

That just sets the pointer, you need a method to set
the properties.


type
Tcountry = class(TObject)
capital:string;
population:string;
end;
Forum: General 04-11-2009, 08:36 PM
Replies: 7
Views: 972
Posted By chris_w
RE: move and clear a piece

InvalidateRect() just adds the rect to the region, it doesn't
cause the control to actually do anything with it.


//Try this...

procedure ProcessPaintMessages;
var
msg: TMsg;
begin
Forum: General 04-04-2009, 12:10 AM
Replies: 3
Views: 1,158
Posted By chris_w
RE: chinese chess

If it's not legal for it to capture the king then the king must not be in check??

Chris
Forum: General 04-03-2009, 12:09 PM
Replies: 3
Views: 1,158
Posted By chris_w
RE: chinese chess

If this function works, then just use it to see if the canon can
capture the king.

http://www.delphipages.com/threads/thread.cfm?ID=181737&G=181683


"There is a theory which states that if...
Forum: General 03-24-2009, 10:54 PM
Replies: 17
Views: 3,006
Posted By chris_w
RE: generating counter like chars

What you are looking for are all the permuations (possible combinations) of the set of characters, not a counter. As far as the code you posted goes, it is copyrighted and you should not be posting...
Forum: General 03-24-2009, 12:21 AM
Replies: 17
Views: 3,006
Posted By chris_w
RE: generating counter like chars

This does what you want, no function for reversing it tho.

As far as Mr. Baseball's routines, they are Base36 only as they use the ordinal
value of the alpha characters ('0'..'9', 'A'..'Z').

...
Forum: General 03-23-2009, 11:56 AM
Replies: 17
Views: 3,006
Posted By chris_w
RE: generating counter like chars

The function is simply converting the integer value to a string of
base(N) characters. As with any base the first element (of the array)
is equal to zero. So with an array of [a,b,c]:

a = 0
b =...
Forum: General 03-21-2009, 05:23 PM
Replies: 3
Views: 1,652
Posted By chris_w
RE: Read a txt file on my server - ignore the cache and proxy

Try changing code as follows...



//orig code...
FillChar(Buffer, SizeOf(Buffer), 0);
repeat
Result := Result + Buffer;
FillChar(Buffer, SizeOf(Buffer), 0);
...
Forum: General 03-21-2009, 05:05 PM
Replies: 17
Views: 3,006
Posted By chris_w
RE: generating counter like chars

No error checks on the array of chars (duplicates)...



function IntToSomeBase(I: cardinal; const BaseChars: array of char;
MinLength, MaxLength:...
Forum: General 03-10-2009, 06:12 PM
Replies: 11
Views: 1,950
Posted By chris_w
RE: how to read the file from last line to First line ?

You can use the following routines. Takes it about 2 seconds to index
a 40MB test file containing >400K lines. Once the index is built accessing
lines is pretty much instantaneous.


// ...
Forum: General 02-19-2009, 04:51 AM
Replies: 5
Views: 5,973
Posted By chris_w
RE: Getting possible combination's / permutations?

The function worked correctly for calculating the number of
perms without repetition, your answer is correct if you
allow repitition.

Function adapted for repitition:


function...
Forum: General 01-15-2009, 09:14 PM
Replies: 2
Views: 788
Posted By chris_w
RE: function with TComponent as parameter

HaX is declared after ReadX so ReadX does not know what HaX is. Just move the declaration of HaX above the declaration of ReadX.

Chris
Forum: General 01-13-2009, 02:56 PM
Replies: 2
Views: 2,567
Posted By chris_w
RE: Pointers and TList

var
objects: TList;
// pChk: ^TbsSkinCheckRadioBox; //you don't really need this
tmpChk: TbsSkinCheckRadioBox;
begin
objects := TList.Create;
objects.Add(chkPostal); //...
Forum: General 01-09-2009, 07:43 AM
Replies: 3
Views: 1,384
Posted By chris_w
RE: Text encoding in text files

This may help http://tinyurl.com/9lfr53

Chris
Forum: General 01-09-2009, 07:22 AM
Replies: 3
Views: 1,110
Posted By chris_w
RE: Reverse solution from .Canvas.TextWidth('12345678')

If you are using a fixed width font then you can just get
the width of a single character. With true type fonts each
character can be a differant width. The following function
returns the number...
Forum: General 12-25-2008, 10:05 AM
Replies: 6
Views: 1,289
Posted By chris_w
RE: Move rows in Tmemo w/mouse?

Using D7 w/ XP Pro, the TRichEdit supports dragging and dropping of selected text auto magically.

Chris
Forum: General 12-24-2008, 06:27 AM
Replies: 6
Views: 1,289
Posted By chris_w
RE: Move rows in Tmemo w/mouse?

You might want to use a TRichEdit as it already does this.

Chris
Forum: General 12-22-2008, 05:45 PM
Replies: 6
Views: 1,289
Posted By chris_w
RE: Move rows in Tmemo w/mouse?

This is adapted from: http://licomputing.com/cgi-bin/webportal.exe/kbitem?id=111

Requires a TApplicationEvents component (Additional tab).

Should be fine for a simple application, otherwise...
Forum: General 12-19-2008, 07:50 PM
Replies: 6
Views: 1,739
Posted By chris_w
RE: Speeding Up Code...

I think all you really need is to understand the basic storage
of the duplicate count.

TStringList holds strings and objects. The object property is nothing
more than an integer which is used to...
Forum: General 12-18-2008, 03:21 PM
Replies: 6
Views: 1,739
Posted By chris_w
RE: Speeding Up Code...

If you don't need to use a string to store the duplicate count
then keep reading, otherwise you're stuck with parsing which
is a bottleneck to speed.

Should be fast enuf...


type
...
Forum: General 12-16-2008, 08:19 PM
Replies: 4
Views: 1,588
Posted By chris_w
RE: Read specified line of large text file (80+ MB)

Cleaner code, tested on 60MB file...



// Following functions handle ASCII files only, not unicode.
//
// Files containing stray line feed characters (x0A)
// or...
Forum: General 12-15-2008, 08:16 AM
Replies: 4
Views: 1,616
Posted By chris_w
RE: Exception class EAccesViolation with message 'Acces violation at adres

You need to check the value of i and your items.count...


begin
if YourListView.Items.Count > 0 then begin
if (i +1 < 0) or (i +1 >= YourListView.Items.Count) then begin
//reset i...
Forum: General 12-10-2008, 06:12 PM
Replies: 4
Views: 1,588
Posted By chris_w
RE: Read specified line of large text file (80+ MB)

Easier: No. Faster: Probably.

Not tested...


function FSGetLine(const Filename: string; Index: cardinal; var s: string): boolean;
const
BUF_SZ = $10000;
var
...
Forum: General 11-29-2008, 01:47 PM
Replies: 8
Views: 1,359
Posted By chris_w
RE: spliting the sting by more then one charcter

I don't know what I was thinking. Now I am thinking that you don't know what StringReplace() does.

Chris
Forum: General 11-29-2008, 12:16 PM
Replies: 8
Views: 1,359
Posted By chris_w
RE: spliting the sting by more then one charcter

You really don't need a function to this...


YourStringList.Text := StringReplace(YourString, '#|', #10, [rfReplaceAll]);


"There is a theory which states that if ever anybody discovers...
Forum: General 11-27-2008, 07:31 AM
Replies: 2
Views: 824
Posted By chris_w
RE: onmouseup after free error

You should not be freeing a component inside it's own event, use
PostMessage() to free the component. This ensures that the event
will be completed properly.



private
procedure...
Forum: General 11-19-2008, 03:11 PM
Replies: 2
Views: 981
Posted By chris_w
RE: To not make a random number appear twice

This is a simpler way, uses an array of indexes which is
randomized once.


private
{ Private declarations }
FIndexes : array of integer;
FCurrIndex : integer;
procedure...
Forum: General 11-06-2008, 09:14 AM
Replies: 5
Views: 1,391
Posted By chris_w
RE: Scientific format to string

Following works correctly, you will have to play around with
it to get it to display the wrong answer that you want ;)


ShowMessage( Format('%.0f', [StrToFloat('1.0011E+11')]) );


"There...
Forum: General 11-02-2008, 03:49 AM
Replies: 4
Views: 814
Posted By chris_w
RE: Can't synchronize files

Should be ANDing the attr...


if (sr.attr AND faDirectory) <> 0 then begin


"There is a theory which states that if ever anybody discovers
exactly what the Universe is for and why it...
Forum: General 10-18-2008, 11:26 AM
Replies: 9
Views: 17,136
Posted By chris_w
RE: count the number os lines of a text file

Smaller yes, fastest no ;)


//used to create a 15MB test file
procedure TForm1.Button1Click(Sender: TObject);
var
f, s : string;
strs : TStringList;
i : integer;
fs : TFileStream;
Forum: General 10-18-2008, 07:22 AM
Replies: 9
Views: 17,136
Posted By chris_w
RE: count the number os lines of a text file

Using ReadLn(hFile) without the string var should be faster.

Chris
Forum: General 10-18-2008, 04:13 AM
Replies: 9
Views: 17,136
Posted By chris_w
RE: count the number os lines of a text file

Read chunks of the file into a string or an array of byte and
count the number of linefeed characters ( #10 ). Add 1 to the
total if the last line does not end with a linefeed character.
64K is...
Forum: General 10-12-2008, 06:24 AM
Replies: 6
Views: 3,594
Posted By chris_w
RE: Calculation of check digit !

Another one...


function CheckDigit731(const s: string): byte;
var
buf : array of byte;
i, j, k, n : integer;
begin
result := 0;
Forum: General 10-12-2008, 05:43 AM
Replies: 7
Views: 926
Posted By chris_w
RE: Selecting a tile with a image in it ( how? )

You want the user to be abe to select 1 of the 50 images?

Each image will be 64 x 64 pixels?

Do you have 50 individual images (1 for each image) or 1 single
bitmap that contains all of the...
Forum: General 10-12-2008, 04:42 AM
Replies: 14
Views: 2,886
Posted By chris_w
RE: Get RichEdit Content as Image..

Vertical extent fix...



function RELineEnd(RE: TRichEdit; Index: integer): integer;
var
n : integer;
begin
// Returns the end of a line based on...
Forum: General 10-11-2008, 07:58 AM
Replies: 14
Views: 2,886
Posted By chris_w
RE: Get RichEdit Content as Image..

This comes pretty close, see comment about vert extent padding.


function RELineEnd(RE: TRichEdit; Index: integer): integer;
var
n : integer;
begin
...
Forum: General 10-08-2008, 01:55 AM
Replies: 5
Views: 1,092
Posted By chris_w
RE: Triple click

Don't use MessageDlg(), it has always had this problem, use
MessageBox() instead.


if MessageBox(Handle,
'Confirm to ....',
'Warning',
MB_ICONWARN OR...
Forum: General 10-06-2008, 05:04 PM
Replies: 2
Views: 1,029
Posted By chris_w
RE: EAccessException

Possibly:


SetLength(TileFirstColour, 65);
SetLength(TileSecondColor, 65);
SetLength(TileCircleShape, 65);
SetLength(TileTriangleShape, 65);
SetLength(intGroundData, 65);...
Forum: General 10-05-2008, 07:39 AM
Replies: 1
Views: 813
Posted By chris_w
RE: Form running time

//I'm guessing this should be
formModel.RedCube.Position.AsVector := VectorMake(2,3,4) ;

//formModel is a TForm not a TFormHouse1 so it does not
//know what a RedCube is.

//either change...
Forum: General 09-30-2008, 02:49 AM
Replies: 7
Views: 2,022
Posted By chris_w
RE: How to Tile Image with Height

It works, the problem is that you are assuming that TImage's canvas
property is the control's canvas. The canvas property of TImage is
actually the bitmap's canvas as drawn by the TImage. If the...
Forum: General 09-29-2008, 02:21 AM
Replies: 7
Views: 2,022
Posted By chris_w
RE: How to Tile Image with Height

Should do it...


var
x, xx, y, yy : integer;
bmp : TBitmap;
begin
bmp := TBitmap.Create;
try
xx := Image1.Picture.Width;
Forum: General 09-26-2008, 02:31 PM
Replies: 18
Views: 4,027
Posted By chris_w
RE: How to free memory of an array of Tlists - Out of Memory error

Tested in D7, with Windows Task Manager open watching the memory
usage, the memory is being freed (when Button2 is clicked). Are
you sure it is not something else?


type
PVector3f =...
Forum: General 09-25-2008, 02:44 AM
Replies: 18
Views: 4,027
Posted By chris_w
RE: How to free memory of an array of Tlists - Out of Memory error

That's a little bit differant then...


type
PVector3f = ^TVector3f;
TVector3f = array[0..2]of single;

procedure TForm1.Button1Click(Sender: TObject);
var
Contours : array of TList;
Forum: General 09-24-2008, 05:50 PM
Replies: 18
Views: 4,027
Posted By chris_w
RE: How to free memory of an array of Tlists - Out of Memory error

>>
I have also tried Chris sample code(Thanks a lot mate) but I get a compilation
error Invalid Typecast.
<<

Would need slightly more information than that. For instance what is a
TVector3f?...
Forum: General 09-23-2008, 02:19 PM
Replies: 18
Views: 4,027
Posted By chris_w
RE: How to free memory of an array of Tlists - Out of Memory error

This might be easier to follow...


var
Contours : array of TList;

//populate Contours with 32 TLists...
SetLength(Contours, 32);
for i := 0 to 31 do
Countours := TList.Create;
Forum: General 09-19-2008, 02:40 AM
Replies: 3
Views: 1,357
Posted By chris_w
RE: creating off screen buffer for graphics routines

Suppose you have a TPaintBox with the OnPaint event set to draw
something that takes a little while.

Without buffering it would look something like this:

procedure...
Forum: General 09-19-2008, 02:20 AM
Replies: 2
Views: 1,246
Posted By chris_w
RE: tfont within custom component

You don't really need the setter method.


class = TCustomComp(TComponent)
private
FFont: TFont; // declare instance of TFont
procedure FFontOnChange(Sender: TObject);
public
...
Forum: General 09-13-2008, 04:23 AM
Replies: 5
Views: 933
Posted By chris_w
RE: CompressionStream, add new data to file

If you want to write multiple streams or blocks of data to a single
file/stream then you need to store the size of the data also.

Very basic example (not tested)...


//to save data to a new...
Forum: General 09-13-2008, 03:55 AM
Replies: 3
Views: 1,340
Posted By chris_w
RE: Always on top

This will fix the problems with Delphi and stay on top.


//...................................
unit StayOnTopFix;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Forms;
Forum: General 09-10-2008, 05:49 PM
Replies: 3
Views: 1,159
Posted By chris_w
RE: Delete read-only archives

(* Example for Windows NT (NOT Win95)
( MoveFileEx is not supported in ME, 98, 95 )

To replace/delete a running file (like a dll that is in use)....


Suppose you have 2...
Showing results 1 to 50 of 500

 
Forum Jump

All times are GMT. The time now is 10:56 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.