Old 28th June 2008, 00:33   #1
zeeh3
Senior Member
 
Join Date: Aug 2005
Posts: 121
System Plugin and SHAppBarMessage help

I need some help with SHAppBarMessage call, the code below:

code:
!define stRECT '(i,i,i,i) i'
!define APPBARDATA '(i,i,i,i,i,i) i'

!include "WinMessages.nsh"

System::Call '*${stRECT} .r2'
System::Call '*${APPBARDATA} .r3'
System::Call 'shell32::SHAppBarMessage(i ${ABM_GETTASKBARPOS}, i r3) i.r0'
System::Call "*$3${APPBARDATA} (.R9, .R8, .R7, .R6, .r2, .R5)"
System::Call "*$2${stRECT}(.r5, .r6, .r7, .r8)" ; screen application rect
System::Free $3
System::Free $2
messagebox mb_ok "$R9, $R8, $R7, $R6, $2, $R5$\r$\nleft=$5 - top=$6 - right=$7 - bottom=$8"



$R6 contains the relative taskbar position (top, bottom, left, right), but stRECT is empty. But if I use the code below I can get the values, but not the relative position:

code:
System::Call '*${stRECT} .r2'
FindWindow $TASKBAR 'Shell_TrayWnd' '' ''
System::Call 'user32::GetWindowRect(i $TASKBAR , i r2)'
System::Call "*$2${stRECT}(.r5, .r6, .r7, .r8)"
System::Free $2
messagebox mb_ok "left=$5 - top=$6 - right=$7 - bottom=$8"



Any ideas? Thanks
zeeh3 is offline   Reply With Quote
Old 28th June 2008, 10:37   #2
CancerFace
Senior Member
 
Join Date: Apr 2006
Posts: 289
Send a message via ICQ to CancerFace
Do you define the size of the APPBARDATA structure somewhere? It appears to me that you need to allocate memory first before passing anything to APPBARDATA as its first member is its size in bytes. Is this a 'working' example of your code or are there bits (relating to the call you make) missing?
CF
CancerFace is offline   Reply With Quote
Old 28th June 2008, 10:54   #3
zeeh3
Senior Member
 
Join Date: Aug 2005
Posts: 121
Yes, it is a working example but could be smaller.

I don't know if I have defined APPBARDATA correctly:
code:
!define APPBARDATA '(i,i,i,i,i,i) i'


The first code works partially, with SHAppBarMessage I got only relative taskbar location, but this function gives the taskbar coordinates too, in stRECT structure, and here is my problem because stRECT is empty. If I use it with the second code, stRECT comes with the values I need, but I wanna know why the first stRECT is empty.
zeeh3 is offline   Reply With Quote
Old 28th June 2008, 12:10   #4
zeeh3
Senior Member
 
Join Date: Aug 2005
Posts: 121
Well, the first value must be &l and not i, but the installer crashes. Maybe there is a value to put there too.

code:
!define APPBARDATA '(&l,i,i,i,i,i) i'


if I move taskbar to the right, using (i,i,i,i,i,i), the installer crashes too
zeeh3 is offline   Reply With Quote
Old 28th June 2008, 15:01   #5
zeeh3
Senior Member
 
Join Date: Aug 2005
Posts: 121
Almost, it's not crashing but no stRECT.

code:
!define stRECT '(i,i,i,i) i'
!define APPBARDATA '(&l4,i,i,i,i,i) i'

!include "WinMessages.nsh"

System::Call '*${stRECT} .r2'
System::Call '*${APPBARDATA} .r3'
System::Call 'shell32::SHAppBarMessage(i ${ABM_GETTASKBARPOS}, i r3) i.r0'
System::Call "*$3${APPBARDATA} (,,, .R6, r2,)"
System::Call "*$2${stRECT}(.r5, .r6, .r7, .r8)"
System::Free $3
System::Free $2
messagebox mb_ok "relative pos=$R6$\r$\nleft=$5$\r$\ntop=$6$\r$\nright=$7$\r$\nbottom=$8"


Last edited by zeeh3; 28th June 2008 at 15:21.
zeeh3 is offline   Reply With Quote
Old 29th June 2008, 11:14   #6
zeeh3
Senior Member
 
Join Date: Aug 2005
Posts: 121
Now I am really confused
I think I am using the wrong message and getting the wrong results. I think now ABM_QUERYPOS is the correct way to get what I want (taskbar relative position and coordinates), but it returns nothing. Below are the MSDN reference links:

SHAppBarMessage Function

ABM_GETTASKBARPOS Message

ABM_QUERYPOS Message

APPBARDATA Structure
zeeh3 is offline   Reply With Quote
Old 29th June 2008, 11:27   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,191
!define APPBARDATA '(&l4,i,i,i,i,i) i', where is the rect struct, you only have a INT there, add 3 more i's?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 29th June 2008, 12:12   #8
zeeh3
Senior Member
 
Join Date: Aug 2005
Posts: 121
The APPBARDATA Structure is:

code:
typedef struct _AppBarData {
DWORD cbSize;
HWND hWnd;
UINT uCallbackMessage;
UINT uEdge;
RECT rc;
LPARAM lParam;
} APPBARDATA, *PAPPBARDATA;



How can I define it correctly with rect struct?
zeeh3 is offline   Reply With Quote
Old 2nd July 2008, 17:44   #9
zeeh3
Senior Member
 
Join Date: Aug 2005
Posts: 121
I give up from using ABM_GETTASKBARPOS Message. The code below does what I need, it gets taskbar coordinates and its relative position, for those interested:

code:
!define stRECT '(i,i,i,i) i'
!include "LogicLib.nsh"

System::Call '*${stRECT} .r0'
FindWindow $1 'Shell_TrayWnd' '' ''
System::Call 'user32::GetWindowRect(i r1 , i r0)'
System::Call "*$0${stRECT}(.r2, .r3, .r4, .r5)" ;left-top-right-bottom
System::Free $0

${If} $3 == $2
${AndIf} $5 > $4
MessageBox MB_OK "Left"
${ElseIf} $3 == $2
${AndIf} $5 < $4
MessageBox MB_OK "Top"
${ElseIf} $3 > $2
MessageBox MB_OK "Bottom"
${Else}
MessageBox MB_OK "Right"
${EndIf}

zeeh3 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump