Skip to content

Make Task List dpi aware#2172

Closed
A-R-C-A wants to merge 1 commit intonotepad-plus-plus:masterfrom
A-R-C-A:dpiTaskList
Closed

Make Task List dpi aware#2172
A-R-C-A wants to merge 1 commit intonotepad-plus-plus:masterfrom
A-R-C-A:dpiTaskList

Conversation

@A-R-C-A
Copy link
Contributor

@A-R-C-A A-R-C-A commented Aug 15, 2016

  • Font and dimension adjustments
  • Icons centered properly

winVer ver = (NppParameters::getInstance())->getWinVersion();
_rc.bottom += (ver <= WV_XP && ver != WV_UNKNOWN)?xpBottomMarge:w7BottomMarge;
// ::GetSystemMetrics(SM_CYFRAME) returns 1px more than actually is ?
_rc.bottom += (::GetSystemMetrics(SM_CYFRAME) - true) * 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why decrease with 'true' instead of '1'?

@A-R-C-A
Copy link
Contributor Author

A-R-C-A commented Aug 15, 2016

it's the same

@MAPJe71
Copy link
Contributor

MAPJe71 commented Aug 15, 2016

Low level yes but...

  • does not make it very readable.
  • implicit type conversion(s)

@A-R-C-A
Copy link
Contributor Author

A-R-C-A commented Aug 15, 2016

OK, I'll change this tomorrow.
Do you know why this wired return value?

@MAPJe71
Copy link
Contributor

MAPJe71 commented Aug 15, 2016

Why the weird return value?
According to this help the function is supposed to return a value of type int for SM_CYFRAME (or maybe better SM_CYSIZEFRAME) representing the thickness of the sizing border around the perimeter of a window that can be resized, in pixels.
So my question is: is it a resizable frame i.e. is the correct metric retrieved?

In addition to 'true' vs '1':
When the return value represents Boolean data a nonzero value is considered true and a zero value is considered false. Most of the Windows functions that return Boolean data return a value of type BOOL (TRUE or FALSE) which is different from the C++ native type bool (true or false).

int reply = ::GetSystemMetrics( SM_DBCSENABLED);
if (reply != 0) // using 'if (reply)' would add an implicit type conversion (int --> bool)
    // User32.dll w/ DBCS support
else
    // User32.dll w/o DBCS support

Could be written as...

BOOL reply = ::GetSystemMetrics( SM_DBCSENABLED);
if (reply == TRUE) // using 'if (reply)' would add an implicit type conversion (int --> bool)
    // User32.dll w/ DBCS support
else
    // User32.dll w/o DBCS support

or as...

bool isEnabled = (TRUE == ::GetSystemMetrics( SM_DBCSENABLED));
if (isEnabled)
    // User32.dll w/ DBCS support
else
    // User32.dll w/o DBCS support

@A-R-C-A
Copy link
Contributor Author

A-R-C-A commented Aug 15, 2016

is it a resizable frame i.e. is the correct metric retrieved?

This is the correct metric for the WS_THICKFRAME Style. The return value is correct for other windows with this style. For the Task List dialog I get this values:

100% - return: 8  - is: 7
150% - return: 11 - is: 10
200% - return: 13 - is: 12

The Task List border is 1px smaller, so I assume it is safe to simply decrement the return value.

In addition to 'true' vs '1': ...

I don't see the point here. I'm aware of this all. There is no 'bad' with the code above. It is absolutely safe to replace 1 with true.

@MAPJe71
Copy link
Contributor

MAPJe71 commented Aug 16, 2016

The return value is correct for other windows ...

I have no idea, yet. Makes it a bigger challenge finding out though ;)
Maybe the returned values are correct. Does the TaskList look wrong without the correction? Probably yes, otherwise you wouldn't have applied the correction.
I would check for it myself but I'm currently not able to compile the application and see the differences.

... I assume it is safe to simply decrement the return value.

Assumptions are always BAD, at some point in time they will bite you in the a...
These should always be well documented (as you did)!

In addition to 'true' vs '1': ...

I was not sure you were aware, just discard it.
Although, IMO it's 'bad' when it raises confusion/questions, degrades readability despite raising neither errors nor warnings by compiler :)

_rc.top = 0;
_rc.bottom = 0;
_rc = { 0, 0, 0, 0 };
TCHAR * buf = new TCHAR[MAX_PATH];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the advantage to allocate a string dynamically, whereas we can have an automatic variable here?

Copy link
Contributor

@milipili milipili Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because potentially allocating 32k on the stack is probably not a good idea. MS tries to fix their crap in their API and the real limit of a path is 32k. So this value may change in the future and there is no good reason to use a static buffer for a path.
(but this has nothing to do with this commit, so it should be a separate commit)

@donho donho added the accepted label Aug 17, 2016
@donho donho added this to the 6.x milestone Aug 17, 2016
@donho donho self-assigned this Aug 17, 2016
@donho donho closed this in 438926b Aug 17, 2016
@A-R-C-A
Copy link
Contributor Author

A-R-C-A commented Aug 17, 2016

Heap vs. stack, leads to a better performance. But in this case there is probably no difference.

@A-R-C-A A-R-C-A deleted the dpiTaskList branch August 30, 2016 00:11
SinghRajenM pushed a commit to SinghRajenM/notepad-plus-plus that referenced this pull request Nov 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants