Solved

Moving  Forms  as they are. (intact)

Posted on 2004-08-15
14
177 Views
Last Modified: 2010-05-02
How Can i move my form as it is ?

For example when i move a  form with the  mouse up down left right
the form disappears and you get a square box outline , when you let the mouse go
the form appears  again. this is standard when moving any form with windows.

So basically i would like to move my form as it is without it disappearing and
then appearing when you let the mouse button go.

How can i code this ?

thankyou Experts


 

0
Comment
Question by:Jimmyx1000
  • 5
  • 4
  • 2
  • +2
14 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 11807189
In Windows 2000, there is a checkbox captioned 'Show window properties while dragging', under the 'Effects' tab of the 'Display properties' dialogue.
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 250 total points
ID: 11807250
You can get something like it with this code.

Option Explicit
Dim gX As Single
Dim gY As Single
Dim Oldleft  As Single
Dim OldTop As Single
Dim gDragging As Boolean

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
OldTop = Me.Top
Oldleft = Me.Left
gX = X
gY = Y
gDragging = True
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If gDragging Then
Me.Move Oldleft + X - gX, OldTop + Y - gY
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
gDragging = False
End Sub


0
 
LVL 8

Expert Comment

by:SNilsson
ID: 11807260
You can set a the registry setting from with in VB:

HKEY_CURRENT_USER\Control Panel\Desktop\DragFullWindows

Set this value to 1
0
 
LVL 8

Expert Comment

by:SNilsson
ID: 11807264

..And just so you know it, a reboot is needed for it to take effect (possibly only a log off/log on).
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11807428
In XP in the Display properties dialog it's under the Appearance tab. This tab contains a button called "Effects..." and it can be found in there.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 11807447
Jimmyx1000
You have 13 open questions (including this one). I suggest that you have a look and see if any of them can be closed.
Cheers, Graham
0
 

Author Comment

by:Jimmyx1000
ID: 11816351
GrahamSkan,  i cant get your code to work

can you accomadate your code to work with a standard  vb form

Much appreciated expert.



0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 11817056
Hi Jimmyx1000
This code works in Windows 2000 with VB6. The effect is rather jittery and not to be recommended over the method built in to the operating system that can be enabled according to my first comment (by checking: 'Show window properties while dragging').
What versions of windows and of  VB are you using?
Graham
0
 

Author Comment

by:Jimmyx1000
ID: 11817217
GrahamSkan  

Im using windows 2000 and vb6

Id like to make this drag feature OS independent.

How can i code this with a standard basic form

thanks GrahamSkan  

0
 
LVL 7

Accepted Solution

by:
Burbble earned 250 total points
ID: 11817372
Here's some code I wrote based on the same principle of GrahamSkan's...

Add a tmrDragging to a Form, with an interval of 1
-----
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Dim CurrentPosition As POINTAPI
Dim OldPosition As POINTAPI
Dim OldLeft As Integer
Dim OldTop As Integer

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    GetCursorPos OldPosition
    OldLeft = Me.Left / Screen.TwipsPerPixelX
    OldTop = Me.Top / Screen.TwipsPerPixelY
    tmrDragging.Enabled = True
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    tmrDragging.Enabled = False
End Sub

Private Sub tmrDragging_Timer()
    GetCursorPos CurrentPosition
    Me.Move Screen.TwipsPerPixelX * (OldLeft + CurrentPosition.X - OldPosition.X), Screen.TwipsPerPixelY * (OldTop + CurrentPosition.Y - OldPosition.Y)
End Sub
-----

-Burbble
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11817380
>> Add a tmrDragging to a Form, with an interval of 1

Should have read:

Add a Timer with an interval of 1, named tmrDragging, to a Form.

-Burbble
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 11818032
Burbble's code improves the performance. You might like to add this bit, to ensure that the timer is set up.

Sub Form_Load()
    tmrDragging.Enabled = False
    tmrDragging.Interval = 20
End Sub

Neither set of code is OS version-dependent. However, the drag only works if you click on the form body - not the title area.
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11823793
>> tmrDragging.Enabled = False

Whoops, forgot to mention that, thanks :)

>> However, the drag only works if you click on the form body - not the title area.

This is true...

-Burbble
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11909226
Thanks for the points, glad I could help :-)

-Burbble
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now