Recreating Dialog Boxes... Major Problem...

Recreating Dialog Boxes... Major Problem...

Post by lloydsarg.. » Wed, 09 Aug 2000 04:00:00



Hi guys,

I've been mucking around in the guts of the Dialog box resources trying
to replicate, for fun, dialog boxes like Windows does. The creepy thing
is that even with all the documentation of how it is supposed to do it,
it doesn't come out the same.

For example, I have a window that in the dialog box resource says is
112 x 186. So, I create the window using x = 0, y = 0, cx = 112 *
(chrWidth / 4.0), cy = 186 * (chrHeight / 8.0).  Well, it is close but
no CEE-gar. (I am comparing it with a dialog box that pops up at the
same time).

So what is the deal? Is there some "special math" going on? Does anyone
know?

Thanks,

L

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by John A. Gran » Wed, 09 Aug 2000 04:00:00



Quote:> Hi guys,

> I've been mucking around in the guts of the Dialog box resources trying
> to replicate, for fun, dialog boxes like Windows does. The creepy thing
> is that even with all the documentation of how it is supposed to do it,
> it doesn't come out the same.

> For example, I have a window that in the dialog box resource says is
> 112 x 186. So, I create the window using x = 0, y = 0, cx = 112 *
> (chrWidth / 4.0), cy = 186 * (chrHeight / 8.0).  Well, it is close but
> no CEE-gar. (I am comparing it with a dialog box that pops up at the
> same time).

> So what is the deal? Is there some "special math" going on? Does anyone
> know?

    What are "chrWidth" & "chrHeight". Did you look them up
    using GetDialogBaseUnits()?

    I think there may be additional scaling for the font specified
    (or not) for the dialog box. If your dialog box resource doesn't
    have a FONT statement, then it should be correct, if you
    use GetDialogBaseUnits(). Otherwise, there may be a
    factor that depends on the relative widths of SYSTEM_FONT
    and the specified FONT.

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by lloydsarg.. » Thu, 10 Aug 2000 04:00:00






> > Hi guys,

> > I've been mucking around in the guts of the Dialog box resources
trying
> > to replicate, for fun, dialog boxes like Windows does. The creepy
thing
> > is that even with all the documentation of how it is supposed to do
it,
> > it doesn't come out the same.

> > For example, I have a window that in the dialog box resource says is
> > 112 x 186. So, I create the window using x = 0, y = 0, cx = 112 *
> > (chrWidth / 4.0), cy = 186 * (chrHeight / 8.0).  Well, it is close
but
> > no CEE-gar. (I am comparing it with a dialog box that pops up at the
> > same time).

> > So what is the deal? Is there some "special math" going on? Does
anyone
> > know?
>     What are "chrWidth" & "chrHeight". Did you look them up
>     using GetDialogBaseUnits()?

>     I think there may be additional scaling for the font specified
>     (or not) for the dialog box. If your dialog box resource doesn't
>     have a FONT statement, then it should be correct, if you
>     use GetDialogBaseUnits(). Otherwise, there may be a
>     factor that depends on the relative widths of SYSTEM_FONT
>     and the specified FONT.

No, I was using GetTextMetrics. See there ISN'T a dialog box, I am
merely using the resource data to create a window to LOOK like a dialog
box (why? because there isn't a WYSISYG editor for MDI windows). What I
am trying to figure out is HOW windows is creating the dialog
box "window" based on the font. The documentation is light in this area
and, from my messing abouts, doesn't seem to be correct.

Cheers,

L

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by John A. Gran » Thu, 10 Aug 2000 04:00:00







> > > Hi guys,

> > > I've been mucking around in the guts of the Dialog box resources
> trying
> > > to replicate, for fun, dialog boxes like Windows does. The creepy
> thing
> > > is that even with all the documentation of how it is supposed to do
> it,
> > > it doesn't come out the same.

> > > For example, I have a window that in the dialog box resource says is
> > > 112 x 186. So, I create the window using x = 0, y = 0, cx = 112 *
> > > (chrWidth / 4.0), cy = 186 * (chrHeight / 8.0).  Well, it is close
> but
> > > no CEE-gar. (I am comparing it with a dialog box that pops up at the
> > > same time).

> > > So what is the deal? Is there some "special math" going on? Does
> anyone
> > > know?
> >     What are "chrWidth" & "chrHeight". Did you look them up
> >     using GetDialogBaseUnits()?

> >     I think there may be additional scaling for the font specified
> >     (or not) for the dialog box. If your dialog box resource doesn't
> >     have a FONT statement, then it should be correct, if you
> >     use GetDialogBaseUnits(). Otherwise, there may be a
> >     factor that depends on the relative widths of SYSTEM_FONT
> >     and the specified FONT.

> No, I was using GetTextMetrics. See there ISN'T a dialog box, I am
> merely using the resource data to create a window to LOOK like a dialog
> box (why? because there isn't a WYSISYG editor for MDI windows). What I
> am trying to figure out is HOW windows is creating the dialog
> box "window" based on the font. The documentation is light in this area
> and, from my messing abouts, doesn't seem to be correct.

    There doesn't have to be any dialog box to use
    GetDialogBaseUnits() - it's a system "metric".
    Call that function and use the values it returns instead of
    the ones you're getting from GetTextMetric(). See if it
    makes a difference.

    Did you create the required HFONT? Did you remember
    to select your font into the HDC before GetTextMetric()?

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by lloydsarg.. » Fri, 11 Aug 2000 04:00:00










> > > > Hi guys,

> > > > I've been mucking around in the guts of the Dialog box resources
> > trying
> > > > to replicate, for fun, dialog boxes like Windows does. The
creepy
> > thing
> > > > is that even with all the documentation of how it is supposed
to do
> > it,
> > > > it doesn't come out the same.

> > > > For example, I have a window that in the dialog box resource
says is
> > > > 112 x 186. So, I create the window using x = 0, y = 0, cx = 112
*
> > > > (chrWidth / 4.0), cy = 186 * (chrHeight / 8.0).  Well, it is
close
> > but
> > > > no CEE-gar. (I am comparing it with a dialog box that pops up
at the
> > > > same time).

> > > > So what is the deal? Is there some "special math" going on? Does
> > anyone
> > > > know?
> > >     What are "chrWidth" & "chrHeight". Did you look them up
> > >     using GetDialogBaseUnits()?

> > >     I think there may be additional scaling for the font specified
> > >     (or not) for the dialog box. If your dialog box resource
doesn't
> > >     have a FONT statement, then it should be correct, if you
> > >     use GetDialogBaseUnits(). Otherwise, there may be a
> > >     factor that depends on the relative widths of SYSTEM_FONT
> > >     and the specified FONT.

> > No, I was using GetTextMetrics. See there ISN'T a dialog box, I am
> > merely using the resource data to create a window to LOOK like a
dialog
> > box (why? because there isn't a WYSISYG editor for MDI windows).
What I
> > am trying to figure out is HOW windows is creating the dialog
> > box "window" based on the font. The documentation is light in this
area
> > and, from my messing abouts, doesn't seem to be correct.

>     There doesn't have to be any dialog box to use
>     GetDialogBaseUnits() - it's a system "metric".
>     Call that function and use the values it returns instead of
>     the ones you're getting from GetTextMetric(). See if it
>     makes a difference.

>     Did you create the required HFONT? Did you remember
>     to select your font into the HDC before GetTextMetric()?

1) You're correct about GetDialogBaseUnits, however what it returns is
virtually useless as the dialog box that is created is based on the
font size. GetDialogBaseUnits seems to be 16 and 8 (y and x
respectively). Been there, done that, don't work.

2) I would have asked the same question, not knowing the skill level of
the person asking the question. Unfortunately, I have been writing
Windows code professionally since 3.x. So, it's not really a newbie
mistake.

So, of course, my next step was take the dependencies out and
manipulate the variables using the following formulas (the ones MS says
they use):

    windowWidth = dialogWidth * (chrWidth / 4.0);
    windowHeight = dialogHeight * (chrHeight / 8.0);

Now, using the values for the dialog box (my example is 112 for dialog
width, 186 for dialog Height) and mess around with the chrWidth and
chrHeight variables you CAN NOT get a window that is the same size as
the dialog box.

ERGO, Microsoft must be using something completely different than
documented. That is the information I am trying to gather.

L

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by John A. Gran » Fri, 11 Aug 2000 04:00:00



    [...incomprehensible multiply-quoted messages...]

Quote:> 1) You're correct about GetDialogBaseUnits, however what it returns is
> virtually useless as the dialog box that is created is based on the
> font size. GetDialogBaseUnits seems to be 16 and 8 (y and x
> respectively). Been there, done that, don't work.

    The values returned by GetDialogBaseUnits() should be based
    on your system font.  Try changing your video resolution and the
    "small/large fonts" settings and see if you get back different
    values.

    [...]

Quote:> So, of course, my next step was take the dependencies out and
> manipulate the variables using the following formulas (the ones MS says
> they use):

>     windowWidth = dialogWidth * (chrWidth / 4.0);
>     windowHeight = dialogHeight * (chrHeight / 8.0);

> Now, using the values for the dialog box (my example is 112 for dialog
> width, 186 for dialog Height) and mess around with the chrWidth and
> chrHeight variables you CAN NOT get a window that is the same size as
> the dialog box.

    [...]
    Are you calling AdjustWindowRect() to adjust those calculated
    values to include the frames & caption areas?

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by Sean Mitchel » Fri, 11 Aug 2000 04:00:00


I remember trying to do this years ago, and being very frustrated.  Windows
doesn't always use the DialogBaseUnits, sometimes it uses some weird
combination of the widths of the 52 US alpha characters in the currently
selected dialog font, and a different mechanism for the DBCS character set.
This was on the original Win95, but I don't imagine it has changed much
since then.

If you think you get it working try it out with Large Fonts, or DBCS and
you'll probably find it breaks.  But if you do get it working tell me how!

 sean





>     [...incomprehensible multiply-quoted messages...]

> > 1) You're correct about GetDialogBaseUnits, however what it returns is
> > virtually useless as the dialog box that is created is based on the
> > font size. GetDialogBaseUnits seems to be 16 and 8 (y and x
> > respectively). Been there, done that, don't work.
>     The values returned by GetDialogBaseUnits() should be based
>     on your system font.  Try changing your video resolution and the
>     "small/large fonts" settings and see if you get back different
>     values.

>     [...]
> > So, of course, my next step was take the dependencies out and
> > manipulate the variables using the following formulas (the ones MS says
> > they use):

> >     windowWidth = dialogWidth * (chrWidth / 4.0);
> >     windowHeight = dialogHeight * (chrHeight / 8.0);

> > Now, using the values for the dialog box (my example is 112 for dialog
> > width, 186 for dialog Height) and mess around with the chrWidth and
> > chrHeight variables you CAN NOT get a window that is the same size as
> > the dialog box.
>     [...]
>     Are you calling AdjustWindowRect() to adjust those calculated
>     values to include the frames & caption areas?

> --
> John A. Grant  * I speak only for myself *  (remove 'z' to reply)
> Radiation Geophysics, Geological Survey of Canada, Ottawa
> If you followup, please do NOT e-mail me a copy: I will read it here

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by Jeff Henkel » Fri, 11 Aug 2000 04:00:00


There's a trick for getting the dialog base units, using MapDialogRect().
Unfortunately, I haven't used it for several years, so I don't remember all
the details.


> I remember trying to do this years ago, and being very frustrated.
Windows
> doesn't always use the DialogBaseUnits, sometimes it uses some weird
> combination of the widths of the 52 US alpha characters in the currently
> selected dialog font, and a different mechanism for the DBCS character
set.
> This was on the original Win95, but I don't imagine it has changed much
> since then.

> If you think you get it working try it out with Large Fonts, or DBCS and
> you'll probably find it breaks.  But if you do get it working tell me how!

>  sean





> >     [...incomprehensible multiply-quoted messages...]

> > > 1) You're correct about GetDialogBaseUnits, however what it returns is
> > > virtually useless as the dialog box that is created is based on the
> > > font size. GetDialogBaseUnits seems to be 16 and 8 (y and x
> > > respectively). Been there, done that, don't work.
> >     The values returned by GetDialogBaseUnits() should be based
> >     on your system font.  Try changing your video resolution and the
> >     "small/large fonts" settings and see if you get back different
> >     values.

> >     [...]
> > > So, of course, my next step was take the dependencies out and
> > > manipulate the variables using the following formulas (the ones MS
says
> > > they use):

> > >     windowWidth = dialogWidth * (chrWidth / 4.0);
> > >     windowHeight = dialogHeight * (chrHeight / 8.0);

> > > Now, using the values for the dialog box (my example is 112 for dialog
> > > width, 186 for dialog Height) and mess around with the chrWidth and
> > > chrHeight variables you CAN NOT get a window that is the same size as
> > > the dialog box.
> >     [...]
> >     Are you calling AdjustWindowRect() to adjust those calculated
> >     values to include the frames & caption areas?

> > --
> > John A. Grant  * I speak only for myself *  (remove 'z' to reply)
> > Radiation Geophysics, Geological Survey of Canada, Ottawa
> > If you followup, please do NOT e-mail me a copy: I will read it here

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by lloydsarg.. » Sat, 12 Aug 2000 04:00:00






>     [...incomprehensible multiply-quoted messages...]

> > 1) You're correct about GetDialogBaseUnits, however what it returns
is
> > virtually useless as the dialog box that is created is based on the
> > font size. GetDialogBaseUnits seems to be 16 and 8 (y and x
> > respectively). Been there, done that, don't work.
>     The values returned by GetDialogBaseUnits() should be based
>     on your system font.  Try changing your video resolution and the
>     "small/large fonts" settings and see if you get back different
>     values.

Yes, but a dialog box is based on the font defined for that box. So if
my box is defined to have a font of 16 pts it will be very different
than one that used the system font. GetDialogBaseUnits() is a dead end.

Quote:>     [...]
> > So, of course, my next step was take the dependencies out and
> > manipulate the variables using the following formulas (the ones MS
says
> > they use):

> >     windowWidth = dialogWidth * (chrWidth / 4.0);
> >     windowHeight = dialogHeight * (chrHeight / 8.0);

> > Now, using the values for the dialog box (my example is 112 for
dialog
> > width, 186 for dialog Height) and mess around with the chrWidth and
> > chrHeight variables you CAN NOT get a window that is the same size
as
> > the dialog box.
>     [...]
>     Are you calling AdjustWindowRect() to adjust those calculated
>     values to include the frames & caption areas?

Even excluding the frame, we are talking about a significant size
difference. Yes, I had already though about the caption area, but that
is not it - if it were then the differences between the two windows
would be that of the caption area and the frame - which it is not.

L

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Recreating Dialog Boxes... Major Problem...

Post by John A. Gran » Sun, 13 Aug 2000 04:00:00







> >     [...incomprehensible multiply-quoted messages...]
> Yes, but a dialog box is based on the font defined for that box. So if
> my box is defined to have a font of 16 pts it will be very different
> than one that used the system font. GetDialogBaseUnits() is a dead end.

    [...]

    If the dialog box has a FONT statement, then Windows
    will create that HFONT and send it to each of the text
    controls with WM_SETFONT. Presumably it will also
    use it to get the average character size, probably using
    GetTextMetrics(), selecting the HFONT into the HDC.
    I assume you're doing all that.  So perhaps you can try
    using SYSTEM_FONT and GetDialogBaseUnits(). If
    that gives you what you expect, then perhaps it is your
    handling of the font stuff that is messing it up for you.
--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here

 
 
 

1. Dialog box resource edit box problem (Borland C++ 3.1)

Using Borland C++ v3.1's Resource workshop, I created a simple dialog box
with one multiline edit box in it.
When ever I set the text for this edit box, instead of the text moving to
the next line after a '\n' character is set, it puts a little box instead.
it only wraps to the next line when it has reached the maximum text it can
fit on one line.
How do I make it line feed each time it prints a '\n' ?

Here is the dialog box resource script in case I did something wrong
there:

RESULTSDLG DIALOG 6, 16, 222, 159
STYLE
WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_
MAXIMIZEBOX
CAPTION "Results of Search:"
FONT 8, "Arial"
BEGIN
 CONTROL "", 40,"EDIT",
ES_LEFT|ES_MULTILINE|ES_READONLY|WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL|
WS_TABSTOP, 3, 2, 217, 155
END

2. how to use thin

3. Dialog box from a Dialog Box

4. Win98/Road Runner

5. HELP! Dialog Boxes within Dialog Boxes!

6. Looking to hire someone to configure MySQL on Windows

7. Dialog Box from Dialog Box

8. Visioneer Paperport MX VX on Windows 2000

9. Dialog boxes from dialog boxes?

10. Dialog boxes from Dialog Boxes

11. Displaying a second DIALOG BOX from another DIALOG BOX????

12. Calling a modeless dialog box from a modal dialog box

13. Calling a 2nd Dialog box from within another Dialog Box