[python-win32] Image capture

Jens B. Jorgensen jens.jorgensen at tallan.com
Wed Jan 5 16:36:05 CET 2005


A little RTFM would go a long way here. The win32 extensions tend to 
translate the win32 api fairly directly into python. The SendMessage 
function can be found in the win32api module. Most constants are found 
in the win32con module. So, your python code should look something like:

import win32api, win32con

# assign grid_hwnd and picture_hdc somehow

win32api.SendMessage(grid_hwnd, win32con.WM_PAINT, picture_hdc, 0)
win32api.SendMessage(grid_hwnd, win32con.WM_PRINT, picture_hdc, 
win32con.PRF_CHILDREN | win32con.PRF_CLIENT | win32con.PRF_OWNED)

That takes care of the SendMessage bits. However, your picture is 
clearly some kind of object (and not one I can seem to find from a 
casual perusal of the msdn) so I can't account for that in Python.

Catalin Lungu wrote:

> Hi,
>  
> Can anybody help me to implement the following VB code in Python. 
> Thanks in advance.
>  
> Private Declare Function SendMessage Lib "user32.dll" Alias _
>    "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
>    ByVal wParam As Long, ByVal lParam As Long) As Long
>
> Private Const WM_PAINT = &HF
> Private Const WM_PRINT = &H317
> Private Const PRF_CLIENT = &H4&
> Private Const PRF_CHILDREN = &H10&
> Private Const PRF_OWNED = &H20&
>
> Private Sub Command1_Click()
>    SendMessage grid.hwnd, WM_PAINT, picture.hDC, 0
>    SendMessage grid.hwnd, WM_PRINT, picture.hDC, PRF_CHILDREN Or 
> PRF_CLIENT
> Or PRF_OWNED
>    picture.Picture = picture.Image
>    picture.Refresh
> End Sub
>  
> Catalin
> lcatalin at siadv.com <mailto:lcatalin at siadv.com>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32 at python.org
>http://mail.python.org/mailman/listinfo/python-win32
>  
>


-- 
Jens B. Jorgensen
jens.jorgensen at tallan.com

"With a focused commitment to our clients and our people, we deliver value through customized technology solutions"  



More information about the Python-win32 mailing list