Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse movement makes controls disappear

Status
Not open for further replies.

wilfranz

Technical User
Oct 4, 2003
122
0
0
US
Hello friends,

I have something really weird happening. I am developing a new project which is in very early phase, and so it has very few controls as yet (i.e. fewer things to go wrong). Essentially this app is designed to store and draw real estate legal lot descriptions and shapes (to scale), and to calculate acreage. Thus far it has only progressed to the phase of drawing the shape, by using the Form.Line control and a little trigonometry.

THE PROBLEM: My app does OK drawing the shapes (though I am having a little trouble with the aspect ratio of my screen pixels, for which I am working on a correction in the DrawLot method). BUT... when the mouse is placed over either of the CommandGroups, the entire form blanks out... everything except the blank form disappears... the drawn shape (usually an irregular polygon) and all other controls disappear!

Then, after the form blanks out, if the mouse is clicked on the (now invisible) area where a CoommandGroup has been placed, the form's controls and the drawn polygon become visible again. Even more strange is that depending upon which control is clicked, other controls become only partially visualized (e.g. after clicking on the "Switch Lot" button, only one of the four buttons on the other command group becomes visible. After redrawing the polygon or switching to another in the table, it all becomes visible and remains so (no more bad behavior).

Can anyone tell me what's going on?

Following is the code, (from the Class Browser)
Code:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


**************************************************
*-- Form:         form1 (c:\myapps\lotdraw\lotdraw.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   05/16/04 09:50:05 AM
*
DEFINE CLASS form1 AS form

    Top = 0
    Left = 0
    Height = 622
    Width = 994
    ShowWindow = 2
    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"

    ADD OBJECT commandgroup2 AS commandgroup WITH ;
        AutoSize = .F., ;
        ButtonCount = 4, ;
        Value = 1, ;
        Height = 37, ;
        Left = 768, ;
        Top = 575, ;
        Width = 204, ;
        Name = "Commandgroup2", ;
        Command1.AutoSize = .F., ;
        Command1.Top = 5, ;
        Command1.Left = 5, ;
        Command1.Height = 27, ;
        Command1.Width = 47, ;
        Command1.Caption = "\<Left", ;
        Command1.Name = "Command1", ;
        Command2.AutoSize = .F., ;
        Command2.Top = 5, ;
        Command2.Left = 54, ;
        Command2.Height = 27, ;
        Command2.Width = 47, ;
        Command2.Caption = "\<Right", ;
        Command2.Name = "Command2", ;
        Command3.AutoSize = .F., ;
        Command3.Top = 5, ;
        Command3.Left = 103, ;
        Command3.Height = 27, ;
        Command3.Width = 47, ;
        Command3.Caption = "\<Up", ;
        Command3.Name = "Command3", ;
        Command4.AutoSize = .F., ;
        Command4.Top = 5, ;
        Command4.Left = 152, ;
        Command4.Height = 27, ;
        Command4.Width = 47, ;
        Command4.Caption = "\<Down", ;
        Command4.Name = "Command4"

    ADD OBJECT commandgroup1 AS commandgroup WITH ;
        AutoSize = .F., ;
        ButtonCount = 2, ;
        Value = 1, ;
        Height = 66, ;
        Left = 18, ;
        Top = 546, ;
        Width = 80, ;
        Name = "Commandgroup1", ;
        Command1.AutoSize = .F., ;
        Command1.Top = 5, ;
        Command1.Left = 5, ;
        Command1.Height = 27, ;
        Command1.Width = 70, ;
        Command1.Caption = "\<Switch lot", ;
        Command1.Name = "Command1", ;
        Command2.AutoSize = .F., ;
        Command2.Top = 34, ;
        Command2.Left = 5, ;
        Command2.Height = 27, ;
        Command2.Width = 70, ;
        Command2.Caption = "\<New Lot", ;
        Command2.Name = "Command2"

    ADD OBJECT commandgroup3 AS commandgroup WITH ;
        AutoSize = .F., ;
        ButtonCount = 2, ;
        Value = 1, ;
        Height = 37, ;
        Left = 525, ;
        Top = 575, ;
        Width = 134, ;
        Name = "Commandgroup3", ;
        Command1.AutoSize = .F., ;
        Command1.Top = 5, ;
        Command1.Left = 5, ;
        Command1.Height = 27, ;
        Command1.Width = 61, ;
        Command1.Caption = "\<Larger", ;
        Command1.Name = "Command1", ;
        Command2.AutoSize = .F., ;
        Command2.Top = 5, ;
        Command2.Left = 68, ;
        Command2.Height = 27, ;
        Command2.Width = 61, ;
        Command2.Caption = "\<Smaller", ;
        Command2.Name = "Command2"

    ADD OBJECT label1 AS label WITH ;
        AutoSize = .T., ;
        FontBold = .T., ;
        FontSize = 10, ;
        Alignment = 2, ;
        Caption = "Label1", ;
        Height = 18, ;
        Left = 415, ;
        Top = 11, ;
        Width = 45, ;
        Name = "Label1"

    PROCEDURE drawlot
        ** METHOD: drawlot
        *TABLES: LotList.dbf and LotData.dbf
        *PLAN: Use screen pixels as a matrix of one-
        *foot units. The aspect ratio will need to be 
        *developed. Simple actual screen measure is 
        *0.9372 vert = 1.000 horiz.
        *The SCALE field in LotList table is a multiplier
        *to allow full screen usage regardless of lot size.

        with this
            select lotlist
            .currentx = basex
            .currenty = basey
            .drawwidth = 3
            SELECT lotdata
            GO bottom
            nLastRec = RECNO()
            GO top
            SCAN 
                *Provide for two lines of closure, 1 by 
                *bearings, and 2nd to join Point-of-
                *beginning.
                IF RECNO() = nLastRec
                    nCurrX = .currentX
                    nCurrY = .currentY
                    .line(lotlist.basex, lotlist.basey)
                    .currentX = nCurrX
                    .currentY = nCurrY
                    .forecolor = RGB(175,175,175)
                ENDIF

                do case
                    case azimuth >= 270
                        nAngle = 360 - azimuth
                        xSign = -1
                        ySign = -1
                    case azimuth >= 180
                        nAngle = azimuth - 180
                        xSign = -1
                        ySign = 1
                    case azimuth >= 90
                        nAngle = 180 - azimuth
                        xSign = 1
                        ySign = 1
                    otherwise
                        nAngle = azimuth
                        xSign = 1
                        ySign = -1
                endcase
                nYLen = cos(DTOR(nAngle)) * feet * .9372 * ySign
                nXlen = sin(DTOR(nAngle)) * feet * xSign
                nNewX = .currentX + (nXlen * lotlist.scale)
                nNewY = .currentY + (nYlen * lotlist.scale)
                .line(nNewX, nNewY)
            ENDSCAN
            .forecolor = RGB(0,0,0)

            nAcreage = .acreage()
            .label1.caption = ALLTRIM(STR(nAcreage,6,2)) ;
               + " acres"
        endwith
    ENDPROC

    PROCEDURE acreage
        *METHOD: numacres
            SELECT lotdata
            SET ORDER TO TAG current
            DIMENSION x[1],y[1]
            x[1]=lotlist.basex
            y[1]=lotlist.basey
            cntr=1
            grandsum=0
            SCAN
                cntr=cntr+1
                DIMENSION x[cntr],y[cntr]
                *Parse and calculate x & y from BEARING 
                degrees = VAL(SUBSTR(bearing,3,2))
                minutes = VAL(SUBSTR(bearing,7,2))
                seconds = VAL(SUBSTR(bearing,11,2))
                secs = seconds + (minutes * 60)
                fractdegr = secs / 3600
                degrees = degrees + fractdegr
                vecstr=LEFT(bearing, 1)+RIGHT(bearing, 1)
                xx = SIN(DTOR(degrees)) * feet
                yy = COS(DTOR(degrees)) * feet
                DO CASE
                    CASE vecstr= "NE"
                        yy = -yy
                    CASE vecstr= "SE"
                        * x and y are both +
                    CASE vecstr= "SW"
                        xx = -xx
                    CASE vecstr= "NW"
                        xx = -xx
                        yy = -yy
                ENDCASE
                *------------------------------------------
                x[cntr]=x[cntr-1]+xx
                y[cntr]=y[cntr-1]+yy
                sum=(x[cntr]*y[cntr-1]) - ;
                    (x[cntr-1] * y[cntr])
                grandsum=grandsum+sum
            ENDSCAN
            area=ABS(grandsum/2)
            acres=area/43560
        RETURN acres
    ENDPROC

    PROCEDURE Load
        set default to \myapps\lotdraw
        close all
        use lotlist in 0
        use lotdata in 0 excl
    ENDPROC

    PROCEDURE Init
        DO FORM lotselector
        SELECT lotdata
        cCmdStr = "index on linenum for lotidn = " ;
                  + CHR(34) + alltr(lotlist.lotidn) ;
                  + CHR(34) + " tag current"
        &cCmdStr
        this.drawlot()
    ENDPROC

    PROCEDURE commandgroup2.Click
        SELECT lotlist
        DO case
            CASE this.Value = 1
                replace lotlist.basex WITH lotlist.basex-25
            CASE this.Value = 2
                replace lotlist.basex WITH lotlist.basex+25
            CASE this.Value = 3
                replace lotlist.basey WITH lotlist.basey-25
            CASE this.Value = 4
                replace lotlist.basey WITH lotlist.basey+25
        ENDCASE
        thisform.cls
        thisform.drawlot()
    ENDPROC

    PROCEDURE commandgroup1.Click
        DO case
            CASE this.Value = 1
                DO FORM lotselector
                SELECT lotdata
                cCmdStr = ;
                    "index on linenum for lotidn = " ;
                    + CHR(34) + alltr(lotlist.lotidn) ;
                    + CHR(34) + " tag current"
                &cCmdStr
                thisform.cls
                thisform.drawlot()
        endcase
    ENDPROC

    PROCEDURE commandgroup3.Click
        SELECT lotlist
        DO case
            CASE this.Value=1
                replace scale WITH lotlist.scale+.10
            CASE this.Value=2
                replace scale WITH lotlist.scale-.10
        ENDCASE
        thisform.Cls
        SELECT lotdata
        thisform.drawlot()
    ENDPROC

ENDDEFINE
*
*-- EndDefine: form1
**************************************************

TIA

BillvV

 


First off, what version of VFP are you using? Does it have that latest service packs applied?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks for your reply, Mike.

I'm running VFP 8.0 SP1.

BvV
 
Hi wilfranz,

I suggest you start by removing the Drawlot and Acreage methods, and seeing if the problem goes away. If it does, start adding back code from those two methods a bit a time, until the problem reappears. That will tell you roughly which code is causing the difficulty.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hello Mike,

Many thanks for your thoughtful reply, and what I know took at least a few minutes to glance through the code.

Your trouble shooting tip found the problem area. I narrowed it down to the two lines in the DrawLot method which use the .Line(nXcoord, nYcoord) graphics command. There are 2 such lines in the code. If they are both remarked-out, the bad behavior quits. If even one of the .Line commands is replaced, the trouble returns.

Additional clue? -- After posting my question I had also added a .Print([cString]) to the DrawLot procedure. This also causes the same bad behavior.

Can I conclude that it is graphics method calls which cause the target behavior?

So, that's the "what". What's the "why"? And is there a fix?

Thanks very much for your help and comments.

BvV
 
Hi guys.

A comment from Bernard Bout, Brisbane, Aus., on Foxite, suggested I turn OFF the Themes property of the Form. That corrected the weird behavior. (!!!)

I continue to get caught up by weird "stuff" from the Themes capability of VFP8. Do you have any comments about what all was happening here?

Thanks again

BvV
 
wilfranz,

I'm glad you've got it sorted. I don't understand why the problem occurred, but I have heard of other weird things happening with themes, so it's not surprising.

Mike




Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
I had similar problem with old forms (FPW 2.6) used under VFP8 - the form kept disappearing every time I moved mouse over commandgroup or a button.

I believe it was caused by Hot Tracking / Hover feature of VFP8 - it seems it doesn't like certain types of layout (it is described in the help)

Disabling the entire Themes Support by using SYS(2700, 0) fixed all problems I had with those old forms.

I also figured out that changing the Special Effect to 3D (from Plain) was fixing the problem for some forms (but it was useless with the old FPW 2.6 forms)
 
I had a somewhat similar problem tonight and just solved it. Maybe my solution will work for you too, but I'm not sure. For many other suggestions I grouped together, see thread184-1035406. The best suggestion is here, especially if your problem is on Windows XP but not earlier Windows versions:
VFP 9.0 Help says this:
Themes said:
Note:
When Themes are enabled, you should avoid using the CLEAR command for forms because it might cause paint issues with themed controls, such as command buttons, that have mouse hovering effects.

You can set _SCREEN.Themes property to False (.F.) to disable Themes entirely in Visual FoxPro.

Note:
When you set _SCREEN.Themes property, you do not actually alter the current state of Themes set at the operating system level. You should use SYS(2700) - Enables Windows XP Themes to check the current state of Themes.
So, what worked for me? I searched my forms and found one CLEAR command. As noted above, it is not appropriate for a form, so I removed it, and my problem is gone.

Did your computers with the disappearing buttons all use Windows XP? Do you have any other code there than what you posted above? I suggest you search your project for any CLEAR commands in your forms, remove them all and test it again. Let us know if you find a CLEAR command.

dbMark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top