CreateBitmap メソッドはインスタンス PRIM_BMP を生成します。
これは、BLOB をイメージに変換する時や FilePicker で選択されたファイルを処理する際に便利です。
ブラウザ内で実行され、メソッドに Filename が割り当てられた場合、ビットマップを作成するファイルの実際のロードは非同期に行われます。Loaded イベントを使って、これが完了した時を決定します。
以下の例では、BLOB フィールドを PRIM_IMAG にロードし、Web ページに表示します。
Define_Com Class(#PRIM_IMAG) Name(#MyImage) Displayposition(5) Left(191) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(6) Height(788) Width(1003)
Mthroutine Name(LoadImage)
Define_Com Class(#MyServerMod.GetImage) Name(#GetImage)
#GetImage.ExecuteAsync( #xEmployeeImage )
Evtroutine Handling(#GetImage.Completed)
#MyImage.Image <= #sys_appln.CreateBitmap( #xEmployeeImage )
Endroutine
Endroutine
This example allows for the selection of an image and shows the selected image on the Web Page:
Begin_Com Role(*EXTENDS #PRIM_WEB) Layoutmanager(#TableLayout1)
Define_Com Class(#PRIM_TBLO) Name(#TableLayout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#TableLayout1) Width(185) Units(Pixels)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column2) Displayposition(2) Parent(#TableLayout1) Width(1.7)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#TableLayout1)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row2) Displayposition(2) Parent(#TableLayout1) Height(50) Units(Pixels)
Define_Com Class(#PRIM_TBLO.Item) Name(#FilePicker1Item1) Alignment(TopCenter) Column(#Column1) Manage(#FilePicker) Parent(#TableLayout1) Row(#Row1) Sizing(None) Margintop(6)
Define_Com Class(#PRIM_TBLO.Item) Name(#Image1Item1) Column(#Column2) Manage(#Image) Parent(#TableLayout1) Row(#Row1) Margintop(6) Marginright(6) Marginbottom(6) Marginleft(6)
Define_Com Class(#PRIM_TBLO.Item) Name(#Label1Item1) Alignment(BottomCenter) Column(#Column2) Manage(#Filename) Parent(#TableLayout1) Row(#Row2) Sizing(FitToWidth) Marginbottom(12) Marginright(12) Marginleft(12)
Define_Com Class(#PRIM_WEB.FilePicker) Name(#FilePicker) Displayposition(2) Ellipses(Word) Height(56) Left(8) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(6) Verticalalignment(Center) Width(169) Image(#xImageCamera32) Caption('Select an Image') Marginleft(8) Themedrawstyle('PushButton')
Define_Com Class(#PRIM_IMAG) Name(#Image) Displayposition(3) Left(191) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(6) Height(738) Width(1003)
Define_Com Class(#PRIM_LABL) Name(#Filename) Displayposition(1) Ellipses(Word) Height(55) Left(197) Parent(#COM_OWNER) Tabposition(3) Tabstop(False) Top(733) Verticalalignment(Center) Width(991) Alignment(Center) Themedrawstyle('Heading1')
Evtroutine Handling(#FilePicker.FileSelected) File(#File)
* イメージのロードは非同期。 ここでできる唯一の作業は、イメージをインスタンスにすること。
#Image.Image <= #sys_appln.Createbitmap( #File.blob )
#Filename := #File.blob
Endroutine
End_Com