AutoHotkey Community

It is currently May 27th, 2012, 11:17 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: March 29th, 2006, 10:25 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi,

I've seen at http://msdn.microsoft.com/library/defau ... l_6cqa.asp that I've exchanged x and y. It has to be x1,y1,x2,y2. But there's still the problem that some values are increasing while scrolling and sometimes goes to 0 and then again increasing. Maybe "LONG" is more than 4 bytes? I don't have the knowlegde to understand the msdn-articles.

_________________
Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2006, 1:00 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Tekl wrote:
Code:
   x1 := 0
   x2 := 0
   y1 := 0
   y2 := 0
   loop, 4
   {
      x1 += *( &rect+0+A_Index-1 )
      x2 += *( &rect+8+A_Index-1 )
      y1 += *( &rect+4+A_Index-1 )
      y2 += *( &rect+12+A_Index-1 )
   }

Why are you doing a Loop here? You are reading outside the bounds of the rectangle. Just do x1 := *() etc.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2006, 1:19 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Concerning the requests to add this as a built-in feature: Thanks for being persistent. I'll add this to the to-do list as a medium priority.

Important clarification: When you pass a memory address via a message whose number is less than WM_USER (1024), the system normally handles the VirtualAllocEx part for you. Therefore, the vast majority of common controls messages do not need to use the method in this topic.

Also, since VirtualAllocEx is not supported on Windows 9x, a different method is used there.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2006, 1:28 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi PhiLho,

I don't know what I'm doing. I just tried to get four values from the examples at the first few postings:

Code:
   loop, 4
   {
      y1 += *( &rect+3+A_Index )
      y2 += *( &rect+11+A_Index )
   }


I don't know how it works und why they use a loop.

_________________
Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2006, 3:20 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Chris wrote:
Important clarification: When you pass a memory address via a message whose number is less than WM_USER (1024), the system normally handles the VirtualAllocEx part for you. Therefore, the vast majority of common controls messages do not need to use the method in this topic.

Aaaaaah!
From a message by Micha, I supposed it was the case for all sent messages!
And indeed, I had a similar problem earlier, which probably strengthened this belief... I resolved this problem, BTW, see below.
And that, despite the fact that I successed using this feature in another message...

OK, for the posterity, here is how I got EM_GETSEL working with two parameters:
Code:
start = 0
end = 0
SendMessage EM_GETSEL, &start, &end, Edit1, A
a := &start
s := *a + (*(a + 1) << 8) +  (*(a + 2) << 16) + (*(a + 3) << 24)
a := &end
e := *a + (*(a + 1) << 8) +  (*(a + 2) << 16) + (*(a + 3) << 24)
;~ s := GetUInt(start)
;~ e := GetUInt(end)
MsgBox |%s%|%e%|

Could be simplier, but we lack a mean to tell SendMessage that we are giving it a pointer to a string, a structure or a simple DWORD that AHK could transpose to a interval value...

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2006, 3:32 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Tekl wrote:
I don't know what I'm doing. I just tried to get four values from the examples at the first few postings:

Code:
   loop, 4
   {
      y1 += *( &rect+3+A_Index )
      y2 += *( &rect+11+A_Index )
   }


I don't know how it works und why they use a loop.

Blindly using others' code is dangerous, even more when dealing with DllCalls...
Actually, I believe this code is bad, it works only because higher bytes are null. These bytes should be shifted (see my code above).

Code:
/*
// @struct: hold the UInt to extract
// _offset: offset of the UInt from the start of the struct, in UInt size units
*/
GetUInt(ByRef @struct, _offset=0)
{
   local addr
   addr := &@struct + _offset * 4
   Return *addr + (*(addr + 1) << 8) +  (*(addr + 2) << 16) + (*(addr + 3) << 24)
}

x1 := GetUInt(rect, 0)
y1 := GetUInt(rect, 1)
x2 := GetUInt(rect, 2)
y2 := GetUInt(rect, 3)

(Untested)
Even better:
Code:
/*
// Read a UInt (DWORD, ULONG, etc.) after the previously read ones.
// Useful for structures made only of UInts (POINT, RECT, etc.).
//
// @struct: hold the UInt to extract
// _bReset: if true, get UInt at offset 0
*/
GetNextUInt(ByRef @struct, _bReset=false)
{
   local addr
   static $offset

   If (_bReset)
   {
      $offset := 0
   }
   addr := &@struct + $offset
   $offset += 4

   Return *addr + (*(addr + 1) << 8) +  (*(addr + 2) << 16) + (*(addr + 3) << 24)
}

x1 := GetNextUInt(rect, true)
y1 := GetNextUInt(rect)
x2 := GetNextUInt(rect)
y2 := GetNextUInt(rect)

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Last edited by PhiLho on March 29th, 2006, 5:24 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2006, 4:37 pm 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
PhiLho wrote:
it works only because higher bytes are null. These bytes should be shifted


That's right. I extracted this simplified code from another post, and modified it to work for a specific purpose; but, forgot to remove the loop.

to Tekl:
    I would suggest using one of the many general purpose integer decoding functions found throughout the forum, or Chris's ExtractInteger.

    The general form of the loop method:

    Code:
    /*  struct RECT {
            LONG    left;       int4        0
            LONG    top;        int4        4
            LONG    right;      int4        8
            LONG    bottom;     int4        12
    }                                       16
    */

    x1 = 0
    y1 = 0
    x2 = 0
    y2 = 0
    loop, 4
    {
       x1 += *( &rect+A_Index-1 ) << 8*( A_Index-1 )
       y1 += *( &rect+3+A_Index ) << 8*( A_Index-1 )
       x2 += *( &rect+7+A_Index ) << 8*( A_Index-1 )
       y2 += *( &rect+11+A_Index ) << 8*( A_Index-1 )
    }


    Compare to the loop from ExtractInteger:

    Code:
    ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
    ...
    Loop %pSize%  ; Build the integer by adding up its bytes.
          result += *(&pSource + pOffset + A_Index-1) << 8*(A_Index-1)


    There is little value to using a specialized loop, over that of the general purpose function.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2006, 1:45 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi PhiLho,

thanks for your efforts. That's working now, although I still don't understand it ;-)

_________________
Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2008, 8:44 am 
Hi, I am slightly confused by this thread. Could someone please show me a way to actually re-size a listview row\'s height? :) Is this even possible?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2010, 7:07 pm 
Offline

Joined: February 16th, 2007, 8:46 pm
Posts: 62
Teto wrote:
Hi, I am slightly confused by this thread. Could someone please show me a way to actually re-size a listview row\'s height? :) Is this even possible?


bump


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group