Re: Determining if a window is visible
- Posted by marky1124 Jul 23, 2009
- 900 views
mattlewis said...
Does getWindowRect( Screen ) work? If you got that rect, you could compare it to your window.
Matt
I don't think so. My main window is called Window1. If I try and use getWindowRect(Screen) I get
Error code 472 getRect:GetWindowRect failed. Win32Lib v0.70.4 17-Jun-2008
Is Screen a predefined variable?
Here's some code I've been using to play with this problem:
-- code generated by Win32Lib IDE v1.0.4 Build July-06-2008 constant TheProgramType="exw" include Win32Lib.ew without warning -------------------------------------------------------------------------------- -- Window Window1 constant Window1 = createEx( Window, "Window1", 0, Default, Default, 400, 300, 0, 0 ) constant PushButton8 = createEx( PushButton, "Open child window", Window1, 40, 44, 100, 28, 0, 0 ) constant PushButton3 = createEx( PushButton, "Move child off top", Window1, 40, 92, 96, 28, 0, 0 ) constant wLabel2 = createEx( LText, "LText10", Window1, 36, 184, 312, 20, 0, 0 ) constant PushButton9 = createEx( PushButton, "Close child window", Window1, 240, 44, 108, 28, 0, 0 ) constant PushButton5 = createEx( PushButton, "Make Visible", Window1, 144, 92, 88, 28, 0, 0 ) constant PushButton6 = createEx( PushButton, "Move child off bottom", Window1, 240, 92, 108, 28, 0, 0 ) constant PushButton4 = createEx( PushButton, "Close", Window1, 280, 220, 88, 28, 0, 0 ) constant wLabel = createEx( LText, "", Window1, 40, 152, 308, 20, 0, 0 ) --------------------------------------------------------- -------------------------------------------------------------------------------- -- Window childWin constant childWin = createEx( Window, "Window 2", 0, Default, Default, 400, 300, 0, 0 ) --------------------------------------------------------- -------------------------------------------------------------------------------- procedure checkifVisible(sequence pButton) sequence wSize if isVisible(childWin) then setText(wLabel, pButton & ": child is visible") else setText(wLabel, pButton & ": child is NOT visible") end if wSize = getWindowRect(Window1) -- wSize = getWindowRect(Screen) setText(wLabel2, "Left=" & sprint(wSize[1]) & ", Top=" & sprint(wSize[2]) & ", Right=" & sprint(wSize[3]) & ", Bottom=" & sprint(wSize[4])) end procedure -------------------------------------------------------------------------------- procedure Window1_onOpen (integer self, integer event, sequence params)--params is () checkifVisible(getText(self)) end procedure setHandler( Window1, w32HOpen, routine_id("Window1_onOpen")) -------------------------------------------------------------------------------- procedure PushButton8_onClick (integer self, integer event, sequence params)--params is () openWindow(childWin, Normal) checkifVisible(getText(self)) end procedure setHandler( PushButton8, w32HClick, routine_id("PushButton8_onClick")) -------------------------------------------------------------------------------- procedure PushButton9_onClick (integer self, integer event, sequence params)--params is () closeWindow(childWin) checkifVisible(getText(self)) end procedure setHandler( PushButton9, w32HClick, routine_id("PushButton9_onClick")) -------------------------------------------------------------------------------- procedure PushButton3_onClick (integer self, integer event, sequence params)--params is () sequence size size = getCtlSize(childWin) setRect(childWin, 500, -1200, size[1], size[2], w32True) checkifVisible(getText(self)) end procedure setHandler( PushButton3, w32HClick, routine_id("PushButton3_onClick")) -------------------------------------------------------------------------------- procedure PushButton5_onClick (integer self, integer event, sequence params)--params is () sequence size size = getCtlSize(childWin) setRect(childWin, 500, 20, size[1], size[2], w32True) checkifVisible(getText(self)) end procedure setHandler( PushButton5, w32HClick, routine_id("PushButton5_onClick")) -------------------------------------------------------------------------------- procedure PushButton6_onClick (integer self, integer event, sequence params)--params is () sequence size size = getCtlSize(childWin) setRect(childWin, 500, 1200, size[1], size[2], w32True) checkifVisible(getText(self)) end procedure setHandler( PushButton6, w32HClick, routine_id("PushButton6_onClick")) -------------------------------------------------------------------------------- procedure PushButton4_onClick (integer self, integer event, sequence params)--params is () abort(0) end procedure setHandler( PushButton4, w32HClick, routine_id("PushButton4_onClick")) --------------------------------------------------------- WinMain( Window1,Normal )