Hi all!
With this code I want to paste the clipboard content in the RichEdit
when I click the button.
Also I want to prevent CTRL-A and CTRL-C press in the RicheEdit
from the user (i.e. I redirect the focus to the button ... not very
elegant but works)
[The really problem is: after some manipolation of the text on the
RichEdit by my program, a CTRL-A & CTRL-C press makes a
"Error: Runtime exception", so I had to "redirect" CTRL-A]
This works but now I can not type in the RichEdit, only paste the
clipboard content. I'd like type normally in the RichEdit.
What's happend?
Thanks! :)
Andrea Maestrutti
##################################################
use Win32::GUI;
use Win32::Clipboard;
my $clip = Win32::Clipboard;
my $TextClass = new Win32::GUI::Class(
-name => "_Editor",
-extends => "RichEdit",
-widget => "RichEdit",
);
$win = new Win32::GUI::Window(
-name => "Window",
-text => "Test",
-width => 520,
-height => 410,
-left => 100,
-top => 100,
-minsize => [520, 410],
);
$Textbox = $win->AddRichEdit(
-class => $TextClass,
-name => "Text",
-left => 10,
-top => 10,
-multiline=> 1,
-width => $win->ScaleWidth-20,
-height => $win->ScaleHeight-150,
-exstyle => WS_EX_CLIENTEDGE,
-style => WS_CHILD | WS_VISIBLE | WS_VSCROLL
| ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
);
$button=$win->AddButton (
-name => "button",
-text => "Paste",
-left => 175,
-top => 310,
-width => 137,
-height => 30,
);
sub Text_KeyPress {
my($key) = @_;
if ($key == 1) {
$button->SetFocus();
} elsif ($key == 3) {
$button->SetFocus();
}
}
sub button_Click {
my $clip_content=$clip->GetText();
$Textbox->Text("$clip_content");
}
sub Window_Terminate {
return -1;
}
$win->Show();
Win32::GUI::Dialog();