Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;-----------------------------------------------------------------------------------------------------------------------------------------; ;SetWindowPos : Changes the size, position, and Z order of a window ; ; Child, pop-up, and top-level windows are ordered according to their appearance on the screen. ; ; The topmost window receives the highest rank and is the first window in the Z order. ; ;v1.1 by IFICantBYTE (2004) ; ;-----------------------------------------------------------------------------------------------------------------------------------------; ;hWnd : Window handle ; ;hWndInsertAfter : Handle to the window to precede the positioned window in the Z order. ; ; This parameter must be a window handle or one of the following values: ; ; HWND_BOTTOM = 1 Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, ; ; the window loses its topmost status and is placed at the bottom of all other windows. ; ; HWND_NOTOPMOST = -2 Places the window above all non-topmost windows (that is, behind all topmost windows). ; ; This flag has no effect if the window is already a non-topmost window. ; ; HWND_TOP = 0 Places the window at the top of the Z order. ; ; HWND_TOPMOST = -1 Places the window above all non-topmost windows. The window maintains its topmost position ; ; even when it is deactivated. ; ; NOTE : For more information about how this parameter is used, see the following Remarks section. ; ;X : Specifies the new position of the left side of the window, in client coordinates. ; ;Y : Specifies the new position of the top of the window, in client coordinates. ; ;cx : Specifies the new width of the window, in pixels. ; ;cy : Specifies the new height of the window, in pixels. ; ;uFlags : Window sizing and positioning flags. This parameter can be a combination of the following values: ; ; SWP_ASYNCWINDOWPOS = 16384 If the calling thread and the thread that owns the window are attached to different ; ; input queues, the system posts the request to the thread that owns the window. This ; ; prevents the calling thread from blocking its execution while other threads process the ; ; request. ; ; SWP_DEFERERASE = 8192 Prevents generation of the WM_SYNCPAINT message. ; ; SWP_DRAWFRAME = 32 Draws a frame (defined in the window's class description) around the window. ; ; SWP_FRAMECHANGED = 32 (Same value as above) Applies new frame styles set using the SetWindowLong function. ; ; Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being ; ; changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's ; ; size is being changed. ; ; SWP_HIDEWINDOW = 128 Hides the window. ; ; SWP_NOACTIVATE = 16 Does not activate the window. If this flag is not set, the window is activated and ; ; moved to the top of either the topmost or non-topmost group (depending on the setting of ; ; the hWndInsertAfter parameter). ; ; SWP_NOCOPYBITS = 256 Discards the entire contents of the client area. If this flag is not specified, the ; ; valid contents of the client area are saved and copied back into the client area after ; ; the window is sized or repositioned. ; ; SWP_NOMOVE = 2 Retains the current position (ignores X and Y parameters). ; ; SWP_NOOWNERZORDER = 512 Does not change the owner window's position in the Z order. ; ; SWP_NOREPOSITION = 512 (Same value as above) Same as the SWP_NOOWNERZORDER flag. ; ; SWP_NOREDRAW = 8 Does not redraw changes. If this flag is set, no repainting of any kind occurs. This ; ; applies to the client area, the nonclient area (including the title bar and scroll bars) ; ; and any part of the parent window uncovered as a result of the window being moved. When ; ; this flag is set, the application must explicitly invalidate or redraw any parts of the ; ; window and parent window that need redrawing. ; ; SWP_NOSENDCHANGING = 1024 Prevents the window from receiving the WM_WINDOWPOSCHANGING message. ; ; SWP_NOSIZE = 1 Retains the current size (ignores the cx and cy parameters). ; ; SWP_NOZORDER = 4 Retains the current Z order (ignores the hWndInsertAfter parameter). ; ; SWP_SHOWWINDOW = 64 Displays the window. ; ; ; ; Remarks : If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized. ; ; If you have changed certain window data using SetWindowLong, you must call SetWindowPos to have the changes take ; ; effect. Use the following combination for uFlags: SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED. ; ; A window can be made a topmost window either by setting the hWndInsertAfter parameter to HWND_TOPMOST and ensuring ; ; that the SWP_NOZORDER flag is not set, or by setting a window's position in the Z order so that it is above any ; ; existing topmost windows. When a non-topmost window is made topmost, its owned windows are also made topmost. Its ; ; owners, however, are not changed. ; ; If neither the SWP_NOACTIVATE nor SWP_NOZORDER flag is specified (that is, when the application requests that a window ; ; be simultaneously activated and its position in the Z order changed), the value specified in hWndInsertAfter is used ; ; only in the following circumstances: ; ; Neither the HWND_TOPMOST nor HWND_NOTOPMOST flag is specified in hWndInsertAfter. ; ; The window identified by hWnd is not the active window. ; ; An application cannot activate an inactive window without also bringing it to the top of the Z order. ; ; Applications can change an activated window's position in the Z order without restrictions, or it can activate a ; ; window and then move it to the top of the topmost or non-topmost windows. ; ; If a topmost window is repositioned to the bottom (HWND_BOTTOM) of the Z order or after any non-topmost window, it is ; ; no longer topmost. ; ; When a topmost window is made non-topmost, its owners and its owned windows are also made non-topmost windows. ; ; A non-topmost window can own a topmost window, but the reverse cannot occur. Any window (for example, a dialog box) ; ; owned by a topmost window is itself made a topmost window, to ensure that all owned windows stay above their owner. ; ; If an application is not in the foreground, and should be in the foreground, it must call the SetForegroundWindow ; ; function. ; ; To use SetWindowPos to bring a window to the top, the process that owns the window must have SetForegroundWindow ; ; permission. ; ; ; ;-----------------------------------------------------------------------------------------------------------------------------------------; ;Returns : If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. ; ;-----------------------------------------------------------------------------------------------------------------------------------------; #DefineFunction SetWindowPos(hWnd,hWndInsertAfter,X,Y,cx,cy,uFlags) User32=StrCat(DirWindows(1),"user32.dll") Return DllCall(user32,long:"SetWindowPos",long:hWnd,long:hWndInsertAfter,long:X,long:Y,long:cx,long:cy,long:uFlags) #EndFunction ;########################################################################################################################################## ;-----------------------------------------------------------------------------------------------------------------------------------------; ;GetWindowRect : Retrieves the dimensions of the bounding rectangle of a specified window and Returns them in a delimited string. ; ; The dimensions are given in screen coordinates (Window's pixels) that are relative to the upper-left corner of the ; ; second window handle specified. ; ;v1.1 by IFICantBYTE (2004) ; ;-----------------------------------------------------------------------------------------------------------------------------------------; ;hWindow1 : Window handle we want to get the relative coordinates for (Usually a Child Window - but not always) ; ;hWindow2 : Window handle we want the returned coordinates to be relative to (Usually the Parent window - but again, doesn't have to be) ; ; NOTE : Passing the same window handle for both - ie: comparing it to itself will basically return the size of the window. ; ;delim : The delimiter you want to use between the Returned X and Y values - eg: "," or @TAB or @CRLF or " " (space) ; ;-----------------------------------------------------------------------------------------------------------------------------------------; ;Returns : Returns a delimited string containing the rectangular coordinates (in Windows' pixels - not Winbatch's 1K units) for hWindow1 ; ; relative to the Window specified by the handle hWindow2. ; ; NOTE : 0 0 is top Left corner. Values can go into negatives and the window specified does not have to be the topmost, active or ; ; focused. This will not Return correct results with a mirrored Window using a Right to Left ExStyle ; ;-----------------------------------------------------------------------------------------------------------------------------------------; #DefineFunction GetWindowRect(hWindow1,hWindow2,delim) User32 = DllLoad(StrCat(DirWindows(1),"user32.dll")) ;--- Make RECT structure --- will contain the top-left and bottom-right coordinates and therefore the rectangle size of the window --- RECT=BinaryAlloc(16) ; Create buffer for structure ;BinaryPoke4(RECT,0,0) ; Left x coordinate (pixel) ;BinaryPoke4(RECT,4,0) ; Top y coordinate (pixel) ;BinaryPoke4(RECT,8,0) ; Right x ;BinaryPoke4(RECT,12,0) ; Bottom y ;NOTE : above BinaryPokes are commented out to save some processing time - contents will be overwritten with new values on dll call) ;------------------------------------------------------------------------------------------------------- DllCall(user32,long:"GetWindowRect",long:hWindow1,lpbinary:RECT) ;----- Make POINT structure ---- will contain the bottom X and Y coordinates ------------------- POINT=BinaryAlloc(8) ; Create buffer for structure ;BinaryPoke4(RECT,0,0) ; Left x coordinate (pixel) ;BinaryPoke4(RECT,4,0) ; Top y coordinate (pixel) ;NOTE : above BinaryPokes are commented out to save some processing time - contents will be overwritten with new values on dll call) ;------------------------------------------------------------------------------------------------------- BinaryCopy(POINT,0,RECT,8,8) DllCall(user32,long:"ScreenToClient",long:hWindow2,lpbinary:RECT) DllCall(user32,long:"ScreenToClient",long:hWindow2,lpbinary:POINT) topx = BinaryPeek4(RECT,0) topy = BinaryPeek4(RECT,4) bottomx = BinaryPeek4(POINT,0) bottomy = BinaryPeek4(POINT,4) BinaryFree(RECT) BinaryFree(POINT) DllFree(User32) Return StrCat(topx,delim,topy,delim,bottomx,delim,bottomy) #EndFunction ;########################################################################################################################################## IntControl(1002,0,0,0,0) ;no winbatch icon IntControl(54,"",1,0,0) ;always on top #definesubroutine dlgproc(handle,msg,id,p4,p5) select msg case 0 ;Init ;Hide Title Bar SWP_FRAMECHANGED = 32 HWND_TOP = 0 SWP_NOMOVE = 2 SWP_NOSIZE = 1 WS_CAPTION=12582912 ;12582912 Hex 00C00000 (Search MSDN for Q111011 for more parameter values) GWL_STYLE=-16 User32=StrCat(DirWindows(1),"USER32.DLL") OldStyle=DllCall(User32, long:"GetWindowLongA", long:Handle, long:GWL_STYLE) NewStyle=OldStyle & ~WS_CAPTION DllCall(User32, long:"SetWindowLongA", long:Handle, long:GWL_STYLE, long:NewStyle) DllCall(user32, long:"SetWindowPos", long:Handle, long:HWND_TOP, long:0, long:0, long:0, long:0, long:SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE) DialogProcOptions(handle,2,1) ;buttons ParseData(GetWindowRect(handle,handle," ")) ; get the size of the dialog (compare it's coordinates to itself) and make param0 to 4 out of it MyDialogFullHeight = Param4 ; Save the current initial (Full) height MyDialogSmall = 58 ; just a value for the small height that was guessed at and then altered manually after testing so that the first button remains visible case 2 ;buttons select id case 1 ;ToolBar size toggle ;;;;;;;;HERE I WANT TO TOGGLE BETWEEN THE FULL DIALOG AND SMALLER DIALOG WITH JUST THIS BUTTON;;;;;;;;; ParseData(GetWindowRect(handle,handle," ")) ; get the size of the dialog (compare it's coordinates to itself) and make param0 to 4 out of it MyDialogHeight = Param4 if MyDialogHeight == MyDialogFullHeight SetWindowPos(handle,-1,param1,param2,param3,MyDialogSmall,2|4|512) ; make dialog smaller For CTRLnum = 2 to 5 DialogControlState(handle,CTRLnum,3, 2) ; Disable all other buttons - so they can't be tabbed to when the dialog is small and they can't be seen. Next CTRLnum else For CTRLnum = 2 to 5 DialogControlState(handle,CTRLnum,4, 2) ; Enable other buttons again now that they can be seen. Next CTRLnum SetWindowPos(handle,-1,param1,param2,param3,MyDialogFullHeight,2|4|512) ; make dialog full size again Endif return -2 case 2 if WinExist("FrodoSatelliteRadioX" ) WinActivate("FrodoSatelliteRadioX") else Run("C:\Program Files\FrodoSatelliteRadioX\FrodoSatelliteRadioX.exe","") endif return -2 case 3 if WinExist("Master Volume" ) WinActivate("Master Volume") else Run("C:\WINNT\system32\sndvol32.exe","") endif return -2 case 4 if WinExist("~Notepad" ) WinActivate("~Notepad") else Run("C:\winnt\notepad.exe","") endif return -2 endselect endselect return -1 #endsubroutine MyDialogFormat=`WWWDLGED,6.1` MyDialogCaption=`ToolBar` MyDialogX=0 MyDialogY=0 MyDialogWidth=31 MyDialogHeight=141 MyDialogNumControls=005 MyDialogProcedure=`dlgproc` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`0|0|0` MyDialogConfig=1 MyDialog001=`0,000,30,30,PUSHBUTTON,DEFAULT,"Change",1,DEFAULT,128,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`0,030,30,30,PUSHBUTTON,DEFAULT,"App1",2,DEFAULT,128,DEFAULT,DEFAULT,DEFAULT"` MyDialog003=`0,060,30,30,PUSHBUTTON,DEFAULT,"App2",3,DEFAULT,128,DEFAULT,DEFAULT,DEFAULT"` MyDialog004=`0,090,30,30,PUSHBUTTON,DEFAULT,"App3",4,DEFAULT,128,DEFAULT,DEFAULT,DEFAULT"` MyDialog005=`0,120,30,30,PUSHBUTTON,DEFAULT,"Cancel",0,DEFAULT,128,DEFAULT,DEFAULT,DEFAULT"` ButtonPushed=Dialog("MyDialog",1)
Article ID: W16948
File Created: 2007:07:03:14:27:08
Last Updated: 2007:07:03:14:27:08