This problem is still not solved. About a week ago I asked if there was any way to get access to the default font at the Windows API level so that I could do something like call GetTextExtents() to determine the exact MBR in pixels of a text string for precision placement on a mapper. I got one response from Brad Mathews <[EMAIL PROTECTED]> who used VB's Printer.TextWidth property for doing this on a layout (he responded publicly, so if you're interested, the date of that message is Jan 3, 2000.) He mentioned that his technique wasn't as precise as he wanted, but it worked on a layout. However, I still need a solution for a mapper window's font, and I want to be able to do it in MapBasic. Last year I did figure out a way to precision-place text on a layout with MapBasic using no API calls; the example with source code is at http://www.directionsmag.com/tools/default.asp?a=file&id=203, but mapper windows are trickier. Other than Brad, no one else responded. I even asked MapInfo tech support and no one there knew how to do this either. Since this one appears to have stumped everyone, or frightened them into silence, I must conclude that it can't be done and only fools will try. So don't even bother, as it is OBVIOUSLY IMPOSSIBLE. It can't be done. No one on this planet is smart enough to figure it out. The problem's superior intractableness is no match for our puny intelligence. We are not worthy. - Bill Thoen My original question > I'm trying to get access to font parameters in MapInfo from > Windows API calls (so someday I will be able to determine exact > text string sizes in pixels for exact map text placement), but > I'm seem to have encountered a basic flaw in my assumptions. I > thought that if you could get a mapper's Device Context, then > MapInfo's currently set font would be loaded in that DC. Perhaps > not, as the following short MB scrapplication suggests. > > My question is, "How can I use API functions like > GetTextExtent(), GetTextMetrics(), etc. for the font currently > set with MapBasic's Set Style statement?" Or is there another > way? > > The following code shows that the default font associated with a > mapper's DC has nothing to do with the font associated with the > Set Style statement. I set "Times New Roman", but the DC is still > using "System." Or did I overlook something? How do I get access > to a particular font setting? Do I need to call CreateFont() and > all its associated baggage like LOGFONT structures and related > font functions? > > If anyone knows, I'd appreciate enlightment here. I'll summarize > in a few days. > > - Bill Thoen > > '----- > define Long Integer > Declare Function GetDC Lib "user32" > Alias "GetDC" ( > ByVal hwnd As Long) > As Long > Declare Function GetTextFace Lib "gdi32" > Alias "GetTextFaceA" ( > ByVal hdc As Long, > ByVal nCount As Long, > lpFacename As String) > As Long > Declare Sub ReleaseDC Lib "user32" > Alias "ReleaseDC" ( > ByVal hwnd As Long, > ByVal hdc As Long) > > include "mapbasic.def" > declare sub main > > sub main > dim hWnd, hDC as integer > dim nResult as integer > dim sTextFace as string > > print chr$(12) > close all interactive > > 'Get a mapper open > open table "World" interactive > map from World > > 'Change the default font? > set style font > makefont ("Times New Roman", 0, 12, BLACK, -1) > > 'Get a Windows handle to the mapper > hWnd = WindowInfo (FrontWindow(), WIN_INFO_WND) > > 'Get that window's Device Context > hDC = GetDC (hWnd) > > 'Get the DC's current text face setting > nResult = GetTextFace (hDC, 30, sTextFace) > > if nResult > 0 then > 'Why is it not "Times New Roman?" > print " Text face is " + sTextFace > end if > > 'Clean up > call ReleaseDC (hWnd, hDC) > > end sub ---------------------------------------------------------------------- To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put "unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
