This is a resubmission with increased points. I got 0 responses last time. If I'm not making myself clear would someone please let me know.
--------------------------
----------
----------
----------
--
I am writing an app that involves changing the work area and I want to size/position other apps' windows accordingly.
According to the MSDN this can be done by using SystemParametersInfo. By specifying SPIF_SENDWININICHANGE (same as SPIF_SENDCHANGE), Windows is supposed to send a WM_SETTINGCHANGE to top level windows which are supposed to size/position themselves to fit the new work area.
The following example uses a single maximized form to illustrate my understanding of what the MSDN says:
' --------------------- Declarations
Option Explicit
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByVal lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Private Const SPI_GETWORKAREA = 48
Private Const SPI_SETWORKAREA& = 47
Private Const SPIF_UPDATEINIFILE& = &H1
Private Const SPIF_SENDWININICHANGE& = &H2
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
' -------------------- A Command button on form1
Private Sub Command1_Click()
Dim di&
Dim rc As RECT
SystemParametersInfo SPI_GETWORKAREA, 0, VarPtr(rc), 0
Debug.Print Str(rc.Left) + Str(rc.Top) + Str(rc.Right) + Str(rc.Bottom)
rc.Left = rc.Left + 100
di = SystemParametersInfo(SPI_S
ETWORKAREA
, 0, VarPtr(rc), SPIF_SENDWININICHANGE)
Debug.Print di
SystemParametersInfo SPI_GETWORKAREA, 0, VarPtr(rc), 0
Debug.Print Str(rc.Left) + Str(rc.Top) + Str(rc.Right) + Str(rc.Bottom)
End Sub
' -------------------- End of code
When I run this, Form1 (and other maximized Apps) remain unchanged. I hooked the window and verified that WM_SETTINGCHANGE is received. This is also apparent if you resize the form to normal and back to maximized: It maximizes to a new work area, but not the one I thought I was setting!
Does anyone know how to make this work correctly? I DON't want to enumerate windows and deal with each individualy.
Note that this sample will screw up the work area which can easily be restored by toggling the state of the Taskbar autohide option (twice).