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 980763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:26:11+00:00 2026-05-16T04:26:11+00:00

Background: I am using OmniThreadLibrary to load batch mode ADO stored procedures in the

  • 0

Background: I am using OmniThreadLibrary to load batch mode ADO stored procedures in the background. I am doing some slightly dodgy stuff by swapping the connection after opening the SP but that seems to be quite reliable. I’m using PostMessage to send messages back to the calling form and that works in my test applications. Primoz’ comms channels work for me, I’m using those for inter-thread comms but for our main application I’m trying to avoid that dependency by using standard PostMessage calls as we do elsewhere in the app.

Problem: Unfortunately when I put this into our main application the PostMessage calls in the thread start failing with 1400:invalid window handle.

I have liberally added extra PostMessage calls and logging code to try to locate the problem, but I’m out of ideas now. The code is boilerplate:

const WM_PW_ADLQUEUEEMPTY = WM_USER + 11;
...
if PostMessage (OwnerHandle, WM_PW_ADLPROGRESS, QueueID, 10) then
    pwDebugLog ('TADLQueue.Run WM_PW_ADLPROGRESS send to  ' + IntToHex (OwnerHandle, 8) + ' (IsWindow '+BoolToStr(IsWindow(OwnerHandle),true)+')     OK for Queue ' + IntToStr (QueueID))
else
    pwDebugLog ('TADLQueue.Run WM_PW_ADLPROGRESS send to  ' + IntToHex (OwnerHandle, 8) + ' (IsWindow '+BoolToStr(IsWindow(OwnerHandle),true)+') failed for Queue ' + IntToStr (QueueID));

But the log for a series of calls is not very revealing to me. note that the four hex digits after the time is the thread id from GetCurrentThreadID.

15:41:53.221 1614  TpwAsyncDataLoader.RunQueue WM_PW_ADLPROGRESS send to  00A5110C (IsWindow True)    OK for Queue -6
15:41:53.265 13B4  TADLQueue.Run WM_PW_ADLPROGRESS send to  00A5110C (IsWindow True)     OK for Queue -6
15:41:53.554 13B4  TADLQueueManager.WriteSysErrorMessageToDatabase Postmessage   00A5110C (IsWindow False)  failed with 1400  Invalid window handle

Can anyone shed some light on this? I’m confused at how a window handle can become invalid while I’m looking at it, but that’s what it looks like to me.

The one thing I can think of is that the form I’m showing here isn’t processing messages and I’m seeing a “message queue full” failure rather than the IsWindow(handle) failure that it looks like. How can I test for that?

  • 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-16T04:26:12+00:00Added an answer on May 16, 2026 at 4:26 am

    There are cases where a handle gets recreated, most notably when you change window flags. This might be what’s happening in your application.

    All I found so far about recreating windows handle is this post from Allen Bauer but I’m certain reading a more detailed one written by Peter Below. Unfortunatly I can’t seem to find that one.

    Finally, you need to be aware of cases
    where your handle may need to get
    recreated. This can happen if the
    surrounding form or the parent
    component’s handle goes through a
    recreate process. Up until more recent
    releases of Windows, the only way to
    change some window flags was to
    destroy the handle and recreate with
    new flags in the CreateWindowEx()
    call. There are many components that
    still do this. You know if you’re in a
    recreate situation by checking
    (csRecreating in ControlState).

    Edit

    Not actually the posts from Peter I had in mind but it might give you some fresh ideas.

    The form will not have a handle until
    you show it the first time (unless
    something in the form load sequence
    request the handle) but the handle is
    not destroyed when you hide the form
    and unless you do something that
    forces the form to recreate the
    handle, e.g. change its border style
    or border icons, or call RecreateWnd
    yourself the handle will stay the
    same.

    It may not be desirable but it cannot
    be avoided, at least not the way
    Delphi drag&dock is currently
    implemented. When you dock the dragged
    form to another form it becomes a
    control (with WS_CHILD window style)
    and that means that its window handle
    has to be destroyed and recreated with
    the new style. And destroying the
    window handle of a container control
    automatically destroys the handles for
    all child controls as well.

    and

    There is also the fact that the forms
    window handle is destroyed and
    recreated when you assign to its
    Parent property. This also destroys
    and recreates the handles for all
    controls on the form.

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

Sidebar

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.