-1

I've noticed that after some Windows update, my application made in Delphi 7 does not focus correctly anymore. The title bar does not change color. UI elements like buttons, scrollbars, etc do not react. I also can't minimize or close the Form with the titlebar buttons.

What is weird is that I can still move the Form around by dragging the titlebar, and the program is working fine in general.

Here is an animation showing what is happening:

animation

Here is the list of Windows versions I've tested on:

Windows 7 SP1 + updates -> OK!
Windows 8.1 without updates -> OK!
Windows 8.1 with all updates -> NO FOCUS! 
Windows 10 BUILD 10240 -> OK!
Windows 10 BUILD 10586 -> OK!
Windows 10 BUILD 14393 -> NO FOCUS!

I tried disabling Window Ghosting with this code:

var 
  User32: HMODULE; 
  DisableProcessWindowsGhosting: TProcedure; 
begin 
  User32 := GetModuleHandle('USER32'); 
  if User32 <> 0 then 
  begin 
    DisableProcessWindowsGhosting := GetProcAddress(User32,  'DisableProcessWindowsGhosting'); 
    if Assigned(DisableProcessWindowsGhosting) then 
      DisableProcessWindowsGhosting; 
  end; 
end;

Also, I removed all Application.ProcessMessages() calls, but still no change.

Community
  • 1
  • 1
Atak_Snajpera
  • 619
  • 9
  • 24
  • What is that code about. Looks like your program is broken and your solution was to put the head deep in the sand. – David Heffernan Dec 08 '16 at 19:37
  • 1
    All threads access UI elements only via synchronization. I know very well that accessing UI directly from threads is just a receipt for disaster. Microsoft has to change something with some update that this problem occurs. It has been working well for years and now BAM! – Atak_Snajpera Dec 08 '16 at 19:53
  • 1
    Why do you need to disable ghosting. What atrocity are you committing. – David Heffernan Dec 08 '16 at 20:43
  • Because I found this topic http://stackoverflow.com/questions/743713/newly-created-modal-window-loses-focus-and-become-inacessible-in-windows-vista and I was just curious if solutions for that case would help here. – Atak_Snajpera Dec 08 '16 at 20:51
  • I notice this glitch very often in normal usage of the OS, with every kind of applications. I activate back the previously active application with the mouse and then click again to the application which failed to come to front, both clicks to client area, to sort it out. – Sertac Akyuz Dec 08 '16 at 21:13
  • Sertac Akyuz what windows version do you use? – Atak_Snajpera Dec 08 '16 at 21:17
  • @Atak - I didn't pay attention to OS versions, but I'm sure it happens both on servers and user desktops. – Sertac Akyuz Dec 08 '16 at 21:22
  • 1
    Probably you have a defect in your code – David Heffernan Dec 08 '16 at 21:50
  • This is not the ghosting feature at play. You can clearly see the Form is still actively processing paint requests, which means the message queue is still running. If the window were being ghosted, you would see "Not Responding" in the titlebar, the window would likely become greyed, there would be no more paint updates displayed, and you would be able to minimize and close the window. – Remy Lebeau Dec 08 '16 at 23:29
  • Perhaps your "Accent color" has been reset to white in the Windows 10 Settings? – Nat Dec 09 '16 at 00:53

1 Answers1

0

It turned out that this odd behavior was caused by code in TForm1.Activate. Looks like that putting too much complex code in that section wasn't a good idea. I've moved whole code to TForm1.JvTimer1Timer and now problem is gone.

Atak_Snajpera
  • 619
  • 9
  • 24