Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Oct : How to get Dispatch() to work?

www.cryer.info
Managed Newsgroup Archive

How to get Dispatch() to work?

Subject:How to get Dispatch() to work?
Posted by:"John Schmidt" (j.schmi..@npkelektro.com)
Date:Tue, 24 Oct 2006 16:19:05

Hello,

I have following, which doesn't want to work. The receiver never receives
the message. Why (code below)???

Thanks & regards,
John

// ---- The message ----
const
  WM_NUMUPDATE = WM_USER + 9989;

// ---- The receiver ----
type
  TMyEdit = class(TEdit)
  private
    procedure WMNumUpdate(var Msg: TMessage); message WM_NUMUPDATE;
  end;

procedure TMyEdit.WMNumUpdate(var Msg: TMessage);
var
  Control: TWinControl;
begin
  Control := TWinControl(Msg.LParam);   // Breakpointed here --> never
accessed!
  if Assigned(Control) and (Control is TMyUpDown) then
  begin
    Text := IntToStr(TMyUpDown(Control).Position);
    Msg.Result := 0;
  end;
end;

// ---- The sender ----
type
  TMyUpDown = class(TUpDown)
  protected
    procedure Click(Button: TUDBtnType); override;
  end;

procedure TMyUpDown.Click(Button: TUDBtnType);
var
  Msg: TMessage;
begin
  inherited;
  Msg.Msg := WM_NUMUPDATE;
  Msg.WParam := 0;
  Msg.LParam := Longint(Self);
  Dispatch(Msg);   // Check here --> Msg is OK
end;

Replies:

www.cryer.info
Managed Newsgroup Archive