delphi - What can I do about maximized, styled windows, which show their borders on adjacent monitors? -
on multi-monitor system, "blank" vcl application maximizes fine, same application styles enabled (and 1 chosen default) maximizes incorrectly. i'm seeing right-hand edge of window extend onto 2nd monitor (my main on left). when started comparing other windows apps, noticed under windows 7 (at least), maximized windows not have non-client borders on left, right or bottom sides. , indeed, standard vcl (non-styled) app behaves same way, without non-client borders.
how fix this? notice tformstylehook has handler wmnccalcsize, haven't dissected yet, makes me wonder if vcl might incorrectly handling message maximized window.
after fiddling time on this, take is, not vcl-styles bug @ all. indeed related behavior in article mentioned in comment question mghie.
the specific behavior that, size of maximized window larger work area of monitor window maximized on. supposedly, window manager hides overhang borders. apparently, doesn't quite customized frames. note msdn's own custom window frame example seems suffer same problem (refer post titled "bug when window maximized " in community content). vcl's application different msdn example in it's not based on dwm, still think same issue.
the overhang borders have size of system sizing border (sm_c[x|y]sizeframe), irrelevant workaround below disregards os suggested size/position , uses work area.
unfortunately don't think workaround usable @ all. one, mentioned behavior not documented, two, workaround not perfect; there's still odd pixel out. if snap window on work area, window manager decides offset window thinks window (with hidden frames) should placed. (the vcl modified window manager does, , take account overhang , not draw them or similar, more work , still workaround undocumented behavior..)
anyway;
type tform1 = class(tform) .. protected // overriding styles not necessary since tformstylehook.wmgetminmaxinfo // first calls default window procedure procedure wmgetminmaxinfo(var message: twmgetminmaxinfo); message wm_getminmaxinfo; .. procedure tform1.wmgetminmaxinfo(var message: twmgetminmaxinfo); var r: trect; begin // arrives minmaxinfo.ptmaxposition = (-sm_cxframe, -sm_cyframe) // , minmaxinfo.ptmaxsize = (primarymonitor.width (?) + 2 * sm_cxframe, ... ) inherited; // should test os, styles etc. before running below r := monitor.workarearect; inflaterect(r, -1, -1); // odd pixel offsetrect(r, -monitor.left, -monitor.top); message.minmaxinfo.ptmaxposition := r.topleft; message.minmaxinfo.ptmaxsize := point(r.width, r.height); end;
Comments
Post a Comment