Skip to content

Incorrect scaling of DefaultNodeHeight #1198

@pyscripter

Description

@pyscripter

#677 resurfaced. (master branch)

image

It is easy to reproduce:
Main Monitor: 300% scaling
Second Monitor: 100% scaling

Move the form from the main monitor to the secondary. Add a node. The node has wrong NodeHeight.

This happens with the following sequence:

  • Parent control is scaled and its font changed
  • The parent control broadcasts CM_PARENTFONTCHANGED
  • The font of the VT changes as a result (ParentFont is True)
  • CM_FONTCHANGED is performed by the VT
  • AutoSize is called before DefaultNodeHeight is scaled. It bumps up DefaultNodeHeight
  • Then DefaultNodeHeight is scaled again in ChangeScale and the damage is done.

The whole handling of ChangeScale and AutoSize is a bit of mess. For example:

  • ChangeScale starts by calling ScaleForPPI. At that point ScaleForPPI does nothing. Thankfully, because it would calll ChangeScale recursively!
  • Then some checking of the ScalingFlags is done which makes no sense. sfHeight is used internally to determine whether the control height needs to be scaled.
  • If IsDPIChange is False I think VT should just call the inherited method and do nothing else.

I will try to simplify things, test vigorously and submit a PR.

One suggestion I have is in relation to toAutoChangeScale. Currently it does two things:

  • Determines whether AutoSize "optimizes" node height
  • Determines whether DPI scaling is performed.

I think it makes absolutely no sense to disable DPI scaling in a DPI aware application. Everything would look wrong. I think that toAutoChangeScale should just control the optimization of the NodeHeight. What do you think?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions