Duane Clark wrote:

Hmmm, well I found this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrols.asp

where is says "By default, the edit control margins are set just wide enough to accommodate the largest character horizontal overhang (negative ABC widths) for the current font being used in the edit control."

I haven't quite figured out what that means, yet ;)

I made the attached changes to the edit test. The results when run on Win2k are a bit strange (note that I only looked for the min in the first 1024 glyphs):

edit.c:807:Font Verdana first char=32, last=64258
edit.c:817:MinA=-1, minC=-7
edit.c:824:Left=1, right=4

edit.c:807:Font Arial first char=32, last=65532
edit.c:817:MinA=-7, minC=-2
edit.c:824:Left=3, right=3

edit.c:807:Font Tahoma first char=32, last=65532
edit.c:817:MinA=-6, minC=-1
edit.c:824:Left=3, right=3

edit.c:807:Font Microsoft Sans Serif first char=32, last=65532
edit.c:817:MinA=0, minC=0
edit.c:824:Left=0, right=0

Index: dlls/user/tests/edit.c
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/edit.c,v
retrieving revision 1.17
diff -u -p -r1.17 edit.c
--- dlls/user/tests/edit.c	22 Mar 2006 21:09:50 -0000	1.17
+++ dlls/user/tests/edit.c	13 Apr 2006 02:14:47 -0000
@@ -776,10 +776,14 @@ static void test_margins_font_change(voi
     LOGFONT lf;
     HFONT hfont, hfont2;
     HDC hdc = GetDC(0);
+    char the_font[]="Arial";
+    TEXTMETRICW tm;
+    HFONT old_font;
+    ABC *lpabc;
 
-    if(EnumFontFamiliesA(hdc, "Arial", find_font_proc, 0))
+    if(EnumFontFamiliesA(hdc, the_font, find_font_proc, 0))
     {
-        trace("Arial not found - skipping font change margin tests\n");
+        trace("%s not found - skipping font change margin tests\n", the_font);
         ReleaseDC(0, hdc);
         return;
     }
@@ -790,15 +794,34 @@ static void test_margins_font_change(voi
     SetWindowPos(hwEdit, NULL, 10, 10, 1000, 100, SWP_NOZORDER | SWP_NOACTIVATE);
 
     memset(&lf, 0, sizeof(lf));
-    strcpy(lf.lfFaceName, "Arial");
+    strcpy(lf.lfFaceName, the_font);
     lf.lfHeight = 16;
     lf.lfCharSet = DEFAULT_CHARSET;
     hfont = CreateFontIndirectA(&lf);
     lf.lfHeight = 30;
     hfont2 = CreateFontIndirectA(&lf);
+    
+    hdc = GetDC(hwEdit);
+    old_font = SelectObject(hdc, hfont);
+    GetTextMetricsW(hdc, &tm);
+    trace("Font %s first char=%d, last=%d\n", the_font, tm.tmFirstChar, tm.tmLastChar);
+    lpabc = HeapAlloc(GetProcessHeap(), 0, sizeof(ABC)*65536);
+    if (GetCharABCWidthsW(hdc, tm.tmFirstChar, 1023, lpabc)) {
+        int i, minA=20, minC=20;
+        for (i=tm.tmFirstChar; i<=tm.tmLastChar; i++) {
+            if (lpabc[i].abcA < minA)
+                minA = lpabc[i].abcA;
+            if (lpabc[i].abcC < minC)
+                minC = lpabc[i].abcC;
+        }
+        trace("MinA=%d, minC=%d\n", minA, minC);
+    }
+    SelectObject(hdc, old_font);
+    ReleaseDC(hwEdit, hdc);
 
     SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
     font_margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
+    trace("Left=%d, right=%d\n", LOWORD(font_margins), HIWORD(font_margins));
     ok(LOWORD(font_margins) != 0, "got %d\n", LOWORD(font_margins));
     ok(HIWORD(font_margins) != 0, "got %d\n", HIWORD(font_margins));
 


Reply via email to