CommonDialogs Plugin

Description

AMSWCommonDialogs is an action plugin that have some common dialogs.

Actions

CommonDialogs.Color
CommonDialogs.File
CommonDialogs.Font
CommonDialogs.PickIcon
CommonDialogs.Close

CommonDialogs.Color(number DefaultColor);

Description:

Opens the standard requester to choose a color. The chosen color is returned under a 24 bit number containing the red, green and blue value, as usual.

DefaultColor:

(number) DefaultColor.

Returns:

A table containing some field that stored some information of selected color. fields are ('R', 'G', 'B', 'Dec').If the user cancels the operation (presses the cancel button), nil will be returned instead of table.

Example:

result = CommonDialogs.Color(1024);

if result ~= nil then
 Dialog.Message("Color", "Red: "..result.R.."\r\nGreen: "..result.G.."\r\nBlue: "..result.B.."\r\nDecimal: "..result.Dec);
end

CommonDialogs.File(boolean FileOpen = true, string Title, string DefaultFolder, string FileFilters, string Filename, string FileExtension, boolean MultipleSelect = false);

Description:

Presents a file browse dialog to the user to collect the paths to one or more files.

FileOpen:

(boolean) Whether to make the dialog a "file open" dialog.

Title:

(string) The text to be displayed on the dialog title bar.

DefaultFolder:

(string) The default folder to browse.

FileFilters:

(string) The file type filters that will be used in the browse. Defaults to "All Files (*.*)|*.*|".

Filename:

(string) The file name that initially appears in the file name edit box.

FileExtension:

(string) The default file extension. This will be appended to the filename in the file name edit box if the user does not supply an extension.

MultipleSelect:

(boolean) Whether to allow multiple selection of files.

Returns:

(strin) this function return a string containing file(s) with Delimiter ("|") for convert it into table you must use some function like "DelimitedStringToTable", if user presed cancel function return "CANCEL". for more perception See below example.

Example1:

function DelimitedStringToTable(DelimitedString, Delimiter)
	tbReturn = {};
	local strWorking;
	local nPos = nil;
	local strData;
	local nTableIndex = 1;
	local nDelimiterLength = String.Length(Delimiter);
	
	if(nDelimiterLength < 1)then
		tbReturn[nTableIndex] = DelimitedString;
		return tbReturn;
	end
	
	strWorking = DelimitedString;
	nPos = String.Find(strWorking,Delimiter);
	while(nPos ~= -1)do
		strData = String.Left(strWorking,nPos-1);
		tbReturn[nTableIndex] = strData;
		nTableIndex = nTableIndex + 1;
		local nLength = String.Length(strWorking);
		strWorking = String.Right(strWorking,nLength - (nPos + (nDelimiterLength-1)));
		nPos = String.Find(strWorking,Delimiter);
	end
	if(strWorking ~= "")then
		tbReturn[nTableIndex] = strWorking;
	end
	
	return tbReturn;
end

files = CommonDialogs.File(true, "Open File", _ProgramFilesFolder, "Text File (*.txt)|*.txt|All Files(*.*)|*.*|", "", "txt", true);

if files ~= "CANCEL" then
 files = DelimitedStringToTable(files, "|")
 Debug.Clear()
 Debug.ShowWindow(true)
 for a, b in files do
 	Debug.Print(b.."\r\n")
 end
end

Example2:

files = CommonDialogs.File(false, "Save File", _ProgramFilesFolder, "Text File (*.txt)|*.txt|All Files(*.*)|*.*|", "", "", false);

if files ~= "CANCEL" then
 Debug.Clear()
 Debug.ShowWindow(true)
 Debug.Print(files)
end

CommonDialogs.Font(string DefaultName, number DefaultSize, boolean ShowColor = false);

Description:

Opens the standard requester to choose a font.

DefaultName:

(string) DefaultName of Font.

DefaultSize:

(number) DefaultSize of font.

ShowColor:

(boolean) if this parameter is true then color box is shown in font dialog.

Returns:

A table containing some field that stored some information of selected Font. fields are ('Name', 'Size', 'Regular', 'Italic', 'Bold', 'StrikeOut', 'Underline', 'Color').If the user cancels the operation (presses the cancel button), nil will be returned instead of table.

Example:

result = CommonDialogs.Font("Arial", 12, true);

if result ~= nil then
 Debug.Clear()
 Debug.ShowWindow(true)
 Debug.Print("Font Name is "..result.Name.."\r\n")
 Debug.Print("Font Size is "..result.Size.."\r\n")
 if result.Regular == true then
 	Debug.Print("Font is Regular\r\n")
 end
 if result.Italic == true and result.Bold == false then
 	Debug.Print("Font is Italic\r\n")
 end
 if result.Bold == true and result.Italic == false then
 	Debug.Print("Font is Bold\r\n")
 end
 if result.Bold == true and result.Italic == true then
 	Debug.Print("Font is Bold Italic\r\n")
 end
 if result.StrikeOut == true then
 	Debug.Print("Font is StrikeOut\r\n")
 end
 if result.Underline == true then
 	Debug.Print("Font is Underline\r\n")
 end
 if result.Color ~= nil then
 	Debug.Print("Font Color is "..result.Color.."\r\n")
 end

end

CommonDialogs.PickIcon(string FileName, number Index, string Extract);

Description:

Opens the standard requester to choose an icon in a moudle.(dll, exe, sys, ...)

FileName:

(string) File That you want open it.

Index:

(number) index of .

Extract:

(string) Address of Extracted icon(if you want icon not extracted just fill it blank "").

Returns:

two variable one string for File Path and one number for index of icon that selected, if user select Cancel First Variable is CANCEL.(See Example)

Example:

-- two vaiable : 
-- 1st return variable filen string : filen
-- 2st return variable filen number : index
filen, index  = CommonDialogs.PickIcon("C:\\windows\\system32\\shell32.dll", 1, "");
if filen ~= "CANCEL" then
  Dialog.Message("", filen.. "," .. index)
end

CommonDialogs.Close();

Description:

Close Application (On Windows Vista Required, use it on XP is optional but we recomonded it on all os).

Returns:

Nothing.

Note:

use this function important on windows vista, Use this function in the end of your codes in 'On Close' of Page, use this function in the end of your codes this is important because codes after this function never executed.

Example:

-- On Close
-- Some code
-- Some code
-- Some code

CommonDialogs.Close()

Change Log

1.0.1.0

1.0.0.0

Additional Information

Author:

AMSWaves Corporation
support@AMSWaves.com

Copyright:

Plugin is copyright © 2008-2009 AMSWaves Design Corporation.

Website:

http://www.AMSWaves.com


Copyright © 2009 AMSWaves Design Corporation.
All Rights Reserved.