activex¤
Load ActiveX controls in an application window.
The following classes are available to interact with ActiveX controls
and the following enumerations
- Colour
- ExtendedWindowStyle
- MenuFlag
- MessageBoxOption
- ShowWindow
- WindowClassStyle
- WindowPosition
- WindowStyle
Application
¤
Application(
*,
background=Colour.WHITE,
class_style=WindowClassStyle.NONE,
icon=None,
title="ActiveX",
window_style=WindowStyle.OVERLAPPEDWINDOW,
)
Create the main application window to display ActiveX controls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
background
|
Colour
|
The background colour of the main window. |
WHITE
|
class_style
|
WindowClassStyle
|
The class style(s). Can be any combination (bitwise OR) of WindowClassStyle values. |
NONE
|
icon
|
Icon | None
|
The application icon. |
None
|
title
|
str
|
The text to display in the titlebar (if one is visible). |
'ActiveX'
|
window_style
|
WindowStyle
|
The window style(s). Can be any combination (bitwise OR) of WindowStyle values. |
OVERLAPPEDWINDOW
|
Source code in src/msl/loadlib/activex.py
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | |
thread_id
property
¤
thread_id
int — The identifier of the thread that created the main application window.
add_message_handler
¤
add_message_handler(handler)
Add a custom handler for processing window messages.
Messages correspond to events from the user and from the operating system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
Callable[[int, int, int, int], None]
|
A function that processes messages sent to the main window.
The function must accept four positional arguments (all integer values)
and the returned object is ignored. See
WindowProc
for more details about the input arguments to the |
required |
Source code in src/msl/loadlib/activex.py
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 | |
close
¤
close()
Close the application.
Source code in src/msl/loadlib/activex.py
1065 1066 1067 | |
handle_events
¤
handle_events(source, sink=None, *, interface=None)
Handle ActiveX events (see GetEvents).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Any
|
An ActiveX object that emits events. |
required |
sink
|
Any
|
The object that handles the events. The |
None
|
interface
|
Any
|
The COM interface to use. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
An |
Source code in src/msl/loadlib/activex.py
1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | |
load
¤
load(
activex_id,
*,
parent=None,
x=0,
y=0,
width=0,
height=0,
style=WindowStyle.VISIBLE | WindowStyle.CHILD,
ex_style=ExtendedWindowStyle.LEFT,
)
Load an ActiveX library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
activex_id
|
str
|
ProgID or CLSID of the ActiveX object. |
required |
parent
|
int | None
|
The handle to the parent window that the ActiveX object will belong to. Default is the main application window. |
None
|
x
|
int
|
Horizontal position of the ActiveX object in the parent window. |
0
|
y
|
int
|
Vertical position of the ActiveX object in the parent window. |
0
|
width
|
int
|
Width (in pixels) of the ActiveX object. |
0
|
height
|
int
|
Height (in pixels) of the ActiveX object. |
0
|
style
|
WindowStyle
|
Style of the window that is created to contain the ActiveX object. Can be any combination (bitwise OR) of WindowStyle values. |
VISIBLE | CHILD
|
ex_style
|
ExtendedWindowStyle
|
Extended style of the window that is created to contain the ActiveX object. Can be any combination (bitwise OR) of ExtendedWindowStyle values. |
LEFT
|
Returns:
| Type | Description |
|---|---|
Any
|
The interface pointer to the ActiveX library. |
Source code in src/msl/loadlib/activex.py
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 | |
message_box
staticmethod
¤
message_box(
*,
hwnd=None,
language_id=0,
options=MessageBoxOption.OK,
text="",
title="",
)
Display a modal dialog box (see MessageBoxExW).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hwnd
|
int | None
|
A handle to the owner window of the message box to be created. |
None
|
language_id
|
int
|
The language for the text displayed in the message box button(s). |
0
|
options
|
MessageBoxOption
|
The contents and behaviour of the dialog box. Can be any combination (bitwise OR) of MessageBoxOption values. |
OK
|
text
|
str
|
The message to be displayed. |
''
|
title
|
str
|
The dialog box title. |
''
|
Returns:
| Type | Description |
|---|---|
int
|
An indication of how the message box was closed. |
Source code in src/msl/loadlib/activex.py
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 | |
run
staticmethod
¤
run()
Run the application.
This is a blocking call. Create and run the application in a separate thread if you want to execute other code while the application is running.
Source code in src/msl/loadlib/activex.py
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 | |
set_window_position
¤
set_window_position(
x, y, width, height, *, flags=WindowPosition.NONE
)
Set the position of the main window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
The new position of the left side of the window. |
required |
y
|
int
|
The new position of the top of the window. |
required |
width
|
int
|
The new width (in pixels) of the window. |
required |
height
|
int
|
The new height (in pixels) of the window. |
required |
flags
|
WindowPosition
|
The window sizing and positioning flags. Can be any combination (bitwise OR) of WindowPosition values. |
NONE
|
Source code in src/msl/loadlib/activex.py
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 | |
set_window_size
¤
set_window_size(width, height)
Set the size of the main window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The new width (in pixels) of the window. |
required |
height
|
int
|
The new height (in pixels) of the window. |
required |
Source code in src/msl/loadlib/activex.py
1224 1225 1226 1227 1228 1229 1230 1231 1232 | |
set_window_title
¤
set_window_title(title)
Set the text to display in the window's title bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title bar text. |
required |
Source code in src/msl/loadlib/activex.py
1234 1235 1236 1237 1238 1239 1240 | |
show
¤
show(command=ShowWindow.NORMAL)
Show the main application window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
ShowWindow
|
Controls how the window is shown. |
NORMAL
|
Source code in src/msl/loadlib/activex.py
1242 1243 1244 1245 1246 1247 1248 1249 1250 | |
unhandle_events
¤
unhandle_events(*advise_connection)
Stop handling ActiveX events.
Added in version 1.1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
advise_connection
|
Any
|
The event connection(s) to stop listening to. The object is one that is returned by handle_events. If no arguments are specified, stops handling all ActiveX events. It is also necessary to delete (del) the connection variable(s) in the calling program (and maybe invoke the Python garbage collector) if events are still firing. |
()
|
Source code in src/msl/loadlib/activex.py
1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 | |
wait_for_events
¤
wait_for_events(timeout)
Wait for ActiveX events to occur (see PumpEvents).
Added in version 1.1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
The number of seconds to wait for events to occur. |
required |
Source code in src/msl/loadlib/activex.py
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 | |
Colour
¤
ExtendedWindowStyle
¤
Bases: IntFlag
Extended window style flags.
Attributes:
| Name | Type | Description |
|---|---|---|
DLGMODALFRAME |
int
|
0x00000001 |
NOPARENTNOTIFY |
int
|
0x00000004 |
TOPMOST |
int
|
0x00000008 |
ACCEPTFILES |
int
|
0x00000010 |
TRANSPARENT |
int
|
0x00000020 |
MDICHILD |
int
|
0x00000040 |
TOOLWINDOW |
int
|
0x00000080 |
WINDOWEDGE |
int
|
0x00000100 |
CLIENTEDGE |
int
|
0x00000200 |
CONTEXTHELP |
int
|
0x00000400 |
RIGHT |
int
|
0x00001000 |
LEFT |
int
|
0x00000000 |
RTLREADING |
int
|
0x00002000 |
LTRREADING |
int
|
0x00000000 |
LEFTSCROLLBAR |
int
|
0x00004000 |
RIGHTSCROLLBAR |
int
|
0x00000000 |
CONTROLPARENT |
int
|
0x00010000 |
STATICEDGE |
int
|
0x00020000 |
APPWINDOW |
int
|
0x00040000 |
LAYERED |
int
|
0x00080000 |
NOINHERITLAYOUT |
int
|
0x00100000 |
NOREDIRECTIONBITMAP |
int
|
0x00200000 |
LAYOUTRTL |
int
|
0x00400000 |
COMPOSITED |
int
|
0x02000000 |
NOACTIVATE |
int
|
0x08000000 |
OVERLAPPEDWINDOW |
int
|
WINDOWEDGE | CLIENTEDGE |
PALETTEWINDOW |
int
|
WINDOWEDGE | TOOLWINDOW | TOPMOST |
Icon
¤
Icon(file, *, index=0, hinstance=None)
Extract an icon from an executable file, DLL or icon file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
PathLike
|
The path to an executable file, DLL or icon file. |
required |
index
|
int
|
The zero-based index of the icon to extract. |
0
|
hinstance
|
int | None
|
Handle to the instance of the calling application. |
None
|
Source code in src/msl/loadlib/activex.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
hicon
property
¤
hicon
int | None — The handle to the icon or None if an icon was not found in the file.
destroy
¤
destroy()
Destroys the icon and frees any memory the icon occupied.
Source code in src/msl/loadlib/activex.py
648 649 650 651 652 | |
Menu
¤
Menu()
A menu associated with the main application window.
Warning
Do not instantiate directly. Use the Application.menu property to access the menu instance.
Source code in src/msl/loadlib/activex.py
856 857 858 859 860 861 862 863 864 | |
append
¤
append(
hmenu,
text,
*,
callback=None,
data=None,
flags=MenuFlag.STRING,
)
Create a new MenuItem and append it to a popup menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hmenu
|
int
|
The handle of a popup menu to append the new menu item to. |
required |
text
|
str
|
The content of the new menu item. |
required |
callback
|
Callable[[MenuItem], None] | None
|
A callable object that will be called when this menu item is selected. The callable object will receive the MenuItem instance as an argument and the returned object is ignored. |
None
|
data
|
Any
|
User data associated with the menu item. |
None
|
flags
|
MenuFlag
|
Controls the appearance and behaviour of the new menu item. Can be any combination (bitwise OR) of MenuFlag values. |
STRING
|
Returns:
| Type | Description |
|---|---|
MenuItem
|
The menu item that was appended. |
Source code in src/msl/loadlib/activex.py
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | |
append_group
¤
append_group(hmenu, menu_group)
Append a group of menu items to a popup menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hmenu
|
int
|
The handle of a popup menu to append the group to. |
required |
menu_group
|
MenuGroup
|
A group of menu items. |
required |
Source code in src/msl/loadlib/activex.py
892 893 894 895 896 897 898 899 900 901 902 903 904 905 | |
append_separator
¤
append_separator(hmenu)
Append a horizontal dividing line to a popup menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hmenu
|
int
|
The handle to a popup menu. |
required |
Source code in src/msl/loadlib/activex.py
907 908 909 910 911 912 913 | |
create
¤
create(text)
Create a new popup menu and append it to the main menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to display for the popup menu. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The handle to the popup menu that was created. |
Source code in src/msl/loadlib/activex.py
915 916 917 918 919 920 921 922 923 924 925 926 927 | |
MenuFlag
¤
Bases: IntFlag
Menu item flags.
Attributes:
| Name | Type | Description |
|---|---|---|
BITMAP |
int
|
0x00000004 |
CHECKED |
int
|
0x00000008 |
DISABLED |
int
|
0x00000002 |
ENABLED |
int
|
0x00000000 |
GRAYED |
int
|
0x00000001 |
MENUBARBREAK |
int
|
0x00000020 |
MENUBREAK |
int
|
0x00000040 |
OWNERDRAW |
int
|
0x00000100 |
POPUP |
int
|
0x00000010 |
SEPARATOR |
int
|
0x00000800 |
STRING |
int
|
0x00000000 |
UNCHECKED |
int
|
0x00000000 |
MenuGroup
¤
MenuGroup(name='')
A group of MenuItems.
Only one item in the group may have a check mark to indicate that a particular item is selected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A name to associate with the group. |
''
|
Source code in src/msl/loadlib/activex.py
749 750 751 752 753 754 755 756 757 758 759 760 | |
hmenu
property
¤
hmenu
append
¤
append(
text, *, callback=None, data=None, flags=MenuFlag.STRING
)
Create a new MenuItem and append it to the group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The content of the new menu item. |
required |
callback
|
Callable[[MenuItem], None] | None
|
A callable object that will be called when this menu item is selected. The callable object will receive the MenuItem instance as an argument and the returned object is ignored. |
None
|
data
|
Any
|
User data associated with the menu item. |
None
|
flags
|
MenuFlag
|
Controls the appearance and behaviour of the new menu item. Can be any combination (bitwise OR) of MenuFlag values. |
STRING
|
Returns:
| Type | Description |
|---|---|
MenuItem
|
The menu item that was appended to the group. |
Source code in src/msl/loadlib/activex.py
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | |
append_separator
¤
append_separator()
Append a horizontal dividing line to the group.
Source code in src/msl/loadlib/activex.py
818 819 820 | |
MenuItem
¤
MenuItem(**kwargs)
A menu item that belongs to a popup menu.
Warning
Do not instantiate this class directly. Use MenuGroup.append or Menu.append to create a new menu item.
Source code in src/msl/loadlib/activex.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | |
callback
property
¤
callback
MessageBoxOption
¤
Bases: IntFlag
Message box flags.
Attributes:
| Name | Type | Description |
|---|---|---|
ABORTRETRYIGNORE |
int
|
0x00000002 |
CANCELTRYCONTINUE |
int
|
0x00000006 |
HELP |
int
|
0x00004000 |
OK |
int
|
0x00000000 |
OKCANCEL |
int
|
0x00000001 |
RETRYCANCEL |
int
|
0x00000005 |
YESNO |
int
|
0x00000004 |
YESNOCANCEL |
int
|
0x00000003 |
ICONEXCLAMATION |
int
|
0x00000030 |
ICONWARNING |
int
|
0x00000030 |
ICONINFORMATION |
int
|
0x00000040 |
ICONASTERISK |
int
|
0x00000040 |
ICONQUESTION |
int
|
0x00000020 |
ICONSTOP |
int
|
0x00000010 |
ICONERROR |
int
|
0x00000010 |
ICONHAND |
int
|
0x00000010 |
DEFBUTTON1 |
int
|
0x00000000 |
DEFBUTTON2 |
int
|
0x00000100 |
DEFBUTTON3 |
int
|
0x00000200 |
DEFBUTTON4 |
int
|
0x00000300 |
APPLMODAL |
int
|
0x00000000 |
SYSTEMMODAL |
int
|
0x00001000 |
TASKMODAL |
int
|
0x00002000 |
DEFAULT_DESKTOP_ONLY |
int
|
0x00020000 |
RIGHT |
int
|
0x00080000 |
RTLREADING |
int
|
0x00100000 |
SETFOREGROUND |
int
|
0x00010000 |
TOPMOST |
int
|
0x00040000 |
SERVICE_NOTIFICATION |
int
|
0x00200000 |
ShowWindow
¤
Bases: IntEnum
Show window options.
Attributes:
| Name | Type | Description |
|---|---|---|
HIDE |
int
|
0 |
SHOWNORMAL |
int
|
1 |
NORMAL |
int
|
1 |
SHOWMINIMIZED |
int
|
2 |
SHOWMAXIMIZED |
int
|
3 |
MAXIMIZE |
int
|
3 |
SHOWNOACTIVATE |
int
|
4 |
SHOW |
int
|
5 |
MINIMIZE |
int
|
6 |
SHOWMINNOACTIVE |
int
|
7 |
SHOWNA |
int
|
8 |
RESTORE |
int
|
9 |
SHOWDEFAULT |
int
|
10 |
FORCEMINIMIZE |
int
|
11 |
WindowClassStyle
¤
Bases: IntFlag
Window class style flags.
Attributes:
| Name | Type | Description |
|---|---|---|
NONE |
int
|
0x0000 |
BYTEALIGNCLIENT |
int
|
0x1000 |
BYTEALIGNWINDOW |
int
|
0x2000 |
CLASSDC |
int
|
0x0040 |
DBLCLKS |
int
|
0x0008 |
DROPSHADOW |
int
|
0x00020000 |
GLOBALCLASS |
int
|
0x4000 |
HREDRAW |
int
|
0x0002 |
NOCLOSE |
int
|
0x0200 |
OWNDC |
int
|
0x0020 |
PARENTDC |
int
|
0x0080 |
SAVEBITS |
int
|
0x0800 |
VREDRAW |
int
|
0x0001 |
WindowPosition
¤
Bases: IntFlag
Window position flags.
Attributes:
| Name | Type | Description |
|---|---|---|
NONE |
int
|
0x0000 |
ASYNCWINDOWPOS |
int
|
0x4000 |
DEFERERASE |
int
|
0x2000 |
DRAWFRAME |
int
|
0x0020 |
FRAMECHANGED |
int
|
0x0020 |
HIDEWINDOW |
int
|
0x0080 |
NOACTIVATE |
int
|
0x0010 |
NOCOPYBITS |
int
|
0x0100 |
NOMOVE |
int
|
0x0002 |
NOOWNERZORDER |
int
|
0x0200 |
NOREDRAW |
int
|
0x0008 |
NOREPOSITION |
int
|
0x0200 |
NOSENDCHANGING |
int
|
0x0400 |
NOSIZE |
int
|
0x0001 |
NOZORDER |
int
|
0x0004 |
SHOWWINDOW |
int
|
0x0040 |
WindowStyle
¤
Bases: IntFlag
Window style flags.
Attributes:
| Name | Type | Description |
|---|---|---|
OVERLAPPED |
int
|
0x00000000 |
POPUP |
int
|
0x80000000 |
CHILD |
int
|
0x40000000 |
MINIMIZE |
int
|
0x20000000 |
VISIBLE |
int
|
0x10000000 |
DISABLED |
int
|
0x08000000 |
CLIPSIBLINGS |
int
|
0x04000000 |
CLIPCHILDREN |
int
|
0x02000000 |
MAXIMIZE |
int
|
0x01000000 |
CAPTION |
int
|
0x00C00000 |
BORDER |
int
|
0x00800000 |
DLGFRAME |
int
|
0x00400000 |
VSCROLL |
int
|
0x00200000 |
HSCROLL |
int
|
0x00100000 |
SYSMENU |
int
|
0x00080000 |
THICKFRAME |
int
|
0x00040000 |
GROUP |
int
|
0x00020000 |
TABSTOP |
int
|
0x00010000 |
MINIMIZEBOX |
int
|
0x00020000 |
MAXIMIZEBOX |
int
|
0x00010000 |
TILED |
int
|
OVERLAPPED |
ICONIC |
int
|
MINIMIZE |
SIZEBOX |
int
|
THICKFRAME |
OVERLAPPEDWINDOW |
int
|
OVERLAPPED | CAPTION | SYSMENU | THICKFRAME | MINIMIZEBOX | MAXIMIZEBOX |
POPUPWINDOW |
int
|
POPUP | BORDER | SYSMENU |
CHILDWINDOW |
int
|
CHILD |
TILEDWINDOW |
int
|
OVERLAPPEDWINDOW |