[lazarus] Developing win32
Vincent Snijders
vslist at zonnet.nl
Fri Nov 29 15:40:47 EST 2002
Hi,
Lately I have been lookint at the win32 interface, trying to make it work a
bit better.
I have never done any low level win32 api programming, so I am a bit in the
dark. Still I want to share with you two things which trouble me a lot.
Maybe some of you can help me a bit further.
Firstly it is not clear what messages the LCL is expecting from an interface
object and what messages the an interface object is suposed to handle. The
only way is to look at the gtk interface and put some (a lot) writelns to
see what it does. An example is the the LM_DESTROY message from the
interface to the LCL. When you run lazarus (with gtk on linux) it only seems
to be sent for TPage object and not for TForm. If you happen to do so on
win32 you get into problems for freeing the form twice (once on the
LM_DESTROY message and once when Application.Free is called). I think it
would be great if there were a document which specified what messages the
LCL expects and sends.
Secondly I have problems writing a good windowproc.
For example I have this window procedure to handle windows messages (see
below). It only works if I comment out the assert, I don't understand why.
If I don't comment out the assert in, I get an access violation when I
create a window which uses this windowproc. Do I use the right calling
convention (stdcall)? Are there some RTL-functions I may not use in a
windowproc? Or is there somewhere else some memory corruption which shows up
here. I just don't know enough of the win32 api. Very frustating.
function WindowProc(Window: HWnd; Msg: UInt; WParam: WParam; LParam:
LParam): LResult; stdcall;
var
LMessage: TLMessage;
LCLObject: TObject;
CallDefWindowProc: boolean;
begin
Assert(False,
Format('Trace:WindowProc - Window Value: $%S-%d; Msg Value: %S; WParam:
$%S; LParam: $%S',
[IntToHex(Window, 4), Window, WM_To_String(Msg), IntToHex(WParam, 4),
IntToHex(LParam, 4)]));
CallDefWindowProc := true;
case Msg of
WM_CLOSE:
Begin
Assert(False, 'Trace:WindowProc - Got WM_CLOSE');
LMessage.Msg := LM_CLOSEQUERY;
LCLObject := TObject(GetProp(Window, 'Lazarus'));
Result := DeliverMessage(LCLObject,LMessage);
CallDefWindowProc := false;
End;
end;
if CallDefWindowProc
then Result := DefWindowProc(Window, Msg, WParam, LParam);
end;
Hope somebody can give me some pointers in the right direction.
Vincent Snijders.
More information about the Lazarus
mailing list