Re: [Lazarus] TFileStream

2009-01-29 Thread Dave Coventry
= snip ===
   case ftype of
 43://'+'
 begin
   FS:=TFileStream.Create(fname, fmshareDenyWrite);
   Try
 FS.Seek(pos,soFromBeginning);
 FS.ReadBuffer(fldheader[0],4);
 increm:=LEtoN(PLongInt(fldheader)^)+1;
 for m:=0 to 3 do
 begin
   fldheader[m]:=increm and 255;
   increm:=increm shr 8;
 end;
  FS.Seek(pos,soFromBeginning);
  FS.WriteBuffer(fldheader[0],4); - Fails here
   Finally
 FreeAndNil(FS);
   end;
 end;
   end;
= snip ===

Continuing on the same block:

I am trying to read a block of 4 bytes, increment it by one and write
it back again.

However, if fails on the write.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-29 Thread Michael Van Canneyt


On Thu, 29 Jan 2009, Dave Coventry wrote:

 = snip ===
case ftype of
  43://'+'
  begin
FS:=TFileStream.Create(fname, fmshareDenyWrite);
Try
  FS.Seek(pos,soFromBeginning);
  FS.ReadBuffer(fldheader[0],4);
  increm:=LEtoN(PLongInt(fldheader)^)+1;
  for m:=0 to 3 do
  begin
fldheader[m]:=increm and 255;
increm:=increm shr 8;
  end;
   FS.Seek(pos,soFromBeginning);
   FS.WriteBuffer(fldheader[0],4); - Fails here
Finally
  FreeAndNil(FS);
end;
  end;
end;
 = snip ===
 
 Continuing on the same block:
 
 I am trying to read a block of 4 bytes, increment it by one and write
 it back again.
 
 However, if fails on the write.

Probably because you failed to specify fmOpenReadWrite.
fmshareDenyWrite does not automatically mean write access.

Michael.

 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
 
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-29 Thread Paul Ishenin
Dave Coventry wrote:
...
FS:=TFileStream.Create(fname, fmshareDenyWrite);
...
 I am trying to read a block of 4 bytes, increment it by one and write
 it back again.
 
 However, if fails on the write.

Please read carefully what have you written:

FS := TFileStream.Create(fname, fmShareDenyWrite);

you passed only fmShareDenyWrite but you have not told to the file 
stream that you want to write :)

There are few modes in which you can open your stream:

   fmCreate= $;
   fmOpenRead  = 0;
   fmOpenWrite = 1;
   fmOpenReadWrite = 2;

You had not passed any of them = you passed 0 = fmOpenRead. As result 
you can only read.

If you want to read and write then pass fmOpenReadWrite as mode:

FS := TFileStream.Create(fname, fmOpenReadWrite or fmShareDenyWrite);

Best regards,
Paul Ishenin.

___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] How I add elements into a colums of TKOLListView with several colums?

2009-01-29 Thread User
Is this possible?

Best regards.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fsStayOnTop under windows

2009-01-29 Thread Luca Olivetti
En/na Henry Vermaak ha escrit:
 2009/1/28 Luca Olivetti l...@wetron.es:
 En/na Henry Vermaak ha escrit:

 Very funny, but it's not the case at hand: I just need the windows of my
 application to always stay on top to the windows of another application.
 I can do it in delphi and lazarus/qt, I just need a hack to do the same
 under win32.
 so what happens if the other application wants to be on top of yours?
 The other application never wants to be on top of mine. Really.
 
 i'm sure he's saying the same about your application :)

There's no he. This isn't a general purpose pc, where I'm fighting for 
screen space with other applications.
This pc will be running just these two apps, and I'm responsible for 
both, but since the development environment of the other application is 
not really good (actually it's a POS), I'm trying to offload some of the 
development to lazarus, so that when the user clicks on a button in the 
other app, it will spawn a lazarus app that should stay on top (because 
the user can click on the previous app to open another lazarus window 
and so on and so forth).

Bye
-- 
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004  Fax +34 93 5883007
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fsStayOnTop under windows

2009-01-29 Thread Luca Olivetti
En/na JoshyFun ha escrit:

 
 Affected file is win32callback.inc


Thanks, that was exactly what I had in mind. It works beautifully.

 Now you must control the StayOnTop using the HWND_TOPMOST and the
 setwindowlong.

Setting fsStayOnTop seems to be enough.

Bye
-- 
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004  Fax +34 93 5883007
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Drawing text in WinCE

2009-01-29 Thread Paul van Helden
Hi All,

I'm new to Lazarus having decided to switch from Delphi for a WinCE 
project. I'm stumped though. Labels on forms display garbage characters. 
Having spent a whole two days learning about Lazarus internals, Unicode, 
Widestrings, etc., I'm now pulling out my hair and the project cannot 
continue.

The following code produces the same garbage characters:

procedure TGPSForm.SatellitePaintBoxPaint(Sender: TObject);
var
  Rect: TRect;
  Dx: Integer;
  W: WideString;
begin
  with SatellitePaintBox do
  begin
Rect:=ClientRect;
W:='Abc';
Windows.ExtTextOutW(Canvas.Handle, 1, 1, 0, LPRECT(@Rect), 
PWideChar(W), Length(W), @Dx);
  end;
end;

Any ideas?

Thanks,

Paul.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Drawing text in WinCE

2009-01-29 Thread John vd Waeter
Paul van Helden wrote:
 Hi All,
 
 I'm new to Lazarus having decided to switch from Delphi for a WinCE 
 project. I'm stumped though. Labels on forms display garbage characters. 
 Having spent a whole two days learning about Lazarus internals, Unicode, 
 Widestrings, etc., I'm now pulling out my hair and the project cannot 
 continue.
 
 The following code produces the same garbage characters:
 
 procedure TGPSForm.SatellitePaintBoxPaint(Sender: TObject);
 var
   Rect: TRect;
   Dx: Integer;
   W: WideString;
 begin
   with SatellitePaintBox do
   begin
 Rect:=ClientRect;
 W:='Abc';
 Windows.ExtTextOutW(Canvas.Handle, 1, 1, 0, LPRECT(@Rect), 
 PWideChar(W), Length(W), @Dx);
   end;
 end;
 
 Any ideas?
 

Hmm,
Dunno, I use KOL without major problems.
But what is output when you try:

with SatellitePaintBox do
  begin
Canvas.Textou(1,1,'Abc');
  end;

?

John
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fsStayOnTop under windows

2009-01-29 Thread JoshyFun
Hello Hans-Peter,

Thursday, January 29, 2009, 3:51:03 AM, you wrote:

 HV so what happens if the other application wants to be on top of yours?
 
 In Windows at least, topmost windows are implemented as a second
 windows layer, one for normal windows and other for topmost ones.

HPD Which Windows version(s)?

AFAIK all Windows versions.

-- 
Best regards,
 JoshyFun

___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Drawing text in WinCE

2009-01-29 Thread Felipe Monteiro de Carvalho
It works for me ... it's a rather wierd problem ... TLabel not working?

What Lazarus version are you using? How did you install support for wince?

Do you have a screenshot of the problem?

Also, are your source files UTF-8 encoded?

If you start a new project, put only a label in the form and run that
does it work?

Are you using a device or the emulator? Can you test with the
emulator? (instructions to install it in the wiki)

-- 
Felipe Monteiro de Carvalho
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] ptInRect question

2009-01-29 Thread Michael Van Canneyt

Hi,

I have a question regarding the following function:

function PtInRect(const Rect : TRect;const p : TPoint) : Boolean;

begin
  PtInRect:=(p.y=Rect.Top) and
(p.yRect.Bottom) and
(p.x=Rect.Left) and
(p.xRect.Right);
end;

Is there a reason why the top/left sides are included (=), and the
left/bottom sides are not included ? I would expect them to be included as well.

Michael.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Interact with M$ Word

2009-01-29 Thread Bart
Currently I'm working on an app that needs to interact with M$ Word.
The intended users are computer noobs, so I expect no knowledge from
them whatsoever.

Problem.
My app calculates/compose tabular data (in the order of  6 cols x 50 rows).
These data have to be inserted into a word document as a word table.
(Most users will not be able to convert text with tabs to a table in
Word, no matter how often explained).

Two different approaches come to mind.

First approach:
Paste the data (all strings) onto the clipboard in Word Table format.
(I can get the users to paste this in their document...)
Does anyone have a clue as to how to achieve this?


Second approach:
Use MS Office automation.
Create new document from template (how do I know where user's
templates (*.dot files)  are?).
Go to right place in document.
Create table
Insert data into table.

There is a basic wiki document on how to open a word doc in Word with
automation, but I never used office automation at all, so all steps I
have no clue as to how to achieve them.


If at all possible I'd prefer the first approach.

Anyone got some suggestions or knows a good place to start looking.
Mind you, I'm really just a basic-stuff programmer.

Bart
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ptInRect question

2009-01-29 Thread dmitry boyarintsev
Delphi rectangles are used to wrap Win32 GDI calls.

here's a quote from msdn FillRect function:
-= start quote =-
When filling the specified rectangle, FillRect does not include the
rectangle's right and bottom sides. GDI fills a rectangle up to, but
not including, the right column and bottom row, regardless of the
current mapping mode.
-= end of quote =-

so function ptInRect can be determined if point is inside filled rect or not.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ptInRect question

2009-01-29 Thread dmitry boyarintsev
AFAIK, Delphi compat.Here's the delphi code from Types unit.

function PtInRect(const Rect: TRect; const P: TPoint): Boolean;
begin
  Result := (P.X = Rect.Left) and (P.X  Rect.Right) and (P.Y = Rect.Top)
and (P.Y  Rect.Bottom);
end;
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ptInRect question

2009-01-29 Thread Michael Van Canneyt


On Fri, 30 Jan 2009, dmitry boyarintsev wrote:

 AFAIK, Delphi compat.Here's the delphi code from Types unit.
 
 function PtInRect(const Rect: TRect; const P: TPoint): Boolean;
 begin
   Result := (P.X = Rect.Left) and (P.X  Rect.Right) and (P.Y = Rect.Top)
 and (P.Y  Rect.Bottom);
 end;

I found this out already, but why, what is the rationale ?

Michael.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Canvas clipping ?

2009-01-29 Thread Michael Van Canneyt

Hi,

Is TCanvas clipping supported ? I set cliprect, but nothing happens...

Michael.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ptInRect question

2009-01-29 Thread dmitry boyarintsev
 I found this out already, but why, what is the rationale ?

i have only one thought, about the reason for this:

if you follow the Microsoft GDI rules, then you'll get
width := r.Right - r.Left;

otherwise (if r.Right is also filled then drawn), you'll end-up with
additional operation
width := r.Right - r.Left + 1;
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Interact with M$ Word

2009-01-29 Thread tiziano de togni
Bart ha scritto:
 Currently I'm working on an app that needs to interact with M$ Word.
 The intended users are computer noobs, so I expect no knowledge from
 them whatsoever.
 
 ...
 Anyone got some suggestions or knows a good place to start looking.
 Mind you, I'm really just a basic-stuff programmer.

If the dimensions of your table are fixed, there is another method that 
avoids you lot af headaches: build the document you need with word, put 
into the cells special tags, i.e: %r01c01, %r02c01,..., an so on.

Then save the document as rtf (rich text format) so your program can 
read in the file, substitute the tags with your values and save it again.

Hope this can help,
bye
-- 
tiziano de togni
__
http://digilander.libero.it/tizzziano/
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] KeyDown Bugs ?

2009-01-29 Thread Darmawan Sugiarto
I have a problem

Look at this code

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: 
TShiftState );
begin
  Key:=0;
end;

In this code, Edit1.Text still empty string but If I change the code like this

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: 
TShiftState);
begin
  Key:=0;
  ShowMessage('a');
end;

then the Edit1.Text become fill by char that I stroke. 

Is this a bug ?

=INTOSOFT

   ALEXIO CHAOS

   darmawan_sugia...@yahoo.com   

  Yahoo Messager

=



  ___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ptInRect question

2009-01-29 Thread Graeme Geldenhuys
On Fri, Jan 30, 2009 at 12:11 AM, Michael Van Canneyt
mich...@freepascal.org wrote:

 function PtInRect(const Rect : TRect;const p : TPoint) : Boolean;

 begin
  PtInRect:=(p.y=Rect.Top) and
(p.yRect.Bottom) and
(p.x=Rect.Left) and
(p.xRect.Right);
 end;

 Is there a reason why the top/left sides are included (=), and the
 left/bottom sides are not included ? I would expect them to be included as 
 well.

I would guess to conform with Microsoft's GDI behaviour. GDI
rectangles are drawn one pixel less than what you specified. Probably
also relates to Mattias's answer, that a pixel also takes up a certain
amount of space. I remember in fpGUI I had plenty of issues getting
the GDI and X11 drawing backends to work identical. Hence I created a
custom TfpgRect which includes the Width and Height values. In fpGUI I
tried to make all Canvas drawing methods use Top,Left,Width and
Height. This gave a more consistent and expected behaviour.

  TfpgRect = object  // not class for static allocations
Top: TfpgCoord;
Left: TfpgCoord;
Width: TfpgCoord;
Height: TfpgCoord;
procedure SetRect(aleft, atop, awidth, aheight: TfpgCoord);
function  Bottom: TfpgCoord;
function  Right: TfpgCoord;
procedure SetBottom(Value: TfpgCoord);
procedure SetRight(Value: TfpgCoord);
  end;


Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus