[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

vNoticeDialog centering bug report.



        Hi everybody.

There is a bug in vNoticeDialog (at least under V1.20/Win98/CygwinB20).

The notices are not well centered in the window upon creation. It is
espessialy visible when the size of the notice is almost as big as the size
of the window.

I think that the problem comes from using different coordinate systems. I'll
try to explain it in more details. Here is a piece of code (which should
normally center the notice) from "srcwin/vnotice.cpp" file.

void vNoticeDialog::DialogDisplayed()
  {
    // center the dialog in the app window
    RECT rctApp, rctDlg;			// app and dialog corners
    ::GetWindowRect(theApp->winHwnd(), &rctApp);
    ::GetWindowRect(_wDialog, &rctDlg);
    int widApp, htApp, widDlg, htDlg;		// app and dialog dimensions
    widApp = rctApp.right - rctApp.left;
    htApp = rctApp.bottom - rctApp.top;
    widDlg = rctDlg.right - rctDlg.left;
    htDlg = rctDlg.bottom - rctDlg.top;
    int left, top;				// new dialog upper-left corner
    if ( widApp > widDlg )
      left = (widApp - widDlg)/2; // don't add to left - SetDialogPosition does
    else
      left = rctApp.left;
    if ( htApp > htDlg )
      top = (htApp - htDlg)/2;
    else
      top = rctApp.top;
    SetDialogPosition (left , top);	      // set the position, in V coords
  }
I think that the problem here is the following: what we get in "widApp" and
"htApp"is the size of the "full" application window (i.e. the window
including the status bar, titrle bar, etc.); but when the
"SetDialogPosition" is called it sets dialog position with respect to "not
full" (i.e. without status bar, command bar, etc.) window's upper-left
corner, and NOT the "full" window's upper-left corner. So here the problem
is !!! Unfortunately I don't know how to correct that, i.e. I don't know if
(and how !!) we can get the size of the "not full" application window.
Furthermore, ther is one MORE problem here: the case when the Notice is
bigger than the window. For this case we have
>    else
>        left = rctApp.left;
and
>    else
>        top = rctApp.top;
As to my mind, it makes NO any sense, since left and top are used with
respect to the application's window, while rctApp.left and rctApp.top are
measured with respect to the upper-left corner of the screen!!!   I think it
should rather be:
>        left = 0;
and
>        top = 0;
or mayby it is better to put someting like 10 and 10 to make it more "nice".

Serguei.
___________________________________________________________________________
Serguei DACHIAN
Laboratoire de Statistique et Processus,
Universite du Maine, Av. Olivier Messiaen
72085 Le Mans CEDEX 9, FRANCE
Tel.   : +33 (0)2 43 83 37 18
Fax.   : +33 (0)2 43 83 35 79
E-mail : Serguei.Dachian@univ-lemans.fr
WWW    : http://www.univ-lemans.fr/sciences/statist/cvs/thesard.html#dachian


Reply to: