TheSwamp
Code Red => VB(A) => Topic started by: Keith™ on September 21, 2004, 12:09:40 AM
-
Your mission, if you choose to accept, is to create a form in VBA that can be resized while the form is active....
Any takers?
I'll post something as soon as I figure out how to do it....
-
Just use the mouse events to determine if the left mouse is down and on the bottom edge, right edge, or lower right corner, then if it is dragged change the form's width and / or height (which is permissible) to reflect the mouse coordinates delta.
-
....well where is the code ? ...
and I thought it would be a little bit harder than that... I guess I need to think about it a little more huh...
-
Had I the time I'd be more than happy to bash it out, but alas ...
-
Had I the time I'd be more than happy to bash it out, but alas ...
...someone already has..... :wink:
No, I didn't write this (http://www.cadvault.com/index.php?page=code&cats=29&view=128) but I remembered seeing it recently.
-
must be something wrong with the web site, cause it won't let me log in (page not found error)
Who knows ....
-
I'm logged in but the link takes me to never-never land.........oh hum.
-
Well, I didn't realize that was a 'member only' area....sorry. Here's the disclaimer from the page
All of the code in the Public database was written by Randall Rath, members of the VBA Expresso (Credit given in the description field) community, or code released into public domain by MSDN and is to be considered "for example only." If you decide to use it in a production environment as is, you agree that you are doing so at your own risk. If you have suggestions for improvement or modification of any code samples please feel free to tell me about them.
And here's the code
Description:
Using the WIN32API and a bit of "slight of code" you can create a User Form that can be resized while running.
Snippet Code: - User Re-sizeable Form
Code removed to encourage development of new code.- JM
If you want to see the code, just go to CADVault.com, register and go to the Code Archives.
-
I have seen that before ... Oh well...
Jeff.. thanks for the code, but the purpose of this challenge was to make us better programmers, not go out and see if we could find the code already done elsewhere.
-
My apologies. This is what happens when I check the forum when I'm in the middle of actually doing some work. I somehow missed the "Challenge" in the original title. :oops:
So now the chalenge would be....Can this be done without calls to the Win32API?
-
No problem ...
I suspect it CAN be done, I just have not had the time to look into it ... been busy on other proggies
-
... well where is the code ? ...
:lol:
-
Here it is ....
Place in UserForm1 Code Window
'define these as global vars
Dim XPointPrev As Single
Dim YPointPrev As Single
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If XPointPrev = 0 Then
XPointPrev = X
End If
If YPointPrev = 0 Then
YPointPrev = Y
End If
If (Button = 1) And (Shift = 0) And (X > UserForm1.Width - 20) And (Y > UserForm1.Height - 50) Then
UserForm1.Width = UserForm1.Width + (X - XPointPrev)
UserForm1.Height = UserForm1.Height + (Y - YPointPrev)
XPointPrev = X
YPointPrev = Y
ElseIf (Button = 1) And (Shift = 0) And (X > UserForm1.Width - 20) Then
UserForm1.Width = UserForm1.Width + (X - XPointPrev)
XPointPrev = X
ElseIf (Button = 1) And (Shift = 0) And (Y > UserForm1.Height - 50) Then
UserForm1.Height = UserForm1.Height + (Y - YPointPrev)
YPointPrev = Y
End If
If (Button = 0) Then
XPointPrev = 0
YPointPrev = 0
End If
End Sub
-
Here it is ....
Place in UserForm1 Code Window
'define these as global vars
Dim XPointPrev As Single
Dim YPointPrev As Single
...
Wouldn't it be more correct to declare 'em
Private _
XPointPrev As Single, _
YPointPrev As Single
at the form level?
Said another way, does VB let you use DIM at the module | form level?
-
Either way I suppose... you can declare hem as private at form/module level and you can use DIM at both the module level and at the form level in VB as globals.
Personally, I seldom use private vars because of the simple fact I may need (or want) to access them from other modules.
Question is ... did it work for you?
Maybe it is bad coding practice but I declare them local while I am developing, then move them to global (if need be) when I am done.
I am thinking of another little challenge just so everyone can get their thinking caps on....
-
How about something to help us newbies to vba get started. Start something simple and develop it. Maybe use the cvs thingy?
-
Where is the CVS thingy?
-
I believe it's here. (http://theswamp.org/phpBB2/viewtopic.php?p=25668#25668)