File: w_main.srw
Size: 12364
Date: Sat, 09 Feb 2019 21:49:34 +0100
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type cbx_lvexisting from checkbox within w_main
end type
type cbx_tvexisting from checkbox within w_main
end type
type cb_tvimportbitmaps from commandbutton within w_main
end type
type cb_lvimportbitmaps from commandbutton within w_main
end type
type st_1 from statictext within w_main
end type
type ddlb_view from dropdownlistbox within w_main
end type
type cb_lvimporticons from commandbutton within w_main
end type
type lv_icons from u_listview within w_main
end type
type cb_tvimporticons from commandbutton within w_main
end type
type tv_icons from u_treeview within w_main
end type
type cb_cancel from commandbutton within w_main
end type
end forward

global type w_main from window
integer width = 3854
integer height = 2444
boolean titlebar = true
string title = "ImageList"
boolean controlmenu = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cbx_lvexisting cbx_lvexisting
cbx_tvexisting cbx_tvexisting
cb_tvimportbitmaps cb_tvimportbitmaps
cb_lvimportbitmaps cb_lvimportbitmaps
st_1 st_1
ddlb_view ddlb_view
cb_lvimporticons cb_lvimporticons
lv_icons lv_icons
cb_tvimporticons cb_tvimporticons
tv_icons tv_icons
cb_cancel cb_cancel
end type
global w_main w_main

type prototypes

end prototypes

on w_main.create
this.cbx_lvexisting=create cbx_lvexisting
this.cbx_tvexisting=create cbx_tvexisting
this.cb_tvimportbitmaps=create cb_tvimportbitmaps
this.cb_lvimportbitmaps=create cb_lvimportbitmaps
this.st_1=create st_1
this.ddlb_view=create ddlb_view
this.cb_lvimporticons=create cb_lvimporticons
this.lv_icons=create lv_icons
this.cb_tvimporticons=create cb_tvimporticons
this.tv_icons=create tv_icons
this.cb_cancel=create cb_cancel
this.Control[]={this.cbx_lvexisting,&
this.cbx_tvexisting,&
this.cb_tvimportbitmaps,&
this.cb_lvimportbitmaps,&
this.st_1,&
this.ddlb_view,&
this.cb_lvimporticons,&
this.lv_icons,&
this.cb_tvimporticons,&
this.tv_icons,&
this.cb_cancel}
end on

on w_main.destroy
destroy(this.cbx_lvexisting)
destroy(this.cbx_tvexisting)
destroy(this.cb_tvimportbitmaps)
destroy(this.cb_lvimportbitmaps)
destroy(this.st_1)
destroy(this.ddlb_view)
destroy(this.cb_lvimporticons)
destroy(this.lv_icons)
destroy(this.cb_tvimporticons)
destroy(this.tv_icons)
destroy(this.cb_cancel)
end on

type cbx_lvexisting from checkbox within w_main
integer x = 2304
integer y = 2220
integer width = 370
integer height = 72
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = "Use Existing"
end type

type cbx_tvexisting from checkbox within w_main
integer x = 951
integer y = 2220
integer width = 370
integer height = 72
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = "Use Existing"
end type

type cb_tvimportbitmaps from commandbutton within w_main
integer x = 512
integer y = 2208
integer width = 407
integer height = 100
integer taborder = 40
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "Import Bitmaps"
end type

event clicked;String ls_filename
Long ll_ownindex, ll_handle, ll_prior, ll_index, ll_count

SetPointer(HourGlass!)

tv_icons.of_DeleteItems()

If cbx_tvexisting.Checked Then
   // use existing ImageList
   If Not tv_icons.of_SetImageList() Then
      MessageBox(this.Text, "of_SetImageList failed!", StopSign!)
      Return
   End If
   // import the owner image
   ls_filename = "globe.ico"
   ll_ownindex = 1
Else
   // create ImageList
   If Not tv_icons.of_CreateImageList() Then
      MessageBox(this.Text, "of_CreateImageList failed!", StopSign!)
      Return
   End If
   // import the owner image
   ls_filename = "globe.ico"
   ll_ownindex = tv_icons.of_ImportIcon(ls_filename, 0)
End If

ll_prior = ll_ownindex
ll_handle = tv_icons.InsertItemLast(0, "of_ImportBitmap", ll_ownindex)

// import bitmaps from resource dll
ls_filename = "ieframe.dll"
ll_index = tv_icons.of_ImportBitmap(ls_filename, "206")
ll_count = tv_icons.of_GetImageCount()
For ll_index = 1 To ll_count - ll_prior
   tv_icons.InsertItemLast(ll_handle, String(ll_index), ll_index + ll_prior)
Next

// import bitmap from .bmp file
ls_filename = "foldero.bmp"
ll_index = tv_icons.of_ImportBitmap(ls_filename)
If ll_index > 0 Then
   tv_icons.InsertItemLast(ll_handle, ls_filename, ll_index)
End If

// import PowerBuilder stock bitmap
ll_index = tv_icons.of_ImportStockBitmap("Picture!")
tv_icons.InsertItemLast(ll_handle, "Picture!", ll_index)

tv_icons.ExpandItem(ll_handle)

end event

type cb_lvimportbitmaps from commandbutton within w_main
integer x = 1865
integer y = 2208
integer width = 407
integer height = 100
integer taborder = 60
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "Import Bitmaps"
end type

event clicked;Long ll_index, ll_count, ll_prior
String ls_filename

SetPointer(HourGlass!)

lv_icons.DeleteItems()

ddlb_view.SelectItem(4)
ddlb_view.Event SelectionChanged(4)

If cbx_lvexisting.Checked Then
   // use existing ImageList
   If Not lv_icons.of_SetSmallImageList() Then
      MessageBox(this.Text, "of_SetSmallImageList failed!", StopSign!)
      Return
   End If
   lv_icons.AddItem("Existing", 1)
   ll_prior = 1
Else
   // create ImageList
   If Not lv_icons.of_CreateSmallImageList() Then
      MessageBox(this.Text, "of_CreateImageList failed!", StopSign!)
      Return
   End If
End If

// import bitmaps from resource dll
ls_filename = "ieframe.dll"
ll_index = lv_icons.of_ImportSmallBitmap(ls_filename, "206")
ll_count = lv_icons.of_GetSmallImageCount()
For ll_index = 1 To ll_count - ll_prior
   lv_icons.AddItem("BMP:" + String(ll_index), ll_index + ll_prior)
Next

// import bitmap from .bmp file
ls_filename = "foldero.bmp"
ll_index = lv_icons.of_ImportSmallBitmap(ls_filename)
If ll_index > 0 Then
   lv_icons.AddItem(ls_filename, ll_index)
End If

// import PowerBuilder stock bitmap
ll_index = lv_icons.of_ImportStockBitmap("Picture!")
lv_icons.AddItem("Picture!", ll_index)

end event

type st_1 from statictext within w_main
integer x = 2816
integer y = 2224
integer width = 183
integer height = 60
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = " View:"
boolean focusrectangle = false
end type

type ddlb_view from dropdownlistbox within w_main
integer x = 2999
integer y = 2208
integer width = 370
integer height = 400
integer taborder = 70
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean vscrollbar = true
string item[] = {"LargeIcon","List","Report","SmallIcon"}
borderstyle borderstyle = stylelowered!
end type

event constructor;this.SelectItem(4)
this.Event SelectionChanged(4)

end event

event selectionchanged;choose case index
   case 1
      lv_icons.View = ListViewLargeIcon!
   case 2
      lv_icons.View = ListViewList!
   case 3
      lv_icons.View = ListViewReport!
   case 4
      lv_icons.View = ListViewSmallIcon!
end choose

end event

type cb_lvimporticons from commandbutton within w_main
integer x = 1390
integer y = 2208
integer width = 407
integer height = 100
integer taborder = 50
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "Import Icons"
end type

event clicked;n_imagelist ln_imglist
String ls_filename
Long ll_large, ll_small, ll_index, ll_count, ll_prior

SetPointer(HourGlass!)

lv_icons.DeleteItems()

// create ImageList
If Not lv_icons.of_CreateSmallImageList() Then
   MessageBox(this.Text, "of_CreateSmallImageList failed!", StopSign!)
   Return
End If
If Not lv_icons.of_CreateLargeImageList() Then
   MessageBox(this.Text, "of_CreateLargeImageList failed!", StopSign!)
   Return
End If

// import Icons into ImageList
ls_filename = "shell32.dll"
ll_count = lv_icons.of_ImportIcons(ls_filename, 0, &
                        True, True, ll_large, ll_small)

// add Icons to the ListView
For ll_index = 1 To ll_count
   lv_icons.AddItem("ICO:" + String(ll_index), ll_index)
Next

// import Icons into ImageList
ls_filename = ln_imglist.of_pbvmname()
ll_prior = ll_count
ll_count = lv_icons.of_ImportIcons(ls_filename, 0, &
                        True, True, ll_large, ll_small)

// add Icons to the ListView
For ll_index = 1 To ll_count
   lv_icons.AddItem("PB:" + String(ll_index), ll_index + ll_prior)
Next

// import separate Icon file
ls_filename = "globe.ico"
ll_index = lv_icons.of_ImportLargeIcon(ls_filename, 0)
ll_index = lv_icons.of_ImportSmallIcon(ls_filename, 0)
lv_icons.AddItem(ls_filename, ll_index)

end event

type lv_icons from u_listview within w_main
integer x = 1390
integer y = 32
integer width = 2382
integer height = 2116
integer taborder = 20
string smallpicturename[] = {"Continue!"}
long smallpicturemaskcolor = 12632256
end type

event constructor;call super::constructor;this.AddColumn("Icon Index", Left!, 500)

end event

event destructor;call super::destructor;this.of_DestroyImageLists()

end event

type cb_tvimporticons from commandbutton within w_main
integer x = 37
integer y = 2208
integer width = 407
integer height = 100
integer taborder = 30
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "Import Icons"
end type

event clicked;n_imagelist ln_imglist
String ls_filename
Long ll_ownindex, ll_handle, ll_index, ll_count, ll_prior

SetPointer(HourGlass!)

tv_icons.of_DeleteItems()

// create ImageList
If Not tv_icons.of_CreateImageList() Then
   MessageBox(this.Text, "of_CreateImageList failed!", StopSign!)
   Return
End If

// import the owner image
ls_filename = "globe.ico"
ll_ownindex = tv_icons.of_ImportIcon(ls_filename, 0)
ll_prior = ll_ownindex

// import Icons into ImageList
ls_filename = "shell32.dll"
ll_count = tv_icons.of_ImportIcons(ls_filename, 0, ll_index)

// add Icons to the TreeView
ll_handle = tv_icons.InsertItemLast(0, "shell32.dll icons", ll_ownindex)
For ll_index = 1 To ll_count
   tv_icons.InsertItemLast(ll_handle, String(ll_index), ll_index + ll_prior)
Next

// import Icons into ImageList
ls_filename = ln_imglist.of_pbvmname()
ll_prior = ll_prior + ll_count
ll_count = tv_icons.of_ImportIcons(ls_filename, 0, ll_index)

// add Icons to the TreeView
ll_handle = tv_icons.InsertItemLast(0, ls_filename + " Icons", ll_ownindex)
For ll_index = 1 To ll_count
   tv_icons.InsertItemLast(ll_handle, String(ll_index), ll_index + ll_prior)
Next

tv_icons.ExpandItem(ll_handle)

end event

type tv_icons from u_treeview within w_main
integer x = 37
integer y = 32
integer width = 1285
integer height = 2116
integer taborder = 10
boolean linesatroot = true
boolean hideselection = false
string picturename[] = {"Continue!"}
long picturemaskcolor = 12632256
end type

event destructor;call super::destructor;this.of_DestroyImageList()

end event

type cb_cancel from commandbutton within w_main
integer x = 3438
integer y = 2208
integer width = 334
integer height = 100
integer taborder = 80
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "Cancel"
boolean cancel = true
end type

event clicked;Close(Parent)

end event