ppescher / resizablelib

A set of MFC classes to easily make resizable windows
Other
55 stars 27 forks source link

Fix a bug, and clear a debug assert #12

Closed irwir closed 5 years ago

irwir commented 5 years ago
  1. Fix a dangerous bug in CResizableLayout::AddAllOtherAnchors ::GetClassName(hWnd, szClassName, _countof(szClassName)) The third parameter is a character count, not a byte count. In Unicode builds sizeof would give twice the length of the name buffer; and access violations might be expected; especially with a small buffer. Not necessarily, but to make the code suitable for prehistoric VS versions, _countof(x) might be replaced with sizeof(x)/sizeof(x[0]).

  2. Clear a rare debug assert in CResizableFormView::GetTotalClientRect A trivial sequence "remove anchor - set window placement - add anchor" was fine in the first pass, but fired a debug asserts afterwards. The problem was in an attempted access to a non-existent scrollbar. An early check and return fixed this. GetDeviceScrollSizes treats all non-positive mapping modes as invalid, and the condition nMapMode < 0 was changed accordingly.

ppescher commented 5 years ago

Thanks @irwir I'm no longer accustomed to writing good Unicode-compatible Windows code. That probably comes from programming small microcontrollers, where wchar_t is a luxury you never have to deal with.