[r7098]: incubator / WinShell.4.0.0 / testing / simpleFolderBrowse.rex  Maximize  Restore  History

Download this file

139 lines (114 with data), 6.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*----------------------------------------------------------------------------*/
/* */
/* Copyright (c) 2008-2008 Rexx Language Association. All rights reserved. */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the Common Public License v1.0 which accompanies this */
/* distribution. A copy is also available at the following address: */
/* http://www.oorexx.org/license.html */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the distribution. */
/* */
/* Neither the name of Rexx Language Association nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*----------------------------------------------------------------------------*/
/** A Sample program showing how to use the .SimpleFolderBrowse class in an
* ooDialog program.
*/
-- Create a simple dialog. The code to actually use .SimpleFolderBrowse is
-- in the dialog code.
say 'Version:' .Sh~version
dlg = .SimpleDlg~new
if dlg~initCode <> 0 then do
say "Error creating dialog. initCode:" dlg~initCode
return 99
end
dlg~Execute('ShowTop')
dlg~DeInstall
exit
::requires 'oodwin32.cls'
::requires 'WinShell.cls'
::class SimpleDlg subclass userdialog -
inherit AdvancedControls MessageExtensions
::method Init
expose browser counter csidls
self~init:super
rc = self~CreateCenter(190, 160, 'Using the WinShell SimpleFolderBrowse Class')
if rc == 0 then self~initCode = -1
-- Instantiate a SimpleFolderBrowse object. This does not need to be done
-- here, it could just be done when it is actually needed.
-- The default title and banner can be changed to whatever the programmer
-- wants. The 'title' is the tile of the dialog. The 'banner' is the text
-- displayed above the tree control in the dialog.
title = "Simple Dialog Sample - Browse for Folder Application"
banner = "Open Object Rexx allows you to choose the folder you need"
browser = .SimpleFolderBrowse~new(title, banner)
-- The default root of the tree control can also be changed. The 'root' is
-- the topmost folder in the tree control. The user can not 'browse' above
-- that point. This will use the CSIDL_XXXX constants to name the root.
-- CSIDL_PERSONAL is the 'My Documents' folder.
browser~root = "CSIDL_PERSONAL"
-- This sample will cycle through a series of different root folders. They
-- are set up in this array.
counter = 0
csidls = .array~new
csidls[1] = "CSIDL_APPDATA"
csidls[2] = "CSIDL_COMMON_PROGRAMS"
csidls[3] = "CSIDL_CONNECTIONS"
csidls[4] = "CSIDL_COOKIES"
csidls[5] = "CSIDL_DESKTOP"
::method DefineDialog
instructions = 'When the Browse button is clicked a Browse for Folder dialog ' || -
'will be displayed. After closing the dialog, the result ' || -
'appears in the static text box below. (Long path names will ' || -
'be wrapped.)'
self~addGroupBox(5, 10, 180, 50, 'Instructions:', , 150)
self~addText(10, 20, 170, 35, instructions, , 155)
self~addGroupBox(5, 70, 180, 60, 'Result:', , 160)
self~addText(10, 80, 170, 40, "<N/A>", , 165)
self~AddButton(300, 5, 140, 75, 15,'Browse', 'onBrowse', "DEFAULT")
self~AddButton(IDOK, 135, 140, 50, 15, 'Done')
::method InitDialog
expose staticControl
staticControl = self~getStaticControl(165)
::method onBrowse
expose staticControl browser counter csidls
if counter > 0 then do
if counter > 5 then do
counter = 0
browser~root = .nil
end
else do
browser~root = csidls[counter]
end
end
ptr = .DlgUtil~handleToPointer(self~dlgHandle)
path = browser~getFolder(ptr)
if path == '' then path = "User canceled"
else if path == .nil then path = "User picked a virtual folder"
staticControl~setTitle(path)
counter += 1
::method ok
return self~ok:super

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks