mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2014
Posts: 328
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 328
Hi Khaled,

When we have an edit box, it can be enabled/disabled via code, e.g.:
Code
alias test { dialog -m test test }

dialog test {
  title ""
  option pixels
  size -1 -1 250 99
  check "Enable", 1, 12 15 50 16
  edit "", 2, 10 32 230 21, disable autohs
  button "&OK", 3, 164 66 76 23, ok default
}
on *:dialog:test:*:*:{
  if ($devent == sclick) && ($did == 1) { did $iif($did($did).state,-e,-b) $dname 2 }
}

I found something that I'm not sure if it's a bug. When the edit box is enabled and we have the cursor inside that window, if we disable the edit box, the style of the edit box changes.

I also discovered that whether we leave the edit box empty or not, the style also changes. Sometimes it's random, the style sometimes doesn't change, sometimes it does.

[Linked Image from i.ibb.co]
[Linked Image from i.ibb.co]
[Linked Image from i.ibb.co]

The same happens with the mIRC edit boxes:

When dialog is opened::

[Linked Image from i.ibb.co]

Dialog box with edit boxes enabled:

[Linked Image from i.ibb.co]

Dialog box with edit boxes disabled:

[Linked Image from i.ibb.co]

Dialog that appears when the cursor is active in the last edit box:

[Linked Image from i.ibb.co]

Dialog box displayed when we disable the edit boxes:

[Linked Image from i.ibb.co]

Sometimes it's random. It changes the style in some edit boxes and not in others:

[Linked Image from i.ibb.co]

I'm using beta version 7.83.3857, but I checked the released version 7.83 and some previous versions, and this problem occurs in all versions.


TECO
irc.PTirc.org (Co-Admin)
Joined: Dec 2002
Posts: 3,907
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 3,907
Thanks for your bug report. I have not been able to reproduce this here so far. I tested your script, and the Options dialog Nickname section, on several different Windows installations. mIRC is using the EnableWindow() API, which is a basic API used to enable/disable controls. The way the control is re-drawn in this case is handled by Windows. This API is used in many places in mIRC, and has been for decades, and I have never heard of an issue with it before. I cannot think of a reason why this would happen, apart from perhaps a Windows graphics driver issue.

Joined: Jul 2014
Posts: 328
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 328
Unfortunately, it's not a driver issue, because I've already tested it on 2 different PCs with different hardware, and the same thing happens. I detected this problem more than 3 years ago, but I never reported it because I hoped that one day you would notice the problem.

To reproduce the problem correctly, you need to enable the edit box, place the mouse cursor in the edit box, and then disable the edit box.

Sometimes it can happen randomly, but most of the time it does.


TECO
irc.PTirc.org (Co-Admin)
Joined: Dec 2002
Posts: 3,907
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 3,907
Interesting issue. I was able to reproduce this by clicking in the editbox first. As far as I can tell, it's a Windows 10/11 bug.

In Windows 10/11, when you click in an editbox, Windows highlights the border of the editbox (and in the case of Windows 11, it displays a blue underline in the editbox as well). When the editbox loses focus, such as when EnableWindow() disables the control, there is a small delay before Windows removes the highlight/underline. The highlight/underline theming feature in Windows 10/11 seems to work independently from the APIs and repaints the editbox a short time after the window is loses focus.

When an application uses EnableWindow(), even if it resets focus to another control first or forces a control redraw/repaint, this makes no difference. Even redrawing the entire dialog makes no difference. The control is still updated incorrectly N milliseconds later by Windows. An application would have to set up a timer for every call to EnableWindow() to redraw the control after N milliseconds, which is whatever delay that Windows uses before adding/removing the highlight/underline when focus is gained/lost.

This issue needs a Windows fix.

Joined: Sep 2003
Posts: 46
O
Ook Offline
Ameglian cow
Offline
Ameglian cow
O
Joined: Sep 2003
Posts: 46
This display issue is also present in my Windows 7 Ultimate x64 install but to a much lesser extent as it only affects the edit box if it has focus (is showing the caret) when its disabled, the system seems to be drawing the control in a `disabled with focus state` which is odd.

A possible fix is simply removing focus before disabling control.

(Microslop appears to have made things worse in 10/11)

Joined: Jul 2006
Posts: 4,062
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,062
I can reproduce this issue on win10 mIRC 7.82


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2002
Posts: 3,907
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 3,907
Quote
A possible fix is simply removing focus before disabling control.
I already tried this, along with re-drawing the entire dialog, the control, changing focus, etc. It makes no difference because Windows removes the highlight/underline after a delay.

An application would need to create a timer to handle the N millisecond delay that Windows uses when applying theming once focus is gained/lost, independently from any API calls. The only solution is to wait, let's say, 500 milliseconds after EnableWindow() is called, hope that Windows has already removed the highlight/underline, and possibly caused the display artifact/glitch, and then force a redraw of the control just in case.

Which is not a practical solution :-) In other words, this needs to be fixed by Microsoft. It is, quite literally, a drawing glitch in their editbox theming.

Joined: Jul 2014
Posts: 328
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 328
The only way I found that works and solves the problem is this:
Code
alias test { dialog -m test test }

dialog test {
  title ""
  option pixels
  size -1 -1 250 99
  check "Enable", 1, 12 15 50 16
  edit "", 2, 10 32 230 21, disable autohs
  button "&OK", 4, 164 66 76 23, ok default
}
on *:dialog:test:*:*:{
  if ($devent == sclick) {
    if ($did == 1) {
      if ($did($did).state) { .timeroff off | did -ve $dname 2 }
      else { did -h $dname 2 | .timeroff -h 1 190 did -bv $dname 2 }
    }
  }
}

However, this is not a perfect solution and may fail in some circumstances.

Last edited by TECO; 28/04/26 10:03 AM.

TECO
irc.PTirc.org (Co-Admin)

Link Copied to Clipboard