 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed Mar 29, 2006 10:25 am Post subject: |
|
|
Hi,
I've seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/rectangl_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 |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Mar 29, 2006 1:00 pm Post subject: |
|
|
| 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. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed Mar 29, 2006 1:19 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed Mar 29, 2006 1:28 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Mar 29, 2006 3:20 pm Post subject: |
|
|
| 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... _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Mar 29, 2006 3:32 pm Post subject: |
|
|
| 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)
|
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Last edited by PhiLho on Wed Mar 29, 2006 5:24 pm; edited 1 time in total |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Wed Mar 29, 2006 4:37 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu Mar 30, 2006 1:45 am Post subject: |
|
|
Hi PhiLho,
thanks for your efforts. That's working now, although I still don't understand it  _________________ Tekl |
|
| Back to top |
|
 |
Teto Guest
|
Posted: Tue May 27, 2008 8:44 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|