Posted on 2006-06-06
I want to use the PathCompactPath API to make a long file name fit into a fixed label width. The API guide I have lists three parameters: the string with the path name, the maximum width in pixels, and "hDC: Handle to the device context used for font metrics." The first two are obvious; the third one has me baffled, and checking a number of online references to the API hasn't helped. Some of them have VB code that uses "Me.hDC" as this parameter passed, but it I try that I get an error of "hdc is not a member of frmMain." And really I wouldn't expect to refer to something at the form level; I would think what I really want to pass is a Font. But the parameter is supposed to be a Long, so a Font won't work. I see a GetHDC method for Graphics objects, which sounds like it might be usable as part of this, but I don't see how to associate a font with that without actually drawing something on the form, which I'm not interested in doing.