I'm afraid the short answer is "no" (as far as I'm aware)--at least not
using the latest Win32::GUI release. Someone asked this a year or so ago and
I looked into it, eventually coming up with a tremendous hack (using hooks)
to get it to work. Since then, the XS code has changed and the hack doesn't
even work any more. Having said that, I don't think it would be *too*
difficult to get it to work again, but it would involve modifying the
listview XS code. In case you're interested, I've included the code as a
guide (it worked a couple of releases ago, but the Hook call now fails). Jez
White and Chris Wearn have done some work on the listview code recently;
maybe they have some ideas too...

Glenn

============================================================================
==================

#!perl -w

use strict;
use Win32();
use Win32::API;
use Win32::GUI;
use Data::Dumper;

use constant WM_NOTIFY                  => 0x4E;
use constant NM_CUSTOMDRAW              => -12;
use constant CDRF_NEWFONT               => 2;
use constant CDRF_NOTIFYITEMDRAW        => 32;
use constant CDDS_PREPAINT              => 1;
use constant CDDS_ITEMPREPAINT  => 65537;
use constant CLR_RED                    => "0000FF";
use constant CLR_GREEN                  => "00FF00";
use constant CLR_BLUE                   => "FF0000";
use constant CLR_WHITE                  => "FFFFFF";
use constant CLR_BLACK                  => "000000";

my $mw = new Win32::GUI::Window(
    -name    => "mw",
    -text        => "Colour Test",
        -size    => [ 200, 200 ],
        -pos     => [ 200, 200 ],
);

sub mw_Terminate { return -1 }

$mw->AddListView(
        -name     => "lvList",
        -pos      => [ 0, 0 ],
    -size     => [ 190, 125 ],
);

$mw->lvList->InsertColumn(
        -index   => 0,
        -text    => "Item",
);

$mw->lvList->ColumnWidth(0,180);

$mw->lvList->InsertItem(-text => "One");
$mw->lvList->InsertItem(-text => "Two");
$mw->lvList->InsertItem(-text => "Three");
$mw->lvList->InsertItem(-text => "Four");

$mw->lvList->TextColor(hex(CLR_RED));

$mw->lvList->Hook(NM_CUSTOMDRAW, \&lvList_CustomDraw);

my $CopyMemory=new Win32::API("kernel32", "RtlMoveMemory", "NPI", "V");
defined $CopyMemory or die "Can't find CopyMemory";

sub lvList_CustomDraw{
        my ($object, $wParam, $lParam, $type, $msgcode)[EMAIL PROTECTED];
        return 1 if $type!=WM_NOTIFY;

        my ($dwDrawStage, $dwItemSpec)=
                        unpack("x12Ix20i", unpack("P40",
pack("L",$lParam)));

        if ($dwDrawStage==CDDS_PREPAINT) {
                $object->Result(CDRF_NOTIFYITEMDRAW);
        } elsif ($dwDrawStage==CDDS_ITEMPREPAINT) {
                my $clrText;
                if              ($dwItemSpec==1) {
                        $clrText=pack("II",hex(CLR_BLUE),hex(CLR_WHITE))
                } elsif ($dwItemSpec==2) {
                        $clrText=pack("II",hex(CLR_GREEN),hex(CLR_BLACK))
                } else {
                        return
                }
                $CopyMemory->Call($lParam+48, $clrText, 8);
                $object->Result(CDRF_NEWFONT);
        }
}

$mw->Show;
$mw->lvList->SetFocus();
Win32::GUI::Dialog();

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
CGIexpo.com Support
Sent: Tuesday, 01 February, 2005 19:18
To: perl-win32-gui-users@lists.sourceforge.net
Subject: [perl-win32-gui-users] listview text color

I know you can set the text color for the items in a list view:

$Window->ListView->TextColor(hex("FF0000"));

Is there any way to set the color on just one row of text leaving the others
as they are?


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users



Reply via email to