On approximately 1/6/2004 6:51 AM, came the following characters from
the keyboard of Stephen Pick:

Hi,

Arrrgh.

The Win32 API deals, in the most part, with pointers to structs rather
than structs themselves. You can't pass homemade structs as Perl
references to SendMessage and hope that they're magically converted into
C pointers, that would indeed be nice, but it just isn't how it works.

pack/unpack does seem to have a conversion feature that deals with pointers, though, which I have to admit I have never figured out how to use it, or for certain why the feature is included. None of the examples show its use.

I've idly wondered, from time to time, if one could obtain a pointer to a homebuilt struct via pack, and then pass that as an integer value via Win32::API to a parameter that expects a pointer, and if that would work. Of course, Win32::API provides support for passing pointers to plain structs, so I've never had to worry about that in reality. But then since SendMessage doesn't, maybe it would be useful there?

I offer these comments and speculations not in the knowledge that this is a workable solution, but that it might be close to one... please don't laugh me off the list if it is completely ridiculous. But it seems I always have something else more important to do when I get near the computer, rather than try out this sort of thing.

Another alternative, of course, is to use the Win32::API module to create a new interface to the Windows SendMessage API rather than using the one in Win32::GUI.

I recommend you take a look at the Win32::API module for Perl. This may
help you as it certainly helped me.

Steve



-----Original Message-----
From: Glenn W Munroe [mailto:[EMAIL PROTECTED]
Sent: 06 January 2004 14:28
To: 'Stephen Pick'; perl-win32-gui-users@lists.sourceforge.net
Cc: [EMAIL PROTECTED]
Subject: RE: [perl-win32-gui-users] New "Hook" Method



Thanks for that, Steve. I'll be looking out for the new implementation.
In the meantime, I've been playing with some other messages and always
seem to hit the same problem with pointers to structures. When you say
"you can't use Perl to resolve the pointer" does that mean it is
impossible without XS code? Can you not just "pack" the correct
structure? For example, it would be nice to be able to select all items
in a listview without going through a slooooow loop like:

for (0..$mw->lvList->Count()-1) {$mw->lvList->Select($_)}

Now,

$mw->lvList->Select(-1)

would be nice, but it doesn't work!

Taking an idea from the VB world I tried this:

use constant LVM_SETITEMSTATE   => 0x1000 + 43;
use constant LVIF_STATE         => 0x0008;
use constant LVIS_SELECTED      => 0x0002;

my $lvItem=pack("IiiIIpiiii",LVIF_STATE,0,0,1,LVIS_SELECTED,"",0,0,0,0);
$mw->lvList->SendMessage(LVM_SETITEMSTATE, -1, \$lvItem);

Needless to say, it fails miserably. I assume the problem is with the
pointer to the structure. Is the structure wrong or is the problem with the Perl variable reference? I know that a Perl variable is represented
by a C structure internally; can you get a pointer to the actual data
value without resorting to XS code?

Thanks again,
Glenn

-----Original Message-----
From: Stephen Pick [mailto:[EMAIL PROTECTED] Sent: Monday, 05 January, 2004 06:46
To: [EMAIL PROTECTED]; perl-win32-gui-users@lists.sourceforge.net
Cc: [EMAIL PROTECTED]
Subject: RE: [perl-win32-gui-users] New "Hook" Method

Hi Glenn,


I've been trying to get the ListView EditLabel feature to

work. I can

turn it on OK and have got the handle to the edit control

and through

that the control's contents. The problem is that the control is

created

and destroyed automatically, and it is difficult to get

access to the

final data. According to MSDN, an LVN_ENDLABELEDIT notification is

sent

just before the control is destroyed, but I can't figure out how to

get

to that. Would the new "Hook" method work? Again, according to MSDN,

the

LVN_ENDLABELEDIT notification is sent in the form of a WM_NOTIFY
message. Would I have to grab that? That sounds like it may

be biting

off more than I can chew... Can you offer any pointers? Could you
perhaps post a snippet of code showing how the "Hook" method works?

You can't do this with Hooks at the moment. Personally I am not happy
with the current hook implementation as it does not satisfy what I
originally intended it to do. A new hook implementation should come in
the next few days, and I'll add the ability to hook notifications as
well as messages.

The problem is that WM_NOTIFY messages are delivered with an lParam that
is a pointer to a structure containing the notification code (like
LVN_ENDLABELEDIT). While you can use the current hooks implementation to
catch WM_NOTIFY and see the wParam and lParam arguments, the lParam
pointer is useless to you in Perl and you can't use Perl to resolve the
pointer and get the notification code from it.

Watch this space...

Steve







-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users



--
Glenn -- http://nevcal.com/
===========================
The best part about procrastination is that you are never bored,
because you have all kinds of things that you should be doing.


Reply via email to