#This IS executing, I can tell because $changes is being set to 1...
sub reDesc_Change{
$changes = 1;
my ($x,$y) = $main->reDesc->Selection;
my $currentline = $main->reDesc->LineFromChar($x);
while (1)
{
my $firstline = $main->reDesc->FirstVisibleLine;
my $linecount = $main->reDesc->SendMessage(0x00ba,0,0);
my $lastline = $firstline + $linecount - 1;
last if ($lastline >= $currentline);
$main->reDesc->SendMessage(0x00b5,1,0);
}
return 1;
}
Okay, the problem is EM_LINECOUNT returns total lines, not visible lines (I
should have read the documentation more closely). I tried this and it
works:
sub reDesc_Change{
$changes = 1;
my ($start,$stop) = $main->reDesc->Selection;
while (1)
{
my ($x,$y) = $main->reDesc->PosFromChar($stop); # or $start, if you
prefer
last if ($y <= $main->reDesc->Height - 20);
$main->reDesc->SendMessage(0x00b5,1,0);
}
return 1;
}
You might want to set a variable before the while loop instead of calling
$main->reDesc->Height over and over again (it's less processor-intensive,
although in my tests, the code took less than a second, anyway) (or, if you
never resize the control, you could even hard-code it, although I dislike
that approach myself).
I subtract 20 because the limiting rectangle of the control (that's the
amount of space text can appear in) is smaller than the actual rectangle.
(PosFromChar returns a value relative to the limiting rectangle, not the
actual rectangle.) There is a message you can send to get the actual
limiting rectangle, but it requires packing a structure, which apparently
will not work with Win32::GUI::SendMessage (although someone posted that it
will work if you roll your own SendMessage via Win32::API). Rather than go
through all that, I simply fudged it by using 20. (If you're planning on
using different font sizes, you'll probably want to use a variable here,
too.) If you would prefer a more exact approach, I would be willing to help
(as, I'm sure, would others).
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com