Ah, no guys I do not mean MessageBox, I mean Windows messages (WM_...etc) :)
Regards
Main Topics
Browse All TopicsHi All,
I've been trying to understand Windows messaging from MSDN and Delphi help file but unfortunately I can't seem to get the idea.
So can someone please briefly explain to me in human language Windows messaging (+) provide me with a small example on how I can make the simplest internal messaging system inside my application that will send an internal message in my application once an event is fired.
Thanks in advance for your help
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you want to use plain windows API to create an app, here's the beginning - creating simple empty form ;)
program project;
uses
windows, messages;
var
wcls : wndClass;
form : cardinal;
msg : tagMsg;
function WndProc (wnd, msg : cardinal; wParam, lParam : integer) : integer; stdcall;
begin
case msg of
wm_close : PostQuitMessage(0);
end;
result := DefWindowProc(wnd, msg, wParam, lParam);
end;
begin
with wcls do begin
style := cs_parentdc;
lpfnWndProc := @WndProc;
cbClsExtra := 0;
cbWndExtra := 0;
hInstance := sysInit.hInstance;
hIcon := LoadIcon(0, idi_application);
hCursor := LoadCursor(0, idc_arrow);
hbrBackground := color_btnface + 1;
lpszMenuName := nil;
lpszClassName := 'empty form';
end;
RegisterClass(wcls);
form := CreateWindowEx(
ws_ex_topmost or ws_ex_toolwindow or ws_ex_appwindow,
wcls.lpszClassName, 'tutorial nr. 001 - empty form',
ws_visible or ws_caption or ws_sizebox or ws_sysmenu,
150, 100, 400, 300,
0, 0, hInstance, nil
);
while GetMessage(msg, 0, 0, 0) do begin
DispatchMessage(msg);
end;
DestroyWindow(form);
UnregisterClass(wcls.lpszC
end.
P.S.(1) If you want to learn WinAPI, I advise you to download Platform SDK from www.microsoft.com - it's free software. You'll need only "help" from it (it's about 200MB).
P.S.(2) You may contact me in Skype (nick: delphists) if you need some help with WinAPI from me.
unit Unit1;
interface
uses
Windows, Messages, Classes, Forms, Dialogs, Controls, SysUtils, StdCtrls;
// added manually
const
CustomMessage_RegEndSearch
type
TForm1 = class(TForm)
Button1: TButton;
// added manually
procedure ProcessMyMsg (var msg : TMessage); message CustomMessage_RegEndSearch
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// added manually
procedure TForm1.ProcessMyMsg(var msg : TMessage);
begin
// do something
ShowMessage('received CustomMessage_RegEndSearch
ShowMessage(IntToStr(msg.w
ShowMessage(pchar(msg.lPar
// set result
msg.result := 1232;
end;
procedure TForm1.Button1Click(Sender
var
res : integer;
begin
// send the message to form, get the result
res := SendMessage({Form1.}Handle
ShowMessageFmt('result of message is %d', [res]);
end;
end.
ZhaawZ,
Thanks a lot for your help and time. :) Now I have a couple of questions on your source code so that I can better understand Windows messages:
** In const
CustomMessage_RegEndSearch
- Why +100? I mean what do 100 refer to?
- What are the other types of Windows messages (other than wm_user)?
Thanks in advance for your time
ZhaawZ,
No need to reply for my last questions, I've found the answer in
http://www.cryer.co.uk/bri
Thank you for your help and time
Regards
You may get info about messages in MSDN (msdn.microsoft.com or downloadable Platform SDK help).
Other messages (not wm_user) are sent when some action occurs - window creating / moving / sizing, typing something in EDIT control, pressing mouse button, releasing it, changing display modes etc - all these (and also other) actions cause receiving different messages (not only WM_*, but also BM_* for buttons, LVM_* for list views, EM_* for edits etc). Some messages are used to let the control do something, for examle, LB_SETCURSEL sets selection in list box.
I think the best way to understand this messaging system is to start making apps by using WinAPI (not Delphi stuff like TForm, TButton, TEdit etc).
Business Accounts
Answer for Membership
by: nodramasPosted on 2006-04-23 at 07:28:24ID: 16519217
var result:integer;
...
Result := MessageBox(Handle, 'hello world!', 'Regards!', 64);
...