IonicWind Software

IWBasic => GUI Central => Topic started by: splakidas on April 14, 2007, 03:29:57 PM

Title: how can i read button position
Post by: splakidas on April 14, 2007, 03:29:57 PM
how can i read the x,y position ao a button as also its width and height  :(
Title: Re: how can i read button position
Post by: mrainey on April 14, 2007, 05:54:39 PM
From the User Guide:



General functions to query a window, dialog or control properties.


Retrieving sizes

GETSIZE window | dialog, varL, varT, varW, varH {, ID}
Will return the size of a window, dialog or control in the variables specified. Variables must be of type INT. The left and top coordinates are relative to the upper left corner of the screen. If ID is specified then the size of the control is returned.
Title: Re: how can i read button position
Post by: splakidas on April 15, 2007, 12:24:52 AM
QuoteGETSIZE window | dialog, varL, varT, varW, varH {, ID}

mrainey i asked because this command doesnt work.
varL, varT, gives me screen relative position of the button and not window relative position.
I want to know the x,y as also the width and the height of the button.

here a  sample you can play around
$include "windows.inc"
openconsole
int x,y,x1,y1

DIALOG d1
INT g_buttonproc
CREATEDIALOG d1,0,0,300,202,0x80CA0880,0,"Caption",&d1_handler
CONTROL d1,@SYSBUTTON,"drag me",96,63,70,20,0x50010000,1000
domodal d1

SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
g_buttonproc = _SetWindowLong(GetControlHandle(d1, 1000), GWL_WNDPROC, &DragDropCtlProc)
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
ENDSELECT
RETURN
ENDSUB

sub DragDropCtlProc(hwnd:int,msg:int,wparam:int,lparam:int),int

if (msg=WM_LBUTTONDOWN) /* and dragging alloved */
SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
getsize d1,x,y,x1,y1,1000
print x,y,x1,y1
return 0
endif
return _CallWindowProc(g_buttonproc, hwnd, msg,wParam,lParam)
endsub






Title: Re: how can i read button position
Post by: splakidas on April 15, 2007, 12:45:02 AM
mrainey
beacause the GETSIZE dont give me window relative button position a thought also to use the getclientsize for readind the window position on the screen and
after find the diference, but  try replacing in my example the sub and you will understand

sub DragDropCtlProc(hwnd:int,msg:int,wparam:int,lparam:int),int

if (msg=WM_LBUTTONDOWN) /* and dragging alloved */
SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
getsize d1,x,y,x1,y1,1000
print x,y,x1,y1
getclientsize d1,x,y,x1,y1
print x,y,x1,y1
return 0
endif
return _CallWindowProc(g_buttonproc, hwnd, msg,wParam,lParam)
endsub



getclientsize d1,x,y  x=0 y=0 ??? ??? ???

I want the position x,y,x-width,x-lenght
Title: Re: how can i read button position
Post by: splakidas on April 15, 2007, 01:05:47 AM
ok solved

getsize d1,wx,wy,wx1,wy1              for window only so we get window position on screen
after
getsize d1,x,y,x1,y1,1000     now we get button coordinates but NOT WINDOW RELATIVE
and after we must do x-wx and y-wy to get window relative positions  here look at the sample

$include "windows.inc"
openconsole
int x,y,x1,y1
int ax,ay,ax1,ay1

DIALOG d1
INT g_buttonproc
CREATEDIALOG d1,0,0,300,202,@size|0x80CA0880,0,"Caption",&d1_handler
CONTROL d1,@SYSBUTTON,"drag me",96,63,70,20,0x50010000,1000

domodal d1

SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
g_buttonproc = _SetWindowLong(GetControlHandle(d1, 1000), GWL_WNDPROC, &DragDropCtlProc)

CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
ENDSELECT
RETURN
ENDSUB

sub DragDropCtlProc(hwnd:int,msg:int,wparam:int,lparam:int),int

if (msg=WM_LBUTTONDOWN) /* and dragging alloved */
SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
getsize d1,ax,ay,ax1,ay1
print x,y,x1,y1
getsize d1,x,y,x1,y1,1000
print x,y,x1,y1
print "================="
print x-ax,y-ay,x1,y1
print "================="

getclientsize d1,x,y,x1,y1
print x,y,x1,y1
GETPOSITION d1, x, y
print x,y
GETCARETPOSITION d1, x, y
print x,y
print "---------------------------"
return 0
endif
return _CallWindowProc(g_buttonproc, hwnd, msg,wParam,lParam)
endsub


Title: Re: how can i read button position
Post by: mrainey on April 15, 2007, 04:07:42 AM
I'm glad you worked it out.  I'll save your code for future reference.   :)