From: Thomas, T. B <tim...@lm...> - 2001-01-20 00:25:52
|
Here's the code that you all helped me to figure out. You can use this = to implement a clickable URL in your About Window, or whereever you like. = The code may not be very clean, let me know if you have suggestions to = improve this. This example runs as-is. Aldo - any way to build all this in to the GUI Module and just have a = -URL option on the label? or a separate object? Thanks everyone! Tim Thomas use Win32; use Win32::GUI; use Win32::Process; $title=3D'TestTool'; $author=3D'T. Thomas'; $contact=3D'tt...@co...'; $contacturl=3D'www.coloradonarwhal.com'; $version=3D"1.0"; $date=3D'January 2001'; my $AboutWindow =3D new GUI::Window(-title=3D>"About $title...", = -left=3D>110, -top=3D>110, -width=3D>230, -height=3D>150, -name=3D>"AboutWindow",); my $AboutTitleFont =3D new Win32::GUI::Font(-name =3D> "Times New Roman", -height =3D> 20, -bold =3D> 1); my $AboutFont =3D new Win32::GUI::Font(-name =3D> "Times New Roman", -height =3D> 15); my $URLFont =3D new Win32::GUI::Font(-name =3D> "Times New Roman", -height =3D> 15, -underline =3D> 1); my $AboutTitle =3D $AboutWindow->AddLabel( -top =3D> 13, -left = =3D> 5, -height =3D> 32, -width =3D> $AboutWindow->ScaleWidth-10, = -name =3D> "AboutTitle", -text =3D> "$title Version $version", -font =3D> $AboutTitleFont,); my $AboutDetails =3D $AboutWindow->AddLabel( -top =3D> 32, -left =3D> 5, -height =3D>15*3, -width =3D> = $AboutWindow->ScaleWidth-10, -name =3D> "AboutDetails", -text=3D>"Author: $author\r\nContact: = $contact\r\nDate: $date\r\n\r\n", -font =3D> $AboutFont); my $AboutURL =3D $AboutWindow->AddLabel( -top =3D>(32+$AboutDetails->Height), -left =3D> 5, -height =3D> = $URLFont->Height, -width =3D> $AboutWindow->ScaleWidth-10, -name =3D> "AboutURL", -text=3D>"$contacturl", -font =3D> $URLFont, -notify =3D> 1, = -foreground =3D>[0,0,255]); my $AboutOK =3D $AboutWindow->AddButton(-left =3D> 0, -top =3D> 0, -text =3D> " OK ", -name =3D> "AboutOK", -visible =3D> 1, = -default =3D> 1, -ok =3D> 1,); =09 $AboutOK->Move($AboutWindow->ScaleWidth-$AboutOK->Width,$AboutWindow->Sc= aleH eight-$AboutOK->Height,); $AboutWindow->Show(); Win32::GUI::Dialog(); #-----------------------------------------------------------------------= ---- ----------------------------------------------- sub AboutOK_Click { $AboutWindow->Hide(); exit; } sub AboutWindow_Terminate { AboutOK_Click(); return 0; } sub AboutURL_Click { if ($ftype=3Dgetftype(".html")) { $ftype=3D~s/"//g; ($ftypeexe)=3D$ftype=3D~/^.*\\(.*\.exe)$/i; my ($process); Win32::Process::Create($process,$ftype,"$ftypeexe $contacturl",0,DETACHED_PROCESS,".") || warn "Create: $!"; } } sub getftype { use Win32::TieRegistry; if (my ($ext) =3D @_) { if (my $typeName =3D $Registry->{"HKEY_CLASSES_ROOT\\$ext\\\\"}) { if (my $command =3D $Registry->{"HKEY_CLASSES_ROOT\\$typeName\\shell\\open\\command\\\\"}) { my ($cmd); unless (($cmd) =3D $command=3D~/^(".*")\s+.*$/) { ($cmd) =3D $command=3D~/^(\S*)\s/; } return $cmd; } else { return 0; } } else { return 0; } } else { return 0; } } ------------------------------------------------------------------------= ---- --------------------- Tim Thomas Unix Systems Administrator Lockheed Martin EIS =B7 Denver Data Center 303-430-2281 mailto:tim...@lm... ------------------------------------------------------------------------= ---- --------------------- |