Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet201/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   197   198   199   200   201   202   203   204   ...   453
/define:
A
[,
B
]
: Provides a means for performing optional conversions specified by #ifdef 
structures within a 
.RESTEXT
(text) file.
@


file
: Specifies the name of a response file to use for additional command line options. You 
can only provide one response file for any given session.
Creating the Media Player Form Code
As normal, the example relies on two files to hold the form and the client code. Because we’re using 
a COM component for this example, the form requires a number of special configuration steps. 
Listing 9-1 shows the form code.
LISTINg 9-1: 
 Creating a Windows Forms application with a 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.
548592c09.indd 182
2/24/10 12:48:22 PM
www.finebook.ir


Defining an Interop DLL
 

 
183
clr.AddReference(‘System.Windows.Forms.DLL’)
clr.AddReference(‘System.Drawing.DLL’)
clr.AddReference(‘AxWMPLib.DLL’)
# Import the .NET assemblies.
import System 
import System.Windows.Forms
import System.Drawing.Point
import AxWMPLib
class frmUseWMP(System.Windows.Forms.Form):
# This function performs all of the required initialization.
def InitializeComponent(self):
# Create a Component Resource Manager
self.resources = System.ComponentModel.ComponentResourceManager.
CreateFileBasedResourceManager(
‘frmUseWMP’, ‘C:/0255 - Source Code/Chapter09’, None)
# Configure Windows Media Player
self.MP = AxWMPLib.AxWindowsMediaPlayer()
self.MP.Dock = System.Windows.Forms.DockStyle.Fill
self.MP.Enabled = True
self.MP.Location = System.Drawing.Point(0, 0)
self.MP.Name = “MP”
self.MP.Size = System.Drawing.Size(292, 266)
self.MP.OcxState = self.resources.GetObject(“MP.OcxState”)
# Configure the form.
self.ClientSize = System.Drawing.Size(350, 200)
self.Text = ‘Simple Windows Media Player Example’
# Add the controls to the form.
self.Controls.Add(self.MP)
The code begins with the normal steps of adding the .NET Framework path, making 
clr
accessible, 
importing the required DLLs, and importing the required assemblies. Notice that the example uses 
the 
AxWMPLib.DLL
file and 
AxWMPLib
assembly. Remember that the Ax versions of the files provide 
wrapping around the ActiveX controls to make them usable as a managed control.
The code begins by creating a 
ComponentResourceManager
from a file, using the 
CreateFileBasedResourceManager()
method. Normally, a managed application would
create the 
ComponentResourceManager
directly from the data stored as part of the form.
This is a special step for IronPython that could cause you grief later if you forget about it.
Even though Listing 9-1 shows the 
CreateFileBasedResourceManager()
method call on multiple lines, it appears on a single line in the actual source 
code. The IronPython call won’t work if you place it on multiple lines because 
IronPython lacks a line continuation character (or methodology).
548592c09.indd 183
2/24/10 12:48:22 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   197   198   199   200   201   202   203   204   ...   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