CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: moving buttons

  1. #1
    Join Date
    Nov 2000
    Location
    Tokyo and Memphis
    Posts
    238

    moving buttons

    If you move a command button around the screen using a timer, the caption doesn't seem to stay crystal clear as it jumps, even if the jumps are very small. Is VB just not the sort of thing for this, or are command boxes just not the sort of object?

    Thanks

    Phil


  2. #2
    Join Date
    Jan 2001
    Location
    Germany
    Posts
    222

    Re: moving buttons

    Greetings!

    I don't exactly know what you're complaining about. I tried out moving a button around a window using a timer myself, it moves perfectly alright. So, what's the matter?

    Teamwork Software - Stuff That Does Something

  3. #3
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: moving buttons

    It should not do that but to force it to refresh itself, just use the Command1.Refresh() method after you move it to new location. It might help.

    -Cool Bizs

    Good Luck,
    -Cool Bizs

  4. #4
    Join Date
    Nov 2000
    Location
    Tokyo and Memphis
    Posts
    238

    Re: moving buttons

    I'm not mad, honostly.

    It's fine on my other computers but on my new computer it just looks awful. It's like the word turns to bold italic for .1 of a second and then slowly disovles into focus. I can't change the refresh rate of the screen - could it be that - or a monitor problem?

    MANY MANY thanks

    Phil



  5. #5
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: moving buttons

    You can check if it is a problem of your monitor by replacing this new monitor by the old one.

    An alternative, if you still face problems of flicker, (and have the time and interest to rewrite,) you can use a picturebox control, with the DrawFrameControl() API and TextOut() API (or the Print Method) to "draw" a command button.

    Following is a code that uses a picture box to simulate a command button. Set the borderstyle of the picturebox to none, autoredraw to true and scalemode to Pixel.


    private Declare Function DrawFrameControl Lib "user32" (byval hDC as Long, lpRect as RECT, byval un1 as Long, byval un2 as Long) as Long
    private Type RECT
    Left as Long
    Top as Long
    Right as Long
    Bottom as Long
    End Type
    private Const DFC_BUTTON = 4
    private Const DFCS_BUTTONPUSH = &H10
    private Const DFCS_PUSHED = &H200
    Dim aRect as RECT

    private Sub Form_Load()
    aRect.Top = 0
    aRect.Left = 0
    aRect.Right = Picture1.ScaleWidth
    aRect.Bottom = Picture1.ScaleHeight
    DrawFrameControl Picture1.hDC, aRect, DFC_BUTTON, DFCS_BUTTONPUSH
    Picture1.Refresh
    End Sub

    private Sub Picture1_MouseDown(Button as Integer, Shift as Integer, X as Single, Y as Single)
    DrawFrameControl Picture1.hDC, aRect, DFC_BUTTON, DFCS_BUTTONPUSH Or DFCS_PUSHED
    Picture1.Refresh
    End Sub

    private Sub Picture1_MouseUp(Button as Integer, Shift as Integer, X as Single, Y as Single)
    DrawFrameControl Picture1.hDC, aRect, DFC_BUTTON, DFCS_BUTTONPUSH
    Picture1.Refresh
    End Sub





  6. #6
    Join Date
    Nov 2000
    Location
    Tokyo and Memphis
    Posts
    238

    Re: moving buttons

    THANKS

    Most interesting - I shall try out your code. Thanks again.

    I'm sure it is the monitor however that is causing the problem - a lap top so I can't stick another monitor on it - but the program works fine on 6 ohter computers including a lap top.

    Thaks again.

    Phil


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured