Hi,
Any ideas how you can re-position a button
Example:
CONTROL (.win,@BUTTON,"OK",0,29,37,40,@TABSTOP,BUTTON_92)
I want to move the button across from position 0 to say position X when I have found what position X is - I do not know what X will be until the window has been re-sized to fit full screen.
Once the window has been re-sized, I know what X is.
Thanks,
Andy.
			
			
			
				You must solve this positioning under @idsize (WM_SIZE )event there is no better way to that,almost same thing 
is in any other gui based programming.
			
			
			
				Quote from: andy1966 on June 26, 2012, 12:55:34 AM
Hi,
Any ideas how you can re-position a button
Example:
CONTROL (.win,@BUTTON,"OK",0,29,37,40,@TABSTOP,BUTTON_92)
I assume you are asking how to reposition the button, not how to trap a resize event. See help file topic:
QuoteSETSIZE
Syntax
SETSIZE(win as WINDOW, l as UINT, t as UINT, w as UINT, h as UINT, OPT id=0 as UINT)
Description
Sets the size of a window, dialog or control.
Parameters
win - Window or dialog.
l, t, w, h - New position and dimensions.
id - Optional control identifier.
Return value
None.
Remarks
See Also: GETSIZE
Example usage
SETSIZE mywindow, 0, 0, 100, 250
 
			 
			
			
				Thanks everyone, missed that!
I will try it!
 :)
Andy.
			
			
			
				Here is some code I found and converted on another forum that lets you move and resize gadgets when you resize the window
$include "windowssdk.inc"
$use "LList.lib"
$include "LList.inc"
WINDOW testwin
type gadget
	window Windhandle
	int Gadget
	int LEFT
	int Top
	int Right
	int Bottom
	int Lock_Left
	int Lock_Top
	int Lock_Right
	int Lock_Bottom
ENDTYPE
def mylist as LList
mylist.Create()
OPENWINDOW testwin,0,0,316,338,@CAPTION|@autoscale|@SIZE|@MINBOX|@MAXBOX,NULL,"Autoscale test",&testhandler
CENTERWINDOW(testwin)
SETWINDOWCOLOR testwin,RGB(155,155,155)
CONTROL testwin,@sysBUTTON,"Butt1",5,5,50,25,0,1
CONTROL testwin,@BUTTON,"Butt2",245,5,50,25,0,2
CONTROL testwin,@BUTTON,"Butt3",5,270,50,25,0,3
CONTROL testwin,@BUTTON,"Butt4",245,270,50,25,0,4
CONTROL testwin,@listview,"Butt5",55,30,190,240,@BORDER|@LVSNOSORTHEADER|@LVSREPORT|@LVSSINGLESEL,5
RS_Register(testwin, 1, 1, 1, 0, 0) ' lock left/top
RS_Register(testwin, 2, 0, 1, 1, 0) ' lock right/top
RS_Register(testwin, 3, 1, 0, 0, 1) ' lock left/bottom
RS_Register(testwin, 4, 0, 0, 1, 1) ' lock right/bottom
RS_Register(testwin, 5, 1, 1, 1, 1) ' lock left/top/right/bottom
WAITUNTIL testwin.hWnd = 0
MyList.ClearAll(TRUE)
END
sub testhandler(),int
'int l=0,t=0,w=0,h=0
	select @message
		case @IDCLOSEWINDOW
			CLOSEWINDOW testwin
		case @IDSIZE
			RS_Resize(testwin)
	endselect
	return 0
endsub
sub RS_Register(RS_window:window,RS_gadget:int,RS_left:int,RS_top:int,RS_right:int,RS_bottom:int)
def WWidth,WHeight,GX,GY as INT
DEF l,t,w,h as UINT
DEF gl,gt,gw,gh as INT
point p
If MyList.AddAfter(NEW(gadget,1))=0
	MyList.#<gadget>m_pCurData.Gadget = RS_gadget
	MyList.#<gadget>m_pCurData.Windhandle = RS_window
	MyList.#<gadget>m_pCurData.Lock_Left = RS_left
	MyList.#<gadget>m_pCurData.Lock_Top = RS_top
	MyList.#<gadget>m_pCurData.Lock_Right = RS_right
	MyList.#<gadget>m_pCurData.Lock_Bottom = RS_bottom
	GETCLIENTSIZE RS_window, l, t, w, h
	WWidth = w
	WHeight = h
	GETSIZE MyList.#<gadget>m_pCurData.Windhandle, gl, gt, gw, gh, MyList.#<gadget>m_pCurData.Gadget
	p.x=gl:p.y=gt
	ScreenToClient(RS_window.hwnd,p)
	GX = p.x
	GY = p.y
	if RS_left = 0 : MyList.#<gadget>m_pCurData.Left = WWidth - GX : endif
	if RS_top = 0 : MyList.#<gadget>m_pCurData.Top = WHeight - GY : endif
	if RS_right = 1 : MyList.#<gadget>m_pCurData.Right = WWidth - (GX+gw) : endif
	if RS_bottom = 1 : MyList.#<gadget>m_pCurData.Bottom = WHeight - (GY+gh) : endif
	MessageBox(0,"Gadget No. "+str$(MyList.#<gadget>m_pCurData.Gadget)+"\nLeft: "+str$(MyList.#<gadget>m_pCurData.Left)+"\nTop: "+str$(MyList.#<gadget>m_pCurData.Top)+"\nWidth: "+str$(MyList.#<gadget>m_pCurData.Right)+"\nHeight: "+str$(MyList.#<gadget>m_pCurData.Bottom),"",0)
	
else
	messagebox(0,MyList.ErrMsg(),"",0)
endif
return 0
endsub
sub RS_Resize(RS_window:window)
DEF l,t,w,h as UINT
DEF gl,gt,gw,gh as INT
point p
def RS_x, RS_y, RS_w, RS_h, WWidth, WHeight as int
If MyList.GetFirst() = 0
	do
		if MyList.#<gadget>m_pCurData.Windhandle = RS_window
			GETCLIENTSIZE MyList.#<gadget>m_pCurData.Windhandle, l, t, w, h
			WWidth = w
			WHeight = h
			if CONTROLEXISTS(MyList.#<gadget>m_pCurData.Windhandle, MyList.#<gadget>m_pCurData.Gadget)
				GETSIZE MyList.#<gadget>m_pCurData.Windhandle, gl, gt, gw, gh, MyList.#<gadget>m_pCurData.Gadget
				p.x=gl:p.y=gt
				ScreenToClient(MyList.#<gadget>m_pCurData.Windhandle.hwnd, p)
				RS_x=p.x
				RS_y=p.y
				RS_w=gw
				RS_h=gh
				If MyList.#<gadget>m_pCurData.Lock_left = 0 then RS_x = WWidth - MyList.#<gadget>m_pCurData.Left
				If MyList.#<gadget>m_pCurData.Lock_top = 0 then RS_y = WHeight - MyList.#<gadget>m_pCurData.Top
				If MyList.#<gadget>m_pCurData.Lock_Right = 1 then RS_w = WWidth - RS_x - MyList.#<gadget>m_pCurData.Right
				If MyList.#<gadget>m_pCurData.Lock_Bottom = 1 then RS_h = WHeight - RS_y - MyList.#<gadget>m_pCurData.Bottom
				SetSize MyList.#<gadget>m_pCurData.Windhandle, RS_x, RS_y, RS_w, RS_h, MyList.#<gadget>m_pCurData.Gadget
			endif
		endif
	until MyList.Getnext() <> 0	
endif
return 0
endsub
			
			
				Pip...
This code is not bad BUT use external libs which in this case are not important.
All positioning and resizing if is used under @idsize event is important.
of course this include first GetClientSize to get current size of specified control.
Then after that use SetSize(), ( api MoveWindow() ).
			
			
			
				This example keeps the close button located in the lower right corner of the window.
CONST BUTTON_1 = 1
DIALOG d1
CREATEDIALOG d1,0,0,320,202,@CAPTION|@SYSMENU|@SIZE,0,"Resize Demo",&d1_handler
CONTROL d1,@SYSBUTTON,"Close",0,0,70,20,0,BUTTON_1
showdialog d1
waituntil d1=0
end
SUB d1_handler(),int
  int l,t,w,h
  SELECT @MESSAGE
    CASE @IDINITDIALOG
      getclientsize d1,l,t,w,h
      setsize d1, w-80,h-30,70,20,BUTTON_1
      CENTERWINDOW d1
    CASE @IDSIZE
      getclientsize d1,l,t,w,h
      setsize d1, w-80,h-30,70,20,BUTTON_1
    CASE @IDCLOSEWINDOW
      CLOSEDIALOG d1,@IDOK
    CASE @IDCONTROL
      SELECT @CONTROLID
        CASE BUTTON_1
          IF @NOTIFYCODE = 0
            CLOSEDIALOG d1,@IDOK
          ENDIF
      ENDSELECT
  ENDSELECT
RETURN 0
ENDSUB
			
			
			
				Yes ...good point mr.Larry ;)