Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4543048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:28:36+00:00 2026-05-21T15:28:36+00:00

I just recently begun using TFrames heavily (OK, yes, I’ve been living under a

  • 0

I just recently begun using TFrames heavily (OK, yes, I’ve been living under a rock…). I thought frames supported Message hander method declaration–and I’ve seen many examples of that. So why does this simple test unit for a TFrame never see the message it posts to itself? (I created the test when I figured out that message handlers weren’t being called in my larger application.)

unit JunkFrame;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

const
  DO_FORM_INITS = WM_USER + 99;

type
  TFrame1 = class(TFrame)
    Panel1: TPanel;
  private
    procedure DoFormInits(var Msg: TMessage); message DO_FORM_INITS;
  public
    constructor Create(AOwner: TComponent); override;
  end;

implementation

{$R *.dfm}

constructor TFrame1.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  PostMessage(self.Handle, DO_FORM_INITS, 0, 0);
end;

procedure TFrame1.DoFormInits(var Msg: TMessage);
begin
  ShowMessage('In DoFormInits!');
end;

end.

This frame only contains a TPanel, and the frame is used on a simple mainform which contains only the frame and a Close button.

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:28:36+00:00Added an answer on May 21, 2026 at 3:28 pm

    I see two possibilities:

    1. Your program hasn’t started processing messages yet. Posted messages are only processed when your program calls GetMessage or PeekMessage and then DispatchMessage. That occurs inside Application.Run, so if your program hasn’t gotten there yet, then it won’t process any posted messages.

    2. Your frame’s window handle has been destroyed and re-created. Accessing the Handle property forces the frame’s window handle to be created, but if the frame’s parent hasn’t quite stabilized yet, then it might destroy its own window handle and re-create it. That forces all its children to do the same, so the handle you posted the message to doesn’t exist by the time your program starts processing messages.

    To fix the first problem, just wait. Your program will start processing messages eventually. To fix the second problem, override your frame’s CreateWnd method and post the message there. That method gets called after the window handle has been created, so you avoid forcing the handle to be created prematurely. It’s still possible for the handle to be destroyed and re-created, though, and CreateWnd will be called each time that happens, so you’ll need to be careful since your initialization message might be posted more than once (but never to the same window handle multiple times). Whether that’s correct depends on what kind of initialzation you need to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently began using dTrace and have noticed just how awesome it is. Its
I've recently started using git, and also begun unit testing (using Python's unittest module).
I just recently began using synthesized instance variables in my iPhone projects. The problem
I just recently started learning and using the ADO.NET Entity Framework and ran into
I just recently got my first mac. I do lots of programming on windows
I just recently installed the MVC beta. However, I assumed because the versioning numbers
I just recently noticed Dictionary.TryGetValue(TKey key, out TValue value) and was curious as to
I just recently installed Winamp Song Requester wich is a Winamp web song requester
I just recently changed out all my hard drives and in the process of
I only just recently discovered that Visual C++ 2008 (and perhaps earlier versions as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.