[python-win32] Question on parsing Reparse Points

2009-03-19 Thread Philip Bloom
Hello, 

This is my first post the python win32 programming list, so hello.

I'm trying to figure out a way to tell where a Reparse Point
() is really pointing programmatically.  I can determine
pretty easily a folder is a Junction
(win32api.GetFileAttributes(folder)==1040), but from there, I can't seem
to find a way to tell where that reparse point is reparsing into.  I've
seen C++ code that does it, but it depends on FindFirstFile, which I
don't see in win32api or win32file for python.  

Any ideas?  


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
_
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] GDI+ text rendering screwed up

2009-03-19 Thread Greg Ewing

I'm trying to use GDI+ (via ctypes) to draw text.
It works for some fonts but messes up with others.
Using Times, for example, it seems to be using the
glyphs for one character earlier in the code sequence,
so that "Times" comes out as "Shldr" -- except that it
uses the widths of the original characters for positioning.

Can someone please run the attached code and tell me
whether it works for them or not? And any ideas on what
I could be doing wrong to cause this?

--
Greg
import os, traceback
from ctypes import *
from ctypes.wintypes import *
gdiplus = windll.gdiplus

SW_HIDE = 0
SW_SHOW = 5
GWL_WNDPROC = -4
GWL_STYLE = -16

CS_VREDRAW = 0x0001
CS_HREDRAW = 0x0002
CS_GLOBALCLASS = 0x4000

WS_OVERLAPPEDWINDOW = 13565952
WS_VISIBLE = 0x1000
WS_SYSMENU = 0x0008

WM_QUIT = 0x0012
WM_PAINT = 0x000f
WM_CLOSE = 0x0010

LF_FACESIZE = 32

WNDPROC = WINFUNCTYPE(c_long, c_int, c_uint, c_int, c_int)

class WNDCLASS(Structure):
_fields_ = [
('style', c_uint),
('lpfnWndProc', WNDPROC),
('cbClsExtra', c_int),
('cbWndExtra', c_int),
('hInstance', c_int),
('hIcon', c_int),
('hCursor', c_int),
('hbrBackground', c_int),
('lpszMenuName', c_char_p),
('lpszClassName', c_char_p),
]

class PAINTSTRUCT(Structure):
_fields_ = [
('hdc', c_int),
('fErase', c_int),
('rcPaint', RECT),
('fRestore', c_int),
('fIncUpdate', c_int),
('rgbReserved', c_char * 32),
]

lo_byte = lambda x : x & 0xff
hi_byte = lambda x : x >> 8 & 0xff
lo_word = lambda x : x & 0x
hi_word = lambda x : x >> 16 & 0x

class RectF(Structure):
_fields_ = [
('x', c_float),
('y', c_float),
('w', c_float),
('h',c_float),
]

class LOGFONT(Structure):
_fields_ = [
('lfHeight', c_long),
('lfWidth', c_long),
('lfEscapement', c_long),
('lfOrientation', c_long),
('lfWeight', c_long),
('lfItalic', c_byte),
('lfUnderline', c_byte),
('lfStrikeOut', c_byte),
('lfCharSet', c_byte),
('lfOutPrecision', c_byte),
('lfClipPrecision', c_byte),
('lfQuality', c_byte),
('lfPitchAndFamily', c_byte),
('lfFaceName', c_char * LF_FACESIZE),
]

def __init__(self):
self.lfHeight, self.lfWidth = 10, 10
self.lfEscapement = 10
self.lfOrientation = 0
self.lfUnderline = 0
self.lfStrikeOut = 0
self.lfCharSet = 0 # ANSI_CHARSET
self.lfPitchAndFamily = 0
self.lfOutPrecision = 0
self.lfClipPrecision = 0
self.lfQuality = 0
self.lfPitchAndFamily = 2

class GdiplusStartupInput(Structure):
_fields_ = [
('GdiplusVersion', c_uint),
('DebugEventCallback', c_void_p),
('SuppressBackgroundThread', BOOL),
('SuppressExternalCodecs', BOOL),
]

def __init__(self):
Structure.__init__(self)
self.GdiplusVersion = 1
self.DebugEventCallback = None
self.SuppressBackgroundThread = 0
self.SuppressExternalCodecs = 0

StartupInput = GdiplusStartupInput()
token = c_ulong()
gdiplus.GdiplusStartup(pointer(token), pointer(StartupInput), None)

class Font(object):

def __init__(self, family, size = 12, style = []):
logfont = LOGFONT()
logfont.lfFaceName = family
logfont.lfHeight = -size
logfont.lfWidth = 0
if 'italic' in style:
logfont.lfItalic = 1
else:
logfont.lfItalic = 0
if 'bold' in style:
logfont.lfWeight = 10
else:
logfont.lfWeight = 0
self._size = size
self._win32_object = 
windll.gdi32.CreateFontIndirectA(byref(logfont))
self._free_object = True
self._family = family # should came elsewhere

class Canvas(object):

def __init__(self, hdc):
self._hdc = hdc
self._GpGraphics = c_void_p()
gdiplus.GdipCreateFromHDC(hdc, byref(self._GpGraphics))
self._GpFont = c_void_p()
self._GpBrush = c_void_p()
gdiplus.GdipCreateSolidFill(0xff00, byref(self._GpBrush))
print "Canvas: brush =", self._GpBrush.value ###
self._GpPen = c_void_p()

Re: [python-win32] GDI+ text rendering screwed up

2009-03-19 Thread Tim Roberts
Greg Ewing wrote:
> I'm trying to use GDI+ (via ctypes) to draw text.
> It works for some fonts but messes up with others.
> Using Times, for example, it seems to be using the
> glyphs for one character earlier in the code sequence,
> so that "Times" comes out as "Shldr" -- except that it
> uses the widths of the original characters for positioning.
>
> Can someone please run the attached code and tell me
> whether it works for them or not? And any ideas on what
> I could be doing wrong to cause this?

Sadly, I see "Times Italic 48" in black-on-yellow.

Do you really have a font called "Times"?  The TrueType font is actually
called "Times New Roman".  There is a "substitution" list for common
font names, but I'm not sure I'd want to rely on it.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] GDI+ text rendering screwed up

2009-03-19 Thread Greg Ewing

Tim Roberts wrote:


Sadly, I see "Times Italic 48" in black-on-yellow.

Do you really have a font called "Times"?


I'm not sure, but I can use the name "Times" with
plain GDI and it works fine, so it seems to be able
to find something equivalent.

But I'll try using the exact name and see if it
works any better.

Thanks,
Greg
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] GDI+ text rendering screwed up

2009-03-19 Thread Greg Ewing

Turns out I *sort* of have a font called Times... I've got
"Times Bold", "Times Italic" and "Times Bold Italic", but
no plain "Times"!

"Times New Roman" works fine, though, and it seems that the
same is true of all the other fonts for which there is a
full set of variations.

So it looks like I'll be building in my own translation
table.

Thanks for the help,
Greg
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32