![]() | Programming Guide | WideStudio Index Table of contents |
文件选择对话窗
显示文件选择对话窗
这里,我们将介绍文件选择对话窗的用法。对于文件选择对话窗,提供有便利的popup函数。popup函数,不仅显示对话窗,还可以用函数返回操作者选择OK和解除等的结果。因此,虽然叫函数,却能实现对话窗的显示,以及取得对话窗的结束时的选择结果。以下是使用文件选择对话窗和消息对话窗的实际范例程序。
[文件选择对话窗]#---------------------------------------------------------- #Function for the event procedure #---------------------------------------------------------- use mpfc; sub btnep2 { my ($object) = @_; # Access to the global instance of the WSCfileSelect class. $fs = mpfc::WSGIappFileSelect(); #(A) mpfc::WSCbase_setProperty($fs,"maskFileName","pl"); #(B) mpfc::WSCbase_setProperty($fs,"defaultPosition",$mpfc::True); #(C) $ret = mpfc::WSCbaseDialog_popup($fs); #(D) #Access to the global instance of the WSCmessageDialog class. $msg = mpfc::WSGIappMessageDialog(); #(E) mpfc::WSCbase_setProperty($msg,"width",500); #(F) mpfc::WSCbase_setProperty($msg,"height",120); #(G) mpfc::WSCbase_setProperty($msg,"defaultPosition",$mpfc::True); #(H) if ($ret == $mpfc::WS_DIALOG_OK){ #(I) $str = sprintf("%s is selected.", mpfc::WSCfileSelect_getFileName($fs) ); mpfc::WSCbase_setProperty($msg,"labelString",$str); mpfc::WSCbaseDialog_popup($msg); }elsif ($ret == $mpfc::WS_DIALOG_NO){ #(J) mpfc::WSCbase_setProperty($msg,"labelString","Nothing is selected."); mpfc::WSCbaseDialog_popup($msg); }elsif (ret == mpfc.WS_DIALOG_CANCEL){ #(K) mpfc::WSCbase_setProperty($msg,"labelString","The selection is canceled."); mpfc::WSCbaseDialog_popup($msg); } return; } 1;(A)使用Global Instance访问文件选择对话窗的Global Instance。在文件选择对话窗等的Class中,预先都备有1个Global Instance。于是,可以使用Global Instance访问函数进行访问。
在(B),(C)处设定属性,并在(D)处将对话窗变为显示状态。当被选择时,popup函数将返回。
使用消息对话窗显示文件选择对话窗的选择结果。在(E),(F),(G),(H)处,取得消息对话窗的Global Instance,并设定属性。
在(I)处,被选择的文件将作为消息字符串显示。 在(J)处,显示说明没有文件被选择的消息字符串。 在(K)处,显示已被解除的消息字符串。
Copyright(C) T. Hirabayashi, 2000-2004 | Last modified: Feb 25, 2004 |