Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2005 Apr : Windows confused?

www.cryer.info
Managed Newsgroup Archive

Windows confused?

Subject:Windows confused?
Posted by:"///Matt" (spammers_die_slow@my_hand.com)
Date:Mon, 11 Apr 2005 01:35:52

I have a recurring situation where the line
form.setfocus;
causes an AV in NTDLL.  The form is visible, and were it not, I would
expect the usual "cannot focus a hidden or disabled window" exception.
Instead I get:

Access violation at address 7C918FEA in module "ntdll.dll".  Write
address 00000010

'form' is a Tform (pointer), which is set correctly since the code
just before the .SetFocus call performs actions like
form.enabled:=true; which work correctly.  The full code snippet is:

          if assigned(parentform) then
             begin
             if not parentform.Visible then
                debug_show('Form is not visible!');  //Temporary code
to debug NTDLL
             parentform.Enabled:=yes;                //Appears to work
             parentform.SetFocus;                    //This line blows
up NTDLL
             end;

The debug note doesn't show, and debugging confirms that the form is
visible when the .SetFocus call is made.  This is 100% reproducible.
I also can't seem to trap it with Try-Except; I get the OS exception
instead of my code handling it.  We're accustomed to working around
Windows bugs, but since I can't seem to trap this one, it's a problem.

This is fully-patched D6 under fully-patched XPSP2.  Running the same
EXE under Win2000 results in a completely different symptom: Nothing
happens when that line is called, but when the ap closes (only if that
line was executed during the run), it generates the following:
The instruction at "0x0040402e" referenced memory at "0x05aad9e8".
The memory could not be "read".

Anyone seen this?  It looks like Windows is getting confused, or has
lost a handle or something.

Thanks for any ideas,
-///Matt

Replies:

www.cryer.info
Managed Newsgroup Archive