Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Rick C. Hodgin
  Where is Rick C. Hodgin?
 Indianapolis
 Indiana - United States
 Rick C. Hodgin
 To: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 Tags
Subject: RE: Object is visible
Thread ID: 373653 Message ID: 373662 # Views: 91 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Forms
Date: Monday, March 25, 2013 2:19:14 AM         
   


> > Does anybody know of an easy (single-command) way to determine
> > if an object is visible on the form at the current time?
> > (Taking into account its parents, the page it might be on if
> > it's visible, etc.)
>
> I don't know really but I would try if:
> sys(1270, objtoclient(theObject,2)+1, objtoclient(theObject,1)+1) = theObject
> PS: Written off the top of my head parameters might not be exact.


Awesome. Very clever. I'll try it. Thank you, Cetin.

Best regards,
Rick C. Hodgin



---------------------
UPDATE: That function is desktop relative, so I wound up using:
*****
* Note:  This works for a top-level form.  If the form is inside
*        _screen, will need to include the commented, portions,
*        and possibly multiply each SYSMETRIC()s by 2.
*****
* SYSMETRIC(3) = width of sizable window border
* SYSMETRIC(4) = height of sizable window border
* SYSMETRIC(9) = height of title bar
*****

FUNCTION isObjectVisible
LPARAMETERS toObj
LOCAL lnX, lnY, loObj, llReturn

    * Are we good?
    IF TYPE("toObj") != "O"
        RETURN .F.  && The test is not valid, default to fail
    ENDIF

    * Get the desktop-relative X and Y coordinates
    lnX = OBJTOCLIENT(toObj,2) + 1 + SYSMETRIC(3) + OBJTOCLIENT(thisForm,2) && + OBJTOCLIENT(_screen,2)
    lnY = OBJTOCLIENT(toObj,1) + 1 + SYSMETRIC(4) + SYSMETRIC(9) + OBJTOCLIENT(thisForm,1) && + OBJTOCLIENT(_screen,1)

    * Is it our object?
    loObj = SYS(1270, lnX, lnY)
    IF TYPE("loObj") = "L"
        * No object exist there?
        RETURN .F.
    ENDIF

    * Is it an object?
    IF TYPE("loObj") = "O"
        * Is it a transparent shape?
        IF LOWER(loObj.baseclass) = "shape" and loObj.BackStyle = 0 && Transparent
            * Yes, try again
            loObj.Visible = .F.
            llReturn = isObjectVisible(toObj)
            lObj.Visible = .T.
        ELSE
            * Nope, we can do the direct test
            llReturn = (SYS(1270, lnX, lnY) = toObj)
        ENDIF
    ELSE
        llReturn = .F.
    ENDIF

    * Indicate our condition
    RETURN llReturn


ENTIRE THREAD

Object is visible Posted by Rick Hodgin @ 3/24/2013 10:19:32 PM
RE: Object is visible Posted by Cetin Basoz @ 3/25/2013 1:52:55 AM
RE: Object is visible Posted by Rick Hodgin @ 3/25/2013 2:19:14 AM
RE: Object is visible Posted by Rick Hodgin @ 3/29/2013 4:10:36 PM
RE: Object is visible Posted by Cetin Basoz @ 3/29/2013 8:47:15 PM
RE: Object is visible Posted by Rick Hodgin @ 3/30/2013 5:01:15 PM