add skeleton for variant type support
[pywinlite.git] / resource.py
blobb3c2d81e5e05a6fb5090c651db9386ae9ed46412
1 #Copyright (c) 2008 Vincent Povirk
3 #Permission is hereby granted, free of charge, to any person
4 #obtaining a copy of this software and associated documentation
5 #files (the "Software"), to deal in the Software without
6 #restriction, including without limitation the rights to use,
7 #copy, modify, merge, publish, distribute, sublicense, and/or sell
8 #copies of the Software, and to permit persons to whom the
9 #Software is furnished to do so, subject to the following
10 #conditions:
12 #The above copyright notice and this permission notice shall be
13 #included in all copies or substantial portions of the Software.
15 #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 #OTHER DEALINGS IN THE SOFTWARE.
24 # Resource definitions
25 # see http://msdn.microsoft.com/en-us/library/ms632583(VS.85).aspx
27 from ctypes import c_void_p, cast, windll
28 from winlitecfg import get_aw_symbols
29 from winliteutils import NONZERO
30 from windef import LPCTSTR, BOOL, HANDLE, UINT, INT, WINFUNCTYPE, WORD, LONG_PTR, DWORD, LPTSTR, HGLOBAL, HMODULE, HINSTANCE, HRSRC
31 _kernel32 = windll.kernel32
32 _user32 = windll.user32
34 # TODO: define Enum* functions and resource-updating functions
36 def MAKEINTRESOURCE(i):
37 return cast(c_void_p(i&0xFFFF), LPCTSTR)
39 def IS_INTRESOURCE(i):
40 try:
41 return i.value|0xFFFF == 0xFFFF
42 except AttributeError:
43 return i|0xFFFF == 0xFFFF
45 IMAGE_BITMAP = 0
46 IMAGE_ICON = 1
47 IMAGE_CURSOR = 2
48 IMAGE_ENHMETAFILE = 3
50 LR_DEFAULTCOLOR = 0x0000
51 LR_MONOCHROME = 0x0001
52 LR_COLOR = 0x0002
53 LR_COPYRETURNORG = 0x0004
54 LR_COPYDELETEORG = 0x0008
55 LR_LOADFROMFILE = 0x0010
56 LR_LOADTRANSPARENT = 0x0020
57 LR_DEFAULTSIZE = 0x0040
58 LR_VGA_COLOR = 0x0080
59 LR_LOADMAP3DCOLORS = 0x1000
60 LR_CREATEDIBSECTION = 0x2000
61 LR_COPYFROMRESOURCE = 0x4000
62 LR_SHARED = 0x8000
64 RT_CURSOR = MAKEINTRESOURCE(1)
65 RT_BITMAP = MAKEINTRESOURCE(2)
66 RT_ICON = MAKEINTRESOURCE(3)
67 RT_MENU = MAKEINTRESOURCE(4)
68 RT_DIALOG = MAKEINTRESOURCE(5)
69 RT_STRING = MAKEINTRESOURCE(6)
70 RT_FONTDIR = MAKEINTRESOURCE(7)
71 RT_FONT = MAKEINTRESOURCE(8)
72 RT_ACCELERATOR = MAKEINTRESOURCE(9)
73 RT_RCDATA = MAKEINTRESOURCE(10)
74 RT_MESSAGETABLE = MAKEINTRESOURCE(11)
75 RT_GROUP_CURSOR = MAKEINTRESOURCE(12)
76 RT_GROUP_ICON = MAKEINTRESOURCE(14)
77 RT_VERSION = MAKEINTRESOURCE(16)
78 RT_DLGINCLUDE = MAKEINTRESOURCE(17)
79 RT_PLUGPLAY = MAKEINTRESOURCE(19)
80 RT_VXD = MAKEINTRESOURCE(20)
81 RT_ANICURSOR = MAKEINTRESOURCE(21)
82 RT_ANIICON = MAKEINTRESOURCE(22)
83 RT_HTML = MAKEINTRESOURCE(23)
84 RT_MANIFEST = MAKEINTRESOURCE(24)
86 get_aw_symbols(globals(), _kernel32, ['FindResource', 'FindResourceEx'])
87 get_aw_symbols(globals(), _user32, ['LoadImage'])
89 _user32.CopyImage.argtypes = [HANDLE, UINT, INT, INT, UINT]
90 _user32.CopyImage.restype = NONZERO
91 CopyImage = _user32.CopyImage
93 FindResource.argtypes = [HMODULE, LPCTSTR, LPCTSTR]
94 FindResource.restype = NONZERO
96 FindResourceEx.argtypes = [HMODULE, LPCTSTR, LPCTSTR, WORD]
97 FindResourceEx.restype = NONZERO
99 _kernel32.FreeResource.argtypes = [HGLOBAL]
100 _kernel32.FreeResource.restype = BOOL
101 FreeResource = _kernel32.FreeResource
103 LoadImage.argtypes = [HINSTANCE, LPCTSTR, UINT, INT, INT, UINT]
104 LoadImage.restype = NONZERO
106 _kernel32.LoadResource.argtypes = [HMODULE, HRSRC]
107 _kernel32.LoadResource.restype = NONZERO
108 LoadResource = _kernel32.LoadResource
110 _kernel32.LockResource.argtypes = [HGLOBAL]
111 _kernel32.LockResource.restype = NONZERO
112 LockResource = _kernel32.LockResource
114 _kernel32.SizeofResource.argtypes = [HMODULE, HRSRC]
115 _kernel32.SizeofResource.restype = NONZERO
116 SizeofResource = _kernel32.SizeofResource