powered by simpleCommunicator - 2.0.49     © 2025 Programmizd 02
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / как вызвать модное окно выбора файлов? (а-ля офис ХР?)
8 сообщений из 8, страница 1 из 1
как вызвать модное окно выбора файлов? (а-ля офис ХР?)
    #32635692
roleks
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
это возможно?
если да - подскажите как пожалуйста.
...
Рейтинг: 0 / 0
как вызвать модное окно выбора файлов? (а-ля офис ХР?)
    #32635797
Фотография Филипп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Ясновидящих как всегда нема, но если в РВ9, то GetFileOpenName PowerScript function имеет aFlag (optional) параметр:
The aFlag argument is used to pass one or more options that determine the appearance of the dialog box. For each option, the value of the flag is 2^(index -1), where index is an integer associated with each option as shown in the following table.You can pass multiple options by passing an aggregate flag, calculated by adding the values of the individual flags.

If you do not pass an aFlag, the Explorer-style open file dialog box is used. If you do pass a flag, the old-style dialog box is used by default. Some options do not apply when the Explorer-style dialog box is used. For those that do apply, add the option value for using the Explorer-style dialog box (2) to the value of the option if you want to display an Explorer-style dialog box.
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
Index	Constant name	Description
 1 	OFN_CREATEPROMPT	If the specified file does not exist, prompt for permission to create the file. If the user chooses to create the file, the dialog box closes; otherwise the dialog box remains open.
 2 	OFN_EXPLORER	Use an Explorer-style dialog box.
 3 	OFN_EXTENSIONDIFFERENT	The file extension entered differed from the extensions specified in extension.
 4 	OFN_FILEMUSTEXIST	Only the names of existing files can be entered.
 5 	OFN_HIDEREADONLY	Hide the Read Only check box.
 6 	OFN_LONGNAMES	Use long file names. Ignored for Explorer-style dialog boxes.
 7 	OFN_NOCHANGEDIR	Restore the current directory to its original value if the user changed the directory while searching for files. This option has no effect for GetOpenFileName on Windows NT,  2000 , and XP.
 8 	OFN_NODEREFERENCELINKS	Return the path and file name of the selected shortcut (.lnk file); otherwise the path and file name pointed to by the shortcut are returned.
 9 	OFN_NOLONGNAMES	Use short file names ( 8 . 3  format). Ignored for Explorer-style dialog boxes.
 10 	OFN_NONETWORKBUTTON	Hide the Network button. Ignored for Explorer-style dialog boxes.
 11 	OFN_NOREADONLYRETURN	The file returned is not read only and is not in a write-protected directory.
 12 	OFN_NOTESTFILECREATE	Do not create the file before the dialog box is closed. This option should be specified if the application saves the file on a netwrok share where files can be created but not modified. No check is made for write protection, a full disk, an open drive door, or network protection. A file cannot be reopened once it is closed.
 13 	OFN_NOVALIDATE	Invalid characters are allowed in file names.
 14 	OFN_OVERWRITEPROMPT	Used in Save As dialog boxes. Generates a message box if the selected file already exists.
 15 	OFN_PATHMUSTEXIST	Only valid paths and file names can be entered.
 16 	OFN_READONLY	Select the Read Only check box when the Save dialog box is created.
...
Рейтинг: 0 / 0
как вызвать модное окно выбора файлов? (а-ля офис ХР?)
    #32635828
roleks
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
нету там такого.........
...
Рейтинг: 0 / 0
как вызвать модное окно выбора файлов? (а-ля офис ХР?)
    #32635888
Фотография Филипп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Похоже, что-то они с флагами перемудрили...
Ну тогда без них :-)

Код: plaintext
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.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
488.
489.
490.
491.
492.
493.
494.
495.
496.
497.
498.
499.
500.
501.
502.
503.
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
524.
525.
526.
527.
528.
529.
530.
531.
532.
533.
534.
535.
536.
537.
538.
539.
540.
541.
542.
543.
544.
545.
546.
547.
548.
549.
550.
551.
552.
553.
554.
555.
556.
557.
558.
559.
560.
561.
562.
563.
564.
565.
566.
567.
568.
569.
570.
571.
572.
573.
574.
575.
576.
577.
578.
579.
580.
581.
582.
583.
584.
585.
586.
587.
588.
589.
590.
591.
592.
593.
594.
595.
596.
597.
598.
599.
600.
601.
602.
603.
604.
605.
606.
607.
608.
609.
610.
611.
612.
613.
614.
615.
616.
617.
618.
619.
620.
621.
622.
623.
624.
625.
626.
627.
628.
629.
630.
631.
632.
633.
634.
635.
636.
637.
638.
639.
640.
641.
642.
643.
644.
645.
646.
647.
648.
649.
650.
651.
652.
653.
654.
655.
656.
657.
658.
659.
660.
661.
662.
663.
664.
665.
666.
667.
668.
669.
670.
671.
672.
673.
674.
675.
676.
677.
678.
679.
680.
681.
682.
683.
684.
$PBExportHeader$nvo_commdlg.sru
$PBExportComments$Common dialog encapsulation
forward
global type nvo_commdlg from nonvisualobject
end type
end forward

type OPENFILENAME from structure
	long		lstructsize
	long		hwndowner
	long		hinstance
	long		lpstrfilter
	long		lpstrcustomfilter
	long		nMaxCustomFilter
	long		nFilterIndex
	long		lpstrFile
	long		nMaxFile
	long		lpstrFileTitle
	long		nMaxFileTitle
	long		lpstrInitialDir
	long		lpstrTitle
	long		Flags
	integer		nFileOffset
	integer		nFileExtension
	long		lpstrDefExt
	long		lCustData
	long		lpfnHook
	long		lpTemplateName
end type

type PRINTDLG from structure
	long		lStructSize
	long		hWndOwner
	long		hDevMode
	long		hDevNames
	long		hDC
	long		Flags
	integer		nFromPage
	integer		nToPage
	integer		nMinPage
	integer		nMaxPage
	integer		nCopies
	long		hInstance
	long		lCustData
	long		lpfnPrintHook
	long		lpfnSetupHook
	long		lpPrintTemplateName
	long		lpSetupTemplateName
	long		hPrintTemplate
	long		hSetupTemplate
end type

type devmode from structure
	character		dmDeviceName[ 32 ]
	integer		dmSpecVersion
	integer		dmDriverVersion
	integer		dmSize
	integer		dmDriverExtra
	long		dmFields
	integer		dmOrientation
	integer		dmPaperSize
	integer		dmPaperLength
	integer		dmPaperWidth
	integer		dmScale
	integer		dmCopies
	integer		dmDefaultSource
	integer		dmPrintQuality
	integer		dmColor
	integer		dmDuplex
	integer		dmYResolution
	integer		dmTTOption
	integer		dmCollate
	character		dmFormName[ 32 ]
	integer		dmLogPixels
	long		dmBitsPerPel
	long		dmPelsWidth
	long		dmPelsHeight
	long		dmDisplayFlags
	long		dmDisplayFrequency
	long		dmICMMethod
	long		dmICMIntent
	long		dmMediaType
	long		dmDitherType
	long		dmReserved1
	long		dmReserved2
end type

type devnames from structure
	integer		wDriverOffset
	integer		wDeviceOffset
	integer		wOutputOffset
	integer		wDefault
end type

type CHOOSEFONT from structure
	long		lStructSize
	long		hWndOwner
	long		hDC
	long		lpLogFont
	long		iPointSize
	long		Flags
	long		RGBColors
	long		lCustData
	long		lpfnHook
	long		lpTemplateName
	long		hInstance
	long		lpszStyle
	integer		nFontType
	integer		___MISSING_ALIGNMENT__
	long		nSizeMin
	long		nSizeMax
end type

type logfont from structure
	long		lfheight
	long		lfwidth
	long		lfescapement
	long		lforientation
	long		lfweight
	character		lfitalic
	character		lfunderline
	character		lfstrikeout
	character		lfcharset
	character		lfoutprecision
	character		lfclipprecision
	character		lfquality
	character		lfpitchandfamily
	character		lffacename[ 32 ]
end type

type printer_info_5 from structure
	unsignedlong		ul_pprintername
	unsignedlong		ul_pportname
	unsignedlong		ul_attributes
	unsignedlong		ul_devicenotselectedtimeout
	unsignedlong		ul_transmissionretrytimeout
end type

type PSDevNames from structure
	string		s_printername
	string		s_printerport
	string		s_printerdriver
end type

global type nvo_commdlg from nonvisualobject autoinstantiate
end type

type prototypes
// Common Dialog External Functions
Function long GetOpenFileNameA(REF OPENFILENAME OpenFileName) library "comdlg32.dll"
Function long GetSaveFileNameA(REF OPENFILENAME SaveFileName) library "comdlg32.dll"
Function long PrintDlgA(REF PRINTDLG PrintDlg) library "comdlg32.dll"
Function long ChooseFontA(REF CHOOSEFONT ChooseFont) library "comdlg32.dll"

// Memory Functions
Function long GetDevMode(REF DEVMODE Destination, long Source, long Size) library "kernel32.dll" Alias For "RtlMoveMemory"
Function long GetDevNames(REF DEVNAMES Destination, long Source, long Size) library "kernel32.dll" Alias For "RtlMoveMemory"
Function long GetLogFont(REF LOGFONT Destination, long Source, long Size) library "kernel32.dll" Alias For "RtlMoveMemory"
Function long PutLogFont(long Destination, REF LOGFONT Source, long Size) library "kernel32.dll" Alias For "RtlMoveMemory"

Function long StrCopy(long Destination, REF string Source, long Size) library "kernel32.dll"  Alias for "RtlMoveMemory"
Function long LocalAlloc(long Flags, long Bytes) library "kernel32.dll"
Function long LocalFree(long MemHandle) library "kernel32.dll"
Function long CommDlgExtendedError() library "comdlg32.dll"
Function long lstrcpy(long Destination, REF string Source) library "kernel32.dll"
Function long LocalLock(long Handle) library "kernel32.dll"
Function long LocalUnlock(long Handle) library "kernel32.dll"

// Misc Functions
Function long GetWindowsDirectoryA(REF string Buffer, long Size) library "kernel32.dll"

//EnumPrinters
function long EnumPrintersA (ULONG a_flags, ULONG  a_name, ULONG a_level,  REF POWEROBJECT a_Printer_Info_5[],  ULONG c_cbBuf,   REF ULONG a_pcbNeeded,  REF ULONG  a_pcReturned ) LIBRARY "WINSPOOL.DRV"
end prototypes

type variables
// *****************************************************************
// All Dialogs members
// *****************************************************************
PUBLIC long Flags =  0 		// Dialog Flags
PUBLIC long hWndParent =  0 		// Parent Window

// *****************************************************************
// Open & Save Dialog public members
// *****************************************************************
Public:
string Filter = ""		// description1~tfilter1~tdescription2~tfilter2
integer FilterIndex =  1 	// Default filter index
string InitialDir  = "" 		// Default directory
string Title = ""		// Dialog Title
PROTECTEDWRITE string Filename = "" 		// returns selected file
PROTECTEDWRITE string Files[]		// Selected Files
PROTECTEDWRITE string PathName		// Path
PROTECTEDWRITE integer FileCount		// Number of selected files

// Flags constants
CONSTANT long OFN_READONLY			=  1 
CONSTANT long OFN_OVERWRITEPROMPT		=  2 
CONSTANT long OFN_HIDEREADONLY		=  4 
CONSTANT long OFN_NOCHANGEDIR		=  8 
CONSTANT long OFN_SHOWHELP			=  16 
CONSTANT long OFN_ENABLEHOOK			=  32 
CONSTANT long OFN_ENABLETEMPLATE		=  64 
CONSTANT long OFN_ENABLETEMPLATEHANDLE	=  128 
CONSTANT long OFN_NOVALIDATE			=  256 
CONSTANT long OFN_ALLOWMULTISELECT		=  512 
CONSTANT long OFN_EXTENSIONDIFFERENT		=  1024 
CONSTANT long OFN_PATHMUSTEXIST		=  2048 
CONSTANT long OFN_FILEMUSTEXIST		=  4096 
CONSTANT long OFN_CREATEPROMPT		=  8192 
CONSTANT long OFN_SHAREAWARE			=  16384 
CONSTANT long OFN_NOREADONLYRETURN		=  32768 
CONSTANT long OFN_NOTESTFILECREATE		=  65536 
CONSTANT long OFN_NONETWORKBUTTON		=  131072 
CONSTANT long OFN_NOLONGNAMES		=  262144 
CONSTANT long OFN_EXPLORER			=  524288 
CONSTANT long OFN_NODEREFERENCELINKS	=  1048576 
CONSTANT long OFN_LONGNAMES			=  2097152 

// *****************************************************************
// Print dialog public members
// *****************************************************************
integer FromPage	=  1 
integer ToPage	=  1 
integer MinPage 	=  1 
integer MaxPage 	=  0 
PROTECTEDWRITE integer Copies =  1  

// Flags constants
CONSTANT long PD_ALLPAGES			=  0 
CONSTANT long PD_SELECTION 			=  1 
CONSTANT long PD_PAGENUMS 			=  2 
CONSTANT long PD_NOSELECTION 			=  4 
CONSTANT long PD_NOPAGENUMS 			=  8 
CONSTANT long PD_COLLATE			=  16 
CONSTANT long PD_PRINTTOFILE 			=  32 
CONSTANT long PD_PRINTSETUP 			=  64 
CONSTANT long PD_NOWARNING 			=  128 
CONSTANT long PD_RETURNDC 			=  256 
CONSTANT long PD_RETURNIC 			=  512 
CONSTANT long PD_RETURNDEFAULT	 	=  1024 
CONSTANT long PD_SHOWHELP 			=  2048 
CONSTANT long PD_ENABLEPRINTHOOK 		=  4096 
CONSTANT long PD_ENABLESETUPHOOK 		=  8192 
CONSTANT long PD_ENABLEPRINTTEMPLATE 	=  16384 
CONSTANT long PD_ENABLESETUPTEMPLATE	=  32768 
CONSTANT long PD_ENABLEPRINTTEMPLATEHANDLE	=  65536 
CONSTANT long PD_ENABLESETUPTEMPLATEHANDLE =  131072 
CONSTANT long PD_USEDEVMODECOPIES 		=  262144 
CONSTANT long PD_USEDEVMODECOPIESANDCOLLATE=  262144 
CONSTANT long PD_DISABLEPRINTTOFILE		=  524288  
CONSTANT long PD_HIDEPRINTTOFILE		=  1048576  
CONSTANT long PD_NONETWORKBUTTON 		=  2097152 

// *****************************************************************
// Font dialog public members
// *****************************************************************
long RGBColors	=  0 
integer FontType	=  0 
integer SizeMin	=  0 
integer SizeMax	=  0 
string FaceName	= ""
long  Height	=  0 
long  Weight	=  0 
boolean Italic	= False
boolean Underline	= False
boolean StrikeOut	= False

// Flags constants
CONSTANT long CF_SCREENFONTS 			=  1 
CONSTANT long CF_PRINTERFONTS 			=  2 
CONSTANT long CF_BOTH 				=  3 
CONSTANT long CF_SHOWHELP 			=  4 
CONSTANT long CF_ENABLEHOOK 			=  8 
CONSTANT long CF_ENABLETEMPLATE 		=  16 
CONSTANT long CF_ENABLETEMPLATEHANDLE 	=  32 
CONSTANT long CF_INITTOLOGFONTSTRUCT 		=  64 
CONSTANT long CF_USESTYLE 			=  128 
CONSTANT long CF_EFFECTS 			=  256 
CONSTANT long CF_APPLY 				=  512 
CONSTANT long CF_ANSIONLY 			=  1024 
CONSTANT long CF_SCRIPTSONLY 			= CF_ANSIONLY
CONSTANT long CF_NOVECTORFONTS 		=  2048 
CONSTANT long CF_NOOEMFONTS 			=  4096 
CONSTANT long CF_NOSIMULATIONS 		=  8192 
CONSTANT long CF_LIMITSIZE			=  16384 
CONSTANT long CF_FIXEDPITCHONLY 		=  32768 
CONSTANT long CF_WYSIWYG 			=  65536 
CONSTANT long CF_FORCEFONTEXIST 		=  131072 
CONSTANT long CF_SCALABLEONLY			=  262144 
CONSTANT long CF_TTONLY 			=  524288 
CONSTANT long CF_NOFACESEL			=  1048576 
CONSTANT long CF_NOSTYLESEL 			=  2097152  
CONSTANT long CF_NOSIZESEL 			=  4194304 
CONSTANT long CF_SELECTSCRIPT 			=  8388608 
CONSTANT long CF_NOSCRIPTSEL 			=  16777216 
CONSTANT long CF_NOVERTFONTS 			=  33554432 

// FontType constants
CONSTANT integer BOLD_FONTTYPE 	=  256 
CONSTANT integer ITALIC_FONTTYPE 	=  512 
CONSTANT integer REGULAR_FONTTYPE 	=  1024 
CONSTANT integer SCREEN_FONTTYPE 	=  8192 
CONSTANT integer PRINTER_FONTTYPE 	=  16384 
CONSTANT integer SIMULATED_FONTTYPE 	=  32768 

// Object private constants
Private:
CONSTANT integer LMEM_ZEROINIT =  64  // Alloc constant => Zero allocated memort

// Open Dialog Special Constants
CONSTANT integer MAXFILENAME     =  260 
CONSTANT integer MAXPATHNAME   =  260 
CONSTANT integer MAXFILES   =  100 

// EnumPrinters constants
constant ulong PRINTER_ENUM_FLAGS =  14 
constant ulong SIZE_PRINTER_INFO_5 =  20 
constant ulong  PRINTER_ENUM_NAME =  8 
end variables

forward prototypes
public function boolean opendialog ()
public function boolean printdialog ()
public subroutine setprinter (string printername, string driver, string port)
public function boolean savedialog ()
public function boolean fontdialog ()
end prototypes

public function boolean opendialog ();
 /*
This function displays the open dialog box available in the COMDLG32 library..

Members available:

string Filter			=> This member allows to specify a list of tab separated filters;
integer FilterIndex	=> Default filter index
string InitialDir		=> Default directory (for the dialog box)
string Title			=> Dialog title
long Flags				=> Dialog Flags
string Filename 		=> returns selected file
string Files[]			=> Array with the list of selected files
string PathName		=> Path of the files
integer FileCount		=> Number of selected files
*/ 

OPENFILENAME OpenFileName
string ls_Token, Empty[]
integer li_TabPos, li_Start

OpenFileName.lStructSize	=  76 
OpenFileName.hWndOwner		= Handle(w_hidden) //hWndParent
OpenFileName.hInstance		=  0 
OpenFileName.lpstrFilter	= LocalAlloc(LMEM_ZEROINIT,Len(Filter) +  2 ) //  2  nulls to signal end
If OpenFileName.lpstrFilter =  0  Then
	MessageBox("Error","Cannot alloc requested memory!",StopSign!,Ok!)
	Return(False)
End If

// Tab separator to Null separator 
li_Start  =  1 
li_TabPos = Pos(Filter,"~t", 1 )
Do While li_TabPos >  0 
	ls_Token = Mid(Filter,li_Start,li_TabPos - li_Start)
	StrCopy(OpenFileName.lpstrFilter + (li_Start -  1 ),ls_Token,Len(ls_Token))
	li_Start		= li_TabPos +  1 
	li_TabPos	= Pos(Filter,"~t",li_TabPos +  1 )
Loop
ls_Token	= Mid(Filter,li_Start)
StrCopy(OpenFileName.lpstrFilter + (li_Start -  1 ),ls_Token,Len(ls_Token))

OpenFileName.lpstrCustomFilter	=  0 
OpenFileName.nMaxCustomFilter		=  0 
OpenFileName.nFilterIndex 			= FilterIndex
OpenFileName.lpstrFile				= LocalAlloc(LMEM_ZEROINIT,MAXFILENAME * MAXFILES) 
OpenFileName.nMaxFile				= MAXFILENAME * MAXFILES
OpenFileName.lpstrFileTitle		= LocalAlloc( 0 ,MAXFILENAME)
OpenFileName.nMaxFileTitle			= MAXFILENAME
OpenFileName.lpstrInitialDir		= LocalAlloc( 0 ,MAXPATHNAME)
StrCopy(OpenFileName.lpstrInitialDir,InitialDir,Len(InitialDir))
OpenFileName.lpstrTitle				= LocalAlloc( 0 , 255 )
StrCopy(OpenFileName.lpstrTitle,Title,Len(Title))

//string ls_testfilename
//ls_testfilename = "Philip"
//StrCopy(OpenFileName.lpstrFile,ls_testfilename,Len(ls_testfilename))


OpenFileName.Flags					= Flags
OpenFileName.nFileOffSet			=  0 
OpenFileName.nFileExtension		=  0 
OpenFileName.lpstrDefExt			=  0 
OpenFileName.lCustData				=  0 
OpenFileName.lpfnHook				=  0 
OpenFileName.lpTemplateName		=  0 

Files = Empty // Reset array
FileCount =  0 

If GetOpenFileNameA(OpenFileName) =  1  Then // Pressed OK button
	PathName = Left(String(OpenFileName.lpstrFile,"address"),OpenFileName.nFileOffSet -  1 )
	li_Start =  0 
	Do
		ls_Token = String(OpenFileName.lpstrFile + OpenFileName.nFileOffSet + li_Start,"address")
		If ls_Token <> "" Then
			FileCount++
			Files[FileCount] = ls_Token
		End If
		li_Start += Len(ls_Token) +  1 
	Loop Until ls_Token = ""
	FileName = Files[ 1 ]
Else
	FileName  = ""
	FileCount =  0 
End If

LocalFree(OpenFileName.lpstrFilter)
LocalFree(OpenFileName.lpstrFile)
LocalFree(OpenFileName.lpstrFileTitle)
LocalFree(OpenFileName.lpstrTitle)
LocalFree(OpenFileName.lpstrInitialDir)

Return(FileCount >  0 )
end function

public function boolean printdialog (); /*

Shows the print dialog box... 

Members:

integer FromPage	// Print from page
integer ToPage		// Print to page
integer MinPage	// Min page (smaller page)
integer MaxPage	// Max page (higher page)
PROTECTEDWRITE integer Copies = 1 // Nº of copies to print...

*/ 

PRINTDLG PrintDlg
DEVMODE DevMode
DEVNAMES DevNames
long pDevNames, pDevMode

PrintDlg.lStructSize 	=  66 
PrintDlg.hWndOwner		= hWndParent
PrintDlg.hDevMode			=  0 
PrintDlg.hDevNames		=  0 
PrintDlg.hDC				=  0 
PrintDlg.Flags				= Flags
PrintDlg.nFromPage		= FromPage
PrintDlg.nToPage			= ToPage
PrintDlg.nMinPage			= MinPage
PrintDlg.nMaxPage			= MaxPage
PrintDlg.nCopies			=  0 
PrintDlg.hInstance		=  0 
PrintDlg.lCustData		=  0 
PrintDlg.lpfnPrintHook	=  0 
PrintDlg.lpfnSetupHook	=  0 
PrintDlg.lpPrintTemplateName =  0 
PrintDlg.lpSetupTemplateName =  0 
PrintDlg.hPrintTemplate	=  0 
PrintDlg.hSetupTemplate =  0 

If PrintDlgA(PrintDlg) =  1  Then

	pDevMode = LocalLock(PrintDlg.hDevMode)
	GetDevMode(DevMode,pDevMode, 148 ) // Lock dynamic memory handle
	LocalUnlock(pDevMode) // Unlock dynamic memory handle

	pDevNames = LocalLock(PrintDlg.hDevNames)
	GetDevNames(DevNames,pDevNames, 8 ) // Lock dynamic memory handle
	LocalUnlock(pDevNames) // Unlock dynamic memory handle

	FromPage	= PrintDlg.nFromPage
	ToPage	= PrintDlg.nToPage
	MinPage 	= PrintDlg.nMinPage
	MaxPage 	= PrintDlg.nMaxPage
	Copies	= PrintDlg.nCopies
	
	If Copies =  1  Then // Copies are provided by devmode..
		Copies = DevMode.dmCopies
	End If

	SetPrinter(String(pDevNames + DevNames.wDeviceOffset,"address"), &
				  String(pDevNames + DevNames.wDriverOffset,"address"), &
				  String(pDevNames + DevNames.wOutPutOffset,"address"))

	Return(True)

End If	
	
Return(False)

end function

public subroutine setprinter (string printername, string driver, string port);// Function used to set the default printer based on the choice maded on the print 
// dialog box..
// Arguments:

// PrinterName => Name of the new printer
// Driver => Driver of the new printer
// Port => Port of the new printer

Environment Env
string ls_WinDir

GetEnvironment(Env)

Choose Case Env.OSType
	Case Windows!
		RegistrySet("HKEY_LOCAL_MACHINE\Config\0001\System\CurrentControlSet\Control\Print\Printers", "Default", PrinterName)
		ls_WinDir = Space( 260 )
		GetWindowsDirectoryA(ls_WinDir, 260 ) // GetWindows directory
		SetProfileString(ls_WinDir + "\WIN.INI","Windows","Device",PrinterName + "," + Driver + "," + Port)
	Case WindowsNT!
		RegistrySet("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device", PrinterName + "," + Driver + "," + Port)
End Choose
end subroutine

public function boolean savedialog ();
 /*
This function displays the save dialog box available in the COMDLG32 library..

Members available:

string Filter			=> This member allows to specify a list of tab separated filters;
integer FilterIndex	=> Default filter index (returns the selected filter)
string InitialDir		=> Default directory (for the dialog box)
string Title			=> Dialog title
long Flags				=> Dialog Flags
string Filename 		=> returns selected file
string Files[]			=> Array with the list of selected files
string PathName		=> Path of the files
integer FileCount		=> Number of selected files
*/ 

OPENFILENAME SaveFileName
string ls_Token, Filters[]
integer li_TabPos, li_Start

SaveFileName.lStructSize	=  76 
SaveFileName.hWndOwner		= hWndParent
SaveFileName.hInstance		=  0 
SaveFileName.lpstrFilter	= LocalAlloc(LMEM_ZEROINIT,Len(Filter) +  2 ) //  2  nulls to signal end
If SaveFileName.lpstrFilter =  0  Then
	MessageBox("Error","Cannot alloc requested memory!",StopSign!,Ok!)
	Return(False)
End If

// Tab separator to Null separator 
li_Start  =  1 
li_TabPos = Pos(Filter,"~t", 1 )
Do While li_TabPos >  0 
	ls_Token = Mid(Filter,li_Start,li_TabPos - li_Start)
	StrCopy(SaveFileName.lpstrFilter + (li_Start -  1 ),ls_Token,Len(ls_Token))
	li_Start		= li_TabPos +  1 
	li_TabPos	= Pos(Filter,"~t",li_TabPos +  1 )
	Filters[UpperBound(Filters) +  1 ] = Mid(ls_Token, 2 )
Loop
ls_Token	= Mid(Filter,li_Start)
StrCopy(SaveFileName.lpstrFilter + (li_Start -  1 ),ls_Token,Len(ls_Token))

SaveFileName.lpstrCustomFilter	=  0 
SaveFileName.nMaxCustomFilter		=  0 
SaveFileName.nFilterIndex 			= FilterIndex
SaveFileName.lpstrFile				= LocalAlloc(LMEM_ZEROINIT,MAXFILENAME) 
SaveFileName.nMaxFile				= MAXFILENAME
SaveFileName.lpstrFileTitle		= LocalAlloc( 0 ,MAXFILENAME)
SaveFileName.nMaxFileTitle			= MAXFILENAME
SaveFileName.lpstrInitialDir		= LocalAlloc( 0 ,MAXPATHNAME)
StrCopy(SaveFileName.lpstrInitialDir,InitialDir,Len(InitialDir))
SaveFileName.lpstrTitle				= LocalAlloc( 0 , 255 )
StrCopy(SaveFileName.lpstrTitle,Title,Len(Title))
SaveFileName.Flags					= Flags
SaveFileName.nFileOffSet			=  0 
SaveFileName.nFileExtension		=  0 
SaveFileName.lpstrDefExt			=  0 
SaveFileName.lCustData				=  0 
SaveFileName.lpfnHook				=  0 
SaveFileName.lpTemplateName		=  0 

If GetSaveFileNameA(SaveFileName) =  1  Then // Pressed OK button
	PathName = Left(String(SaveFileName.lpstrFile,"address"),SaveFileName.nFileOffSet -  1 )
	FileName = String(SaveFileName.lpstrFile + SaveFileName.nFileOffSet,"address")
	If SaveFileName.nFileExtension = Len(PathName) + Len(FileName) +  1  Then
		FileName += Filters[ 2  * SaveFileName.nFilterIndex]
	End If
Else
	FileName  = ""
End If

LocalFree(SaveFileName.lpstrFilter)
LocalFree(SaveFileName.lpstrFile)
LocalFree(SaveFileName.lpstrFileTitle)
LocalFree(SaveFileName.lpstrTitle)
LocalFree(SaveFileName.lpstrInitialDir)

Return(FileName <> "")
end function

public function boolean fontdialog ();
 /*
This function displays the font dialog box available in the COMDLG32 library..

Members:

integer FontType
integer SizeMin
integer SizeMax
string FaceName
long  Height
long  Weight
boolean Italic
boolean Underline
boolean StrikeOut

*/ 
CHOOSEFONT ChooseFont
LOGFONT	LogFont
boolean lb_Result

If Flags =  0  Then Flags = CF_FORCEFONTEXIST + CF_BOTH + CF_EFFECTS + CF_INITTOLOGFONTSTRUCT

LogFont.lfFaceName	= FaceName
LogFont.lfHeight		= Height
LogFont.lfWeight		= Weight
If Italic Then LogFont.lfItalic = Char( 255 ) Else LogFont.lfItalic = Char( 0 )
If Underline Then LogFont.lfUnderline = Char( 1 ) Else LogFont.lfUnderline = Char( 0 )
If StrikeOut Then LogFont.lfStrikeOut = Char( 1 ) Else LogFont.lfStrikeOut = Char( 0 )
long ll
SetNull(ll)
ChooseFont.lStructSize	=  60 
ChooseFont.hWndOwner		= hWndParent
ChooseFont.hDC				=  0 
ChooseFont.lpLogFont		= LocalAlloc( 0 , 60 )
PutLogFont(ChooseFont.lpLogFont,LogFont, 60 )
ChooseFont.iPointSize	=  0 
ChooseFont.Flags			= Flags
ChooseFont.RGBColors		= RGBColors
ChooseFont.lCustData		=  0 
ChooseFont.lpfnHook		=  0 
ChooseFont.lpTemplateName	=  0 
ChooseFont.hInstance 	=  0 
ChooseFont.lpszStyle 	=  0 
ChooseFont.nFontType 	= FontType
ChooseFont.nSizeMin 		= SizeMin
ChooseFont.nSizeMax 		= SizeMax

If ChooseFontA(ChooseFont) =  1  Then
	GetLogFont(LogFont,ChooseFont.lpLogFont, 60 )

	FontType	= ChooseFont.nFontType
	FaceName	= LogFont.lfFaceName
	Height	= LogFont.lfHeight
	Weight	= LogFont.lfWeight
	Italic	= (Asc(LogFont.lfItalic) 	 =  255 )
	Underline= (Asc(LogFont.lfUnderline) =  1 )
	StrikeOut= (Asc(LogFont.lfStrikeOut) =  1 )

	lb_Result = True
Else
	FontType	=  0 
	FaceName	= ""
	Height	=  0 
	Weight	=  0 
	Italic	= False
	Underline= False
	StrikeOut= False
	lb_Result = False
End If

LocalFree(ChooseFont.lpLogFont)

Return(lb_Result)

end function

on nvo_commdlg.create
TriggerEvent( this, "constructor" )
end on

on nvo_commdlg.destroy
TriggerEvent( this, "destructor" )
end on

В окошке на кнопке пишешь:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
nvo_commdlg Dialogs
integer li_Files

Dialogs.hWndParent	= Handle(parent)
Dialogs.Title			= "Export"
Dialogs.Filter			= "Export to SQL (*.sql)~t*.SQL~tExport to ANSI (*.ans)~t*.ANS~tExport to ASCII (*.asc)~t*.ASC"
Dialogs.FilterIndex	=  1 
Dialogs.InitialDir	= "C:\"
Dialogs.Flags			= Dialogs.OFN_EXPLORER + Dialogs.OFN_LONGNAMES + Dialogs.OFN_PATHMUSTEXIST

If Dialogs.SaveDialog() Then
	MessageBox("FileTitle",Dialogs.PathName + "\" + Dialogs.FileName)
End If

И любуешся...
...
Рейтинг: 0 / 0
как вызвать модное окно выбора файлов? (а-ля офис ХР?)
    #32636479
roleks
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Филипп, большое спасибо!
Именно то что нужно!
...
Рейтинг: 0 / 0
Период между сообщениями больше года.
как вызвать модное окно выбора файлов? (а-ля офис ХР?)
    #38292227
Двоичник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
подскажите, пожалуйста, а можно ли этот диалог использовать для множественного выбора файлов? как?
спасибо
...
Рейтинг: 0 / 0
как вызвать модное окно выбора файлов? (а-ля офис ХР?)
    #38293086
Фотография PL99
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Двоичникподскажите, пожалуйста, а можно ли этот диалог использовать для множественного выбора файлов? как?
спасибоВидимо, надо взвести флаг
Код: plaintext
1.
CONSTANT long OFN_ALLOWMULTISELECT		= 512
...
Рейтинг: 0 / 0
Период между сообщениями больше года.
как вызвать модное окно выбора файлов? (а-ля офис ХР?)
    #39355713
Valdas
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Я нашел еще один хороший пример http://www.topwizprogramming.com/freecode_getfilename.html, если кто-то нуждается в нем.
...
Рейтинг: 0 / 0
8 сообщений из 8, страница 1 из 1
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / как вызвать модное окно выбора файлов? (а-ля офис ХР?)
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]