Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet202/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   198   199   200   201   202   203   204   205   ...   453
184

CHAPTER 9
InteractIng wIth cOM Objects
Media Player (MP) configuration comes next. You must instantiate the control from the 
AxWMPLib 
.AxWindowsMediaPlayer()
constructor, rather than using the COM component constructor. The Ax 
constructor provides a wrapper with additional features you need within the Windows Forms environ-
ment. Like most controls, you need to specify control position and size on the form. However, because 
of the nature of the Windows Media Player, you want it to fill the client area of the form, so you set the 
Dock
property to 
System.Windows.Forms.DockStyle.Fill
.
The one configuration item that you must perform correctly is setting the COM component values 
using the 
MP.OcxState
property. The 
ComponentResourceManager

resources
, contains this value. 
You simply set the 
MP.OcxState
property to 
resources.GetObject(“MP.OcxState”)
— this tech-
nique is also different from what you’d use in a C# or Visual Basic.NET application. The rest of the 
form code isn’t anything special — you’ve seen it in all of the Windows Forms examples so far.
Creating the Media Player Application Code
Some COM components require a lot of tinkering by the host application, despite being self-contained 
for the most part. However, the Windows Media Player is an exception to the rule. Normally, you want 
to tinker with it as little as possible to meet your programming requirements. In some cases, you won’t 
want to tinker at all, as shown in Listing 9-2.
LISTINg 9-2: 
 Interacting with the COM component
# Set up the path to the .NET Framework. 
import sys
sys.path.append(‘C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727’)
# Make clr accessible.
import clr
# Add any required references.
clr.AddReference(‘System.Windows.Forms.DLL’)
# Import the .NET assemblies.
import System 
import System.Windows.Forms
# import the form. 
from frmUseWMP import *
# Define the Windows Form and the elements of this specific instance.
WMPForm = frmUseWMP()
WMPForm.InitializeComponent()
# Run the application.
System.Windows.Forms.Application.Run(WMPForm)
This code does the minimum possible for a Windows Forms application. It contains no event
handlers or anything of that nature. In fact, the code simply displays the forms. Believe it or not,
548592c09.indd 184
2/24/10 12:48:22 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   198   199   200   201   202   203   204   205   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish