From: Maxmelbin N. (RBIN/EMT1) <Max...@in...> - 2007-07-11 09:15:57
|
Hello , How do I use DialogUI method to make my Window take "Tabs" etc .... use Win32::GUI; use Win32::GUI::GridLayout; $main =3D Win32::GUI::DialogBox->new(-name =3D> 'Main', -text =3D> 'Perl Win32 GUI', -width =3D> 550, -height =3D> 650, -maximizebox =3D> 0, ); $worktext =3D $main->AddTextfield( -width =3D> 300, -height =3D> 26, -left =3D> 20, -top =3D> 20, -readonly =3D> 0, -position =3D> bottom, -text =3D> $sel3, ); $filetext =3D $main->AddTextfield( -name =3D> "list_file", -width =3D> 300, -height =3D> 26, -left =3D> 20, -top =3D> 90, -readonly =3D> 0, -position =3D> bottom, -text =3D> $sel3, ); $main->Show(); Win32::GUI::Dialog(); Thanks and Regards Maxmelbin Neson ------------------------------------------------------------------------ ----------------------------------------- Robert Bosch India Limited Engineering Services - DS - Methods and Tools (RBIN/EMT1) 123 Industrial Layout - Hosur Road - Bangalore 560 095 - INDIA Telephone: +91 80 6657-4532 Fax: +91 80 6657-1404 max...@in... www.bosch.com |
From: Geoffrey S. <geo...@gm...> - 2007-07-11 11:11:43
|
You need to add -tabstop =3D> 1, to the options for any control that you want to be able to select with tab. On 7/11/07, Maxmelbin Neson (RBIN/EMT1) <Max...@in...> wrot= e: > > > > > Hello , > > How do I use DialogUI method to make my Window take "Tabs" etc =85. > > use Win32::GUI; > use Win32::GUI::GridLayout; > > $main =3D Win32::GUI::DialogBox->new(-name =3D> 'Main', > -text =3D> 'Perl Win32 GUI', > -width =3D> 550, > -height =3D> 650, > -maximizebox =3D> 0, > ); > > $worktext =3D $main->AddTextfield( > -width =3D> 300, > -height =3D> 26, > -left =3D> 20, > -top =3D> 20, > -readonly =3D> 0, > -position =3D> bottom, > -text =3D> $sel3, > ); > > > $filetext =3D $main->AddTextfield( > -name =3D> "list_file", > -width =3D> 300, > -height =3D> 26, > -left =3D> 20, > -top =3D> 90, > -readonly =3D> 0, > -position =3D> bottom, > -text =3D> $sel3, > ); > > $main->Show(); > Win32::GUI::Dialog(); > > Thanks and Regards > Maxmelbin Neson > -------------------------------------------------------------------------= ---------------------------------------- > Robert Bosch India Limited > Engineering Services - DS - Methods and Tools (RBIN/EMT1) > 123 Industrial Layout - Hosur Road - Bangalore 560 095 - INDIA > Telephone: +91 80 6657-4532 Fax: +91 80 6657-1404 > max...@in... > www.bosch.com > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > --=20 Geoffrey Spear http://www.geoffreyspear.com/ |
From: <a98...@gm...> - 2007-07-11 14:01:22
|
hi, I have a small program which can be minimized to the tray. Now I want to have an accelerator which fires to minimize the program to the tray => this works fine. But know I want to restore the window with an accelerator anytime. It should work if I'm writing a text or in internet explorer or firefox ... everytime. is this possible? how can I install the accelerator so that it can be activated? thx. juergen -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser |
From: Robert M. <rob...@us...> - 2007-07-11 21:34:57
|
On 11/07/07, a98...@gm... <a98...@gm...> wrote: > I have a small program which can be minimized to the tray. > Now I want to have an accelerator which fires to minimize the program to the > tray => this works fine. > But now I want to restore the window with an accelerator anytime. > It should work if I'm writing a text or in internet explorer or firefox ... everytime. > is this possible? > how can I install the accelerator so that it can be activated? Yes, it's possible, you'll find it discussed on this list if you search for WM_HOTKEY or WM_SETHOTKEY (these are 2 slightly different techniques. I'll attach some code that shows the WM_SETHOTKEY method to this mail - it doesn't quite meet your requirements, but it's close and can be done with Win32::GUI alone. I'll follow-up with code that uses the Win32 RegisterHotKey() function - I think it exactly meets what you want to do, but needs Win32::API() to call the functions that are missing from Win32::GUI. Regards, Rob. #!perl -w use strict; use warnings; # What this script does: # Creates a Window, and a notify icon. # Register a Hotkey (Ctrl-A) for the window. # When the window is minimised, it is not hidden. # Left-clicking on the notify icon, or pressing the # Hotkey combination will Show the window again. # In this example, we can't hide the window, as if we do, then # I can't find a suitable hook into the message system to know # when to show the window again. use Win32::GUI 1.05 qw( CW_USEDEFAULT WM_SETHOTKEY VK_A IDI_DEFAULTICON ); # Some constants missing from Win32::GUI::Constants sub HOTKEYF_SHIFT() {0x01} # Shift key sub HOTKEYF_CONTROL() {0x02} # Ctrl key sub HOTKEYF_ALT() {0x04} # Alt key sub HOTKEYF_EXT() {0x08} # Extended key (??) my $mw = Win32::GUI::Window->new( -title => 'HotKey demonstration', -left => CW_USEDEFAULT, -size => [400,300], ); my $icon = Win32::GUI::Icon->new(IDI_DEFAULTICON); $mw->AddNotifyIcon( -icon => $icon, -onClick => \&show_window, ); set_hotkey($mw, VK_A, HOTKEYF_CONTROL); $mw->Show(); Win32::GUI::Dialog(); sub show_window { my ($win) = @_; $win->Show(); return 0; } # Set the hotkey for a window (or replace it if this is called # more than once) sub set_hotkey { my ($win, $key, $modifier) = @_; # $win - any top level window # $key - any virtual keycode (VK_*) Esc, TAB, SPACE and a few others. # $modifier: any combination of the HOTKEYF_* constants (or 0 for no modifier) # Watch out. Despite what the MS documentation says the modifier # goes in the upper byte of a short, not the upper WORD of a # DWORD. I.e. the left shift is 8 bits, not 16 bits my $wParam = ($modifier << 8) + $key; # Set the hotkey for the window by sending a WM_SETHOTKEY # message. If successful pressing the hokey combination # results in a WM_SYSCOMMAND message being sent to the registered window # with wParam equl to SC_HOTKEY. DefWindowProc process this by bringing # the window to the foreground. my $ret = $win->SendMessage(WM_SETHOTKEY, $wParam, 0); if($ret == -1) { die('set_hotkey() failed to register the hotkey - invalid hotkey'); } elsif($ret == 0) { die('set_hotkey() failed to register the hotkey - invalid window'); } elsif($ret == 1) { # success } elsif($ret == 2) { warn('set_hotkey(): registered hotkey, but another window has the '. "same hotkey.\nThe window activated by the hotkey will be". "randomly selected\n"); } else { die('set_hotkey(): unexpected return value from WM_SETHOTKEY'); } return; } |
From: Robert M. <rob...@us...> - 2007-07-11 21:36:39
|
On 11/07/07, Robert May <rob...@us...> wrote: > On 11/07/07, a98...@gm... <a98...@gm...> wrote: > > I have a small program which can be minimized to the tray. > > Now I want to have an accelerator which fires to minimize the program to the > > tray => this works fine. > > But now I want to restore the window with an accelerator anytime. > > It should work if I'm writing a text or in internet explorer or firefox ... everytime. > > is this possible? > > how can I install the accelerator so that it can be activated? > > I'll attach some code that shows the WM_SETHOTKEY method to this mail > - it doesn't quite meet your requirements, but it's close and can be > done with Win32::GUI alone. I'll follow-up with code that uses the > Win32 RegisterHotKey() function - I think it exactly meets what you > want to do, but needs Win32::API() to call the functions that are > missing from Win32::GUI. This is the follow-up using RegisterHotKey() and WM_HOTKEY. It's a bit more complex than the last example: #!perl -w use strict; use warnings; # What this script does: # Creates a Window, and a notify icon. # Register a Hotkey (Ctrl-A) for the window. # When the window is minimised, it is hidden. # Left-clicking on the notify icon, or pressing the # Hotkey combination will Show the window again. # Pressing the HotKey when the window is visible # hides it. # We can't use WM_SETHOTKEY, as we never see any WM_SYSCOMMAND # once the window is hidden, so we use Win32::API to give # us access to RegisterHotKey/UnregisterHotKey and catch # the WM_HOTKEY messages to o our bidding. use Win32::API(); Win32::API->Import('user32', 'RegisterHotKey', 'LiII', 'I'); Win32::API->Import('user32', 'UnregisterHotKey', 'Li', 'I'); use Win32::GUI 1.05 qw( CW_USEDEFAULT WM_HOTKEY VK_A IDI_DEFAULTICON ); # Some constants missing from Win32::GUI::Constants sub MOD_ALT() {0x001} # Alt key sub MOD_CONTROL() {0x002} # Ctrl key sub MOD_SHIFT() {0x004} # Shift key sub MOD_WIN() {0x008} # Windows key my $HOTKEY_ID = 0x1234; # Any unique number for this app - need # a different number for each hotkey my $mw = Win32::GUI::Window->new( -title => 'HotKey demonstration', -left => CW_USEDEFAULT, -size => [400,300], -onMinimize => \&toggle_show_state, ); # We need to catch WM_HOTKEY messages $mw->Hook(WM_HOTKEY, \&handle_wm_hotkey); my $icon = Win32::GUI::Icon->new(IDI_DEFAULTICON); $mw->AddNotifyIcon( -icon => $icon, -onClick => \&toggle_show_state, ); set_hotkey($mw, $HOTKEY_ID, VK_A, MOD_CONTROL); $mw->Show(); Win32::GUI::Dialog(); # Before we exit we must remove the hotkey, else it won't be available # for other apps, and we'll leak system memory # Using and END block to that this get called, even if we exit other # than by falling off the end here. END { unset_hotkey($mw, $HOTKEY_ID); } sub toggle_show_state { my ($win) = @_; # Less obviously written as: # $win->Show(!$win->IsVisible()); if($win->IsVisible()) { $win->Hide(); } else { $win->Show(); } return 0; } # Set the hotkey for a window (or replace it if this is called # more than once) sub set_hotkey { my ($win, $id, $key, $modifiers) = @_; # $win - any top level window # $id - unique identifier for the hotkey # $key - any virtual keycode (VK_*) except F12 (and others??) # $modifiers - any combination of the MOD_* constants (or 0 for no modifier) if(!RegisterHotKey($win->{-handle}, $id, $modifiers, $key)) { die("set_hotkey() failed to register the hotkey - $^E"); } return; } sub unset_hotkey { my ($win, $id) = @_; # $win - any top level window # $id - unique identifier for the hotkey if(!UnregisterHotKey($win->{-handle}, $id)) { die("unset_hotkey() failed to unregister the hotkey - $^E"); } return; } sub handle_wm_hotkey { my ($win, $id, $lparam, $type, $msgcode) = @_; return unless $type == 0; return unless $msgcode == WM_HOTKEY; # decode virtual key and modifiers from lparam: # my ($modifiers, $key) = unpack("SS", pack("L", $lparam)); # my $mod = ''; # $mod .= "A" if($modifiers & MOD_ALT); # $mod .= "C" if($modifiers & MOD_CONTROL); # $mod .= "S" if($modifiers & MOD_SHIFT); # $mod .= "W" if($modifiers & MOD_WIN); # print "Saw WM_HOTKEY with id: $id (vkey: $key, mod: $mod)\n"; # should really check ID to determine what to do, but we can get # away without that, as we only have one hotkey toggle_show_state($win); return; } |