$PBExportHeader$w_main.srw forward global type w_main from window end type type mdi_1 from mdiclient within w_main end type type dw_info from u_base_datawindow within w_main end type type point from structure within w_main end type type minmaxinfo from structure within w_main end type end forward type point from structure long lx long ly end type type minmaxinfo from structure point ptreserved point ptmaxsize point ptmaxposition point ptmintracksize point ptmaxtracksize end type global type w_main from window boolean visible = false integer x = 23 integer y = 24 integer width = 4210 integer height = 2424 boolean titlebar = true string title = "ZLib - Compression Library Example" string menuname = "m_main" boolean controlmenu = true boolean minbox = true boolean maxbox = true boolean resizable = true windowtype windowtype = mdihelp! long backcolor = 67108864 string icon = "AppIcon!" boolean center = true event ue_openzip ( ) event ue_comments ( ) event ue_extract ( ) event ue_newzip ( ) event ue_addfile ( ) event getminmaxinfo pbm_getminmaxinfo mdi_1 mdi_1 dw_info dw_info end type global w_main w_main type prototypes Subroutine GetMinMaxInfo ( & Ref MINMAXINFO d, & longptr s, & long l & ) Library "kernel32.dll" Alias For "RtlMoveMemory" Subroutine SetMinMaxInfo ( & longptr d, & MINMAXINFO s, & long l & ) Library "kernel32.dll" Alias For "RtlMoveMemory" end prototypes type variables Constant String WindowMemory = "Window\w_main" n_dwautowidth in_dwaw String is_zipfile end variables forward prototypes public subroutine wf_staterestore () public subroutine wf_statesave () end prototypes event ue_openzip();String ls_filename Integer li_rc li_rc = GetFileOpenName("Open Zip Archive", & is_zipfile, ls_filename, "ZIP", "Zip Archives (*.zip),*.ZIP") If li_rc = 1 Then // get directory of zipfile dw_info.Event ue_populate() End If end event event ue_comments();String ls_comment Longptr ll_zipfile If is_zipfile = "" Then Return // open the zip archive ll_zipfile = gn_zlib.of_unzOpen(is_zipfile) If ll_zipfile > 0 Then // get global comment ls_comment = gn_zlib.of_unzGetGlobalComment(ll_zipfile) MessageBox("Global Comment", ls_comment) // close the zip archive gn_zlib.of_unzClose(ll_zipfile) End If end event event ue_extract();String ls_name, ls_fullname, ls_filename Longptr ll_zipfile Long ll_row Integer li_rc ll_row = dw_info.GetRow() If ll_row = 0 Then Return // get file name and fullname ls_name = dw_info.GetItemString(ll_row, "name") ls_fullname = dw_info.GetItemString(ll_row, "fullname") // get filename to extract to li_rc = GetFileSaveName("Extract File", & ls_name, ls_filename, "", "All Files (*.*),*.*") If li_rc = 1 Then SetPointer(HourGlass!) // open the zip archive ll_zipfile = gn_zlib.of_unzOpen(is_zipfile) If ll_zipfile > 0 Then // extract the file gn_zlib.of_ExtractFile(ll_zipfile, ls_name, ls_fullname) // close the zip archive gn_zlib.of_unzClose(ll_zipfile) End If End If end event event ue_newzip();Integer li_rc String ls_fname li_rc = GetFileSaveName("Create Zip Archive", & is_zipfile, ls_fname, "zip", "Zip Archives (*.zip),*.zip") If li_rc = 1 Then this.Event ue_addfile() End If end event event ue_addfile();Longptr ll_zipFile Integer li_rc, li_file, li_count String ls_title, ls_fname, ls_extn, ls_filter String ls_folder, ls_initialdir, ls_pathname String ls_filename[], ls_ImportFile Boolean lb_folder = False SetPointer(HourGlass!) If lb_folder Then ls_title = "Add Folder to Archive" li_rc = GetFolder(ls_title, ls_folder) If li_rc = 1 Then // open zipfile ll_zipFile = gn_zlib.of_zipOpen(is_zipfile) // import selected folder gn_zlib.of_ImportFolder(ll_zipFile, ls_folder) // close zipfile gn_zlib.of_zipClose(ll_zipFile, "Zip archive created by PowerBuilder!") End If Else // get name of files to add ls_title = "Add Files to Archive" ls_filter = "All Files (*.*), *.*" li_rc = GetFileOpenName(ls_title, ls_pathname, ls_filename, & ls_extn, ls_filter, ls_initialdir) If li_rc = 1 Then // open zipfile ll_zipFile = gn_zlib.of_zipOpen(is_zipfile) // import selected files li_count = UpperBound(ls_filename) If li_count = 1 Then gn_zlib.of_ImportFile(ll_zipFile, ls_pathname, ls_filename[1]) Else For li_file = 1 To li_count ls_ImportFile = ls_pathname + "\" + ls_filename[li_file] gn_zlib.of_ImportFile(ll_zipFile, ls_ImportFile, ls_filename[li_file]) Next End If // close zipfile gn_zlib.of_zipClose(ll_zipFile, "Zip archive created by PowerBuilder!") End If End If // get directory of zipfile dw_info.Event ue_populate() end event event getminmaxinfo;MINMAXINFO lstr_minmaxinfo // copy the data to local structure GetMinMaxInfo(lstr_minmaxinfo, minmaxinfo, 40) // set the minimum size for our window lstr_minmaxinfo.ptMinTrackSize.lx = UnitsToPixels(2500, XUnitsToPixels!) lstr_minmaxinfo.ptMinTrackSize.ly = UnitsToPixels(1650, YUnitsToPixels!) // copy the structure back into memory SetMinMaxInfo(MINMAXINFO, lstr_minmaxinfo, 40) // important: must return 0 Return 0 end event public subroutine wf_staterestore ();Integer li_newwidth, li_newheight String ls_toolbar, ls_state gw_frame = this // restore window state ls_state = gn_app.of_GetReg(WindowMemory,"WindowState","Normal") If Lower(ls_state) = "maximized" Then // maximize window gn_app.of_ShowWindow(gw_frame, Maximized!) Else // restore window size/position li_newwidth = Integer(gn_app.of_GetReg(WindowMemory,"WindowWidth", String(this.Width))) li_newheight = Integer(gn_app.of_GetReg(WindowMemory,"WindowHeight", String(this.Height))) this.Resize(li_newwidth, li_newheight) this.X = Integer(gn_app.of_GetReg(WindowMemory,"WindowXPos", String(this.X))) this.Y = Integer(gn_app.of_GetReg(WindowMemory,"WindowYPos", String(this.Y))) End If // make visible after repositioned this.Visible = True end subroutine public subroutine wf_statesave ();// save window state If this.WindowState = Maximized! Then // window is maximized gn_app.of_SetReg(WindowMemory,"WindowState", "Maximized") Else If this.WindowState = Normal! Then // window is normal gn_app.of_SetReg(WindowMemory,"WindowState", "Normal") // remember window size/position gn_app.of_SetReg(WindowMemory,"WindowXPos", String(this.X)) gn_app.of_SetReg(WindowMemory,"WindowYPos", String(this.Y)) gn_app.of_SetReg(WindowMemory,"WindowWidth", String(this.Width)) gn_app.of_SetReg(WindowMemory,"WindowHeight", String(this.Height)) End If End If end subroutine on w_main.create if this.MenuName = "m_main" then this.MenuID = create m_main this.mdi_1=create mdi_1 this.dw_info=create dw_info this.Control[]={this.mdi_1,& this.dw_info} end on on w_main.destroy if IsValid(MenuID) then destroy(MenuID) destroy(this.mdi_1) destroy(this.dw_info) end on event resize;dw_info.Width = this.WorkSpaceWidth() - 18 dw_info.Height = this.WorkSpaceHeight() - 75 end event event open;// restore window state wf_StateRestore() end event event close;// save window state wf_StateSave() end event type mdi_1 from mdiclient within w_main long BackColor=268435456 end type type dw_info from u_base_datawindow within w_main event ue_populate ( ) integer x = 9 integer y = 164 integer width = 4091 integer height = 2016 string dataobject = "d_zipdirectory" boolean hscrollbar = true boolean vscrollbar = true end type event ue_populate();// get directory of created zipfile String ls_import SetPointer(HourGlass!) this.SetRedraw(False) Parent.title = "ZLib - " + is_zipfile ls_import = gn_zlib.of_Directory(is_zipfile, False) this.Reset() this.ImportString(ls_import) this.Sort() // resize columns in_dwaw.of_resize("name") in_dwaw.of_resize("type") in_dwaw.of_resize("size") in_dwaw.of_resize("packed") in_dwaw.of_resize("path") in_dwaw.of_resize("comment") this.SetRedraw(True) this.SetFocus() this.Event RowFocusChanged(1) end event event constructor;call super::constructor;// turn on gridsort arrows this.of_gridsort_arrows(this.of_get_syscolor(16)) // register window/datawindow in_dwaw.of_register(Parent, dw_info) end event
File: w_main.srw
Size: 8447
Date: Thu, 14 Jul 2022 19:38:04 +0200
Size: 8447
Date: Thu, 14 Jul 2022 19:38:04 +0200
- window w_main(srw)
- mdiclient mdi_1
- u_base_datawindow dw_info