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.

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
> 
> 
> 
> 

Reply via email to