[fpc-pascal]Message methods - DefaultHandler

2004-06-08 Thread Mr. Ego
Hello,
 I have some problem with DefaultHandler method. When I pass a message for which 
is special handler defined everything is ok, but when it should be passed to 
DefaultHandler (which is overriden) it does nothing. Here is some sample code:

{$MODE OBJFPC}
type TMyMessage = record
   MSGID : cardinal;
   text : string;
   end;

 TTest=class(TObject)
   constructor Init;
   procedure Handle (var MyMessage : TMyMessage); Message 1; virtual;
   procedure DefaultHandler(var MyMessage : TMyMessage); virtual;
   destructor Done;
   end;
 
constructor TTest.Init;
begin
end;
 
procedure TTest.Handle (var MyMessage : TMyMessage);
begin
  writeln(MyMessage.text);
end;
 
procedure TTest.DefaultHandler(var MyMessage : TMyMessage);
begin
  writeln(MyMessage.Text);
end;
 
destructor TTest.Done;
begin
end;
 
var MyMessage : TMyMessage;
Moje : TTest;
 
begin
Moje:=TTest.Init;
MyMessage.MSGID:=1;
MyMessage.text:='Hello, world';
Moje.Dispatch(MyMessage); {this is handled by TTest.Handle method}
MyMessage.MSGID:=2;
Moje.Dispatch(MyMessage); {this should be handled by DefaultHandler, but it isn't}
Moje.Done;
end.

It should write two times the "Hello world message". For the first time from method 
TTest.Handle, and for the second time from method TTest.DefaultHandler. But 
TTest.DeafultHandler doesn't do anything (it writes only one message).

Could anybody help me, please?


Pavel B.





___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Re: [fpc-pascal]Re: [fpc-pascal]Can't find lmysqlclient What I'm missing? SOLVED!!

2004-06-08 Thread Eduardo Lopez
Thank you to all.
I have solved the problem. Yours tips help me to check what I'm doing wrong:
1 - In home (Mandrake 8.2) was only the symbolic link: when I created 
the correct it works:
   ln -s .. *libmysqlclient.so*

2 - In work (Fedora Core 1), I haven't installed the mysq-client rpm, 
when I do it, then I update then fpc.cfg to include then /usr/lib/mysql 
and ... voilá... all working.   :-)

Thank you for your patience... 

Eduardo.

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Message methods - DefaultHandler

2004-06-08 Thread Thomas Schatzl
Hello,

>  I have some problem with DefaultHandler method. When I pass a
>message for which is special handler defined everything is ok, but when
>it should be passed to DefaultHandler (which is overriden) it does
>nothing. Here is some sample code:
>
> {$MODE OBJFPC}
> type TMyMessage = record
>MSGID : cardinal;
>text : string;
>end;
>
>  TTest=class(TObject)
>constructor Init;
>procedure Handle (var MyMessage : TMyMessage); Message 1; virtual;
>procedure DefaultHandler(var MyMessage : TMyMessage); virtual;
>destructor Done;
>end;
>
> It should write two times the "Hello world message". For the first time
from
> method TTest.Handle, and for the second time from method
> TTest.DefaultHandler. But TTest.DeafultHandler doesn't do anything
> (it writes only one message).

The DefaultHandler method has a wrong signature and so your method is not
called. You have to override

procedure Dispatch(var Message); override;

and use a typecast in the method implementation, e.g.

procedure TTest.DefaultHandler(var MyMessage);
begin
  writeln(TMyMessage(MyMessage).Text);
end;

Note that Delphi (don't have FPC installed on this machine, sorry) complains
that message methods may not be declared as virtual (doesn't make much sense
imo, since dispatching a message to an object always is "bound" dynamically
using the message identifier).

Hth,
  Thomas


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Message methods - DefaultHandler

2004-06-08 Thread Peter Vreman
> Hello,
>  I have some problem with DefaultHandler method. When I pass a message
> for which is special handler defined everything is ok, but when it
> should be passed to DefaultHandler (which is overriden) it does
> nothing. Here is some sample code:

You need to use 1.9.x. It also gives a warning why the code does not work:

p.pp(10,18) Warning: An inherited method is hidden by
"TTest.DefaultHandler(var TMyMessage)"



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Windows unit problems

2004-06-08 Thread Matthews
I'm attempting to retrieve information about the current resolution 
settings, but I'm not having much luck.  I've downloaded the Borland Win32 
API, but I'm still stuck with creating the device context, and so on.  I 
need some massive help with this... =(

Thanks in advance.
-Lukas
PS The code below is just a snippet from a larger program, but only the 
important stuff has been included.

Program ResGrabber;
Uses
crt,windows;
type
tResSettings=record
w,h,bits,refresh:integer;
end;
var
res:hdc;
display:pchar;
curr:tResSettings;
dev:devmode;
BEGIN
	clrscr;
	Display := 'DISPLAY';
	res := CreateDC(Display,Display,nil,{Am not sure what to put here... =( });
	if res = {Also, what type does res return, so I can know what should go 
here for a failure} then
		begin
			writeln('GetCurrentSettings failed - the return value to res was 
null/nil.');
			writeln;
			write('');
			readkey;
			halt;
		end;
	with curr do
		begin
			w := GetDeviceCaps(res,HORZRES);
			h := GetDeviceCaps(res,VERTRES);
			bits := GetDeviceCaps(res,BITSPIXEL);
			refresh := GetDeviceCaps(res,VREFRESH);
		end;
	writeln('The current resolution is ',curr.w,'x',curr.h,'x',curr.bits,' 
with a refresh rate of ',curr.refresh,' hz.');
	DeleteDC(res); // Clear it out
END.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.699 / Virus Database: 456 - Release Date: 04-Jun-04