slloyd has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone show me how to do any of the following in a Win32::GUI::RichEdit Control? I cannot seem to find any good examples.
- Insert an image
- Bold or underline the selected text
- Center the line or the selected text
- show the "cut, copy, paste" context menu when text is selected...
  • Comment on Using the Win32::GUI::RichEdit Control?

Replies are listed 'Best First'.
Re: Using the Win32::GUI::RichEdit Control?
by Anonymous Monk on Sep 09, 2005 at 07:21 UTC
    Which examples have you found?
      Here is what I have been able to do so far. This is from reading the XS code, searching the sourceforge newsgroup, and searching the web.. Not much but a start.
      #!perl use strict; use Win32::GUI; ################ MAIN WINDOW ############# my $MainWindow = new Win32::GUI::Window( -name => "MainWindow", -text => "Test", -pos => [600,50], -size => [415,320], -noflicker=> 1, ); ########################## my $left=0; my $top=0; my $width=400; my $height=300; #RichEdit References #http://sourceforge.net/mailarchive/message.php?msg_id=245995 (way to + copy, etc) #http://sourceforge.net/mailarchive/message.php?msg_id=245991 (Way to + append) #http://sourceforge.net/mailarchive/message.php?msg_id=245926 (Richedi +t Keypress, enter key, etc) my $RE = $MainWindow->AddRichEdit( -parent => $MainWindow, -name => "RichEditControl", -pos => [$left, $top ], -size => [$width,$height], -multiline => 1, -vscroll=>1, -autovscroll=>1, ); #Set the eventmask so that the _onChange gets called $RE->SendMessage (0x445, 0, 1); #Turn on auto detect url $RE->AutoURLDetect(1); #Set max character length $RE->SetMaxLength(5000); #Set Background Color $RE->SetBkgndColor(0xFFFFFF); #Set Text Mode - This enables cut, copy, paste, undo, select all (No c +ontext menu though) $RE->SetTextMode(1,1); ############################# $MainWindow->Show(); Win32::GUI::Dialog(); ############################## sub MainWindow_Resize{return 0;} sub MainWindow_Minimize {return 0;} sub MainWindow_Maximize {return 0;} sub MainWindow_Terminate {return -1;} sub RichEditControl_Change{ my $text=$MainWindow->RichEditControl->Text(); print "RichEditControl: $text\n"; } sub RichEditControl_KeyPress{ my($key) = @_; if ($key == 13){ print "Enter Key Pressed\n"; } } sub appendToRichEditControl{ my $text=shift || return; $RE->Select (1e9, 1e9); $RE->ReplaceSel ($text); } exit;