ActiveX Questions
Michael Kelly
mkelly2002NOSPAM at earthlink.net
Mon Feb 18 17:17:05 EST 2002
On Mon, 18 Feb 2002 11:48:01 -0800, "Jimmy Retzlaff"
<jimmy at retzlaff.com> wrote:
[snip]
Here's a python script I have for using an
"invisible" ActiveX Control that dynamically
creates and displays Message Dialogs with
cool color backgrounds:
(please forgive newsreader word wrap messing up the script)
# Demonstrates handling an event fired from an .ocx ActiveX Control in
# Python
# November 20, 2001
# Michael Kelly
#
# The ActiveX Control provides dialog boxes with mixed color
#backgrounds.
# If a HelpCtx other than -1 is passed to a method a Help button is
#also
# displayed in the dialog. The demo handler below handles the event
#for
# the Help button press.
import pythoncom
import win32com.client
import GradDlgX
import win32com.server.util
import os
HelpMsgs = ["Some Help Appropriate to Context 0",
"Some Other damn Message for Context 1",
"Okay, you Pressed Help with Context 2 Oberday!",
"Alright already! Help Context 3"]
def InternalHelpFunc(HelpCtx):
if HelpCtx >= 0 and HelpCtx < len(HelpMsgs):
print HelpMsgs[HelpCtx]
def ExternalHelpFunc(HelpCtx):
if HelpCtx >= len(HelpMsgs):
os.startfile("D:\Program Files\Microsoft Visual
Studio\MyProjects\MyActiveX\GradDlgX.hlp")
class HelpHandler:
def OnContextHelp(self, HelpCtx=GradDlgX.defaultNamedNotOptArg):
#self.__dlg =
win32com.client.Dispatch("GradDlgXControl1.GradDlgX")
#if HelpCtx >= 0 and HelpCtx < len(HelpMsgs):
if 0 <= HelpCtx < len(HelpMsgs):
InternalHelpFunc(HelpCtx)
else:
ExternalHelpFunc(HelpCtx)
EDlg = win32com.client.DispatchWithEvents("GradDlgXControl1.GradDlgX",
HelpHandler)
EDlg.InfoDlg("Hello", 1, 1, 2)
=== end of script ===
Most of my ActiveX are of the "invisible" variety so
there may be container issues that don't apply.
The ActiveX Control in this case is one created by
Delphi 5 wizard from a Delphi "TWinControl"
component.
[Note that one fun thing with this is that the
ActiveX uses a local dynamically created
dialog, so in the help handler I can call
the ActiveX Control to make another dialog
to show a msg if I like.]
--
"I don't want to belong to any club that would have me as a member."
-- Groucho Marx
More information about the Python-list
mailing list