I'm working on creating a cleaned up, functional version of the GImageX_COM HTA found here for use with winbuilder projects (mainly Win7PE_SE). While I've had issues with the HTA itself, those seem to be resolved, and the one issue I'm running into is getting HTA windows to properly center themselves on the screen. From what I can tell, it has to do with being unable to get the ScreenWidth and ScreenHeight values from Win32_DesktopMonitor.
Here's the code the HTAs use to center themselves:
Sub Window_onLoad strComputer = "." Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next intLeft = (intHorizontal - 400) / 2 intTop = (intVertical - 200) / 2 window.resizeTo 400,200 window.moveTo intLeft, intTop End Sub
When I replace the intHorizontal and intVertical variables with pre-defined screen sizes, the HTAs center perfectly, but for some reason, they aren't able to get the current values from Win32_DesktopMonitor--does it not exist in PE? If so, what do I need to do to get these values from PE?
EDIT: I should note that the bit of code above results in the window being "centered" on 0,0 (so 3/4 of it aren't even visible). And that's what leads me to believe it's not getting the values from Win32_DesktopMonitor.
Edited by dcistech, 30 May 2012 - 02:56 PM.