Discussion:
using WM_USER const and TMessage to press escape to minimize form.
Peter Williams
2010-12-27 11:09:13 UTC
Permalink
Hi All,

I am trying to port some Delphi 5 or 7 (cannot recall which) to Lazarus.

What do I change WM_USER to? I am getting Identifier not found.

Here is the code:

main.pas

const
WM_USER_APPLICATION_MINIMIZE = WM_USER+1;

// identifier not found WM_USER

type
[...]
private
{ Private declarations }
procedure OnUserAppMin(var M: TMessage);
message WM_USER_APPLICATION_MINIMIZE;

procedure TForm1.OnUserAppMin(var M: TMessage);
begin
Application.Minimize;
end; { OnUserAppMin }
{----------------------------------------------------------}

about.pas

procedure TForm2.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = VK_ESCAPE) then
begin
key := 0;
PostMessage(Form1.Handle, WM_USER_APPLICATION_MINIMIZE, 0, 0);

// error : Identifier not found WM_USER_APPLICATION_MINIMIZE

close;
end;
end; { FormKeyDown }
{----------------------------------------------------------}
Roberto Padovani
2010-12-27 13:10:30 UTC
Permalink
Post by Peter Williams
Hi All,
I am trying to port some Delphi 5 or 7 (cannot recall which) to Lazarus.
What do I change WM_USER to? I am getting Identifier not found.
main.pas
const
  WM_USER_APPLICATION_MINIMIZE = WM_USER+1;
// identifier not found WM_USER
Add the following use clause:

uses Windows;

R#

--
Benito van der Zander
2010-12-27 13:40:55 UTC
Permalink
Post by Peter Williams
What do I change WM_USER to? I am getting Identifier not found.
LM_USER from unit LMessages, if you want to become platform independent
(wm_user is also in that unit and defined as wm_user=lm_user).


--

Loading...