Author Topic: (Challenge) Resizeable Form  (Read 12680 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Resizeable Form
« 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....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
(Challenge) Resizeable Form
« Reply #1 on: September 21, 2004, 12:17:21 AM »
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Resizeable Form
« Reply #2 on: September 21, 2004, 08:09:13 AM »
....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...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
(Challenge) Resizeable Form
« Reply #3 on: September 21, 2004, 08:20:41 AM »
Had I the time I'd be more than happy to bash it out, but alas ...
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Jeff_M

  • King Gator
  • Posts: 4086
  • C3D user & customizer
(Challenge) Resizeable Form
« Reply #4 on: September 21, 2004, 01:22:55 PM »
Quote from: MP
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 but I remembered seeing it recently.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Resizeable Form
« Reply #5 on: September 21, 2004, 02:17:19 PM »
must be something wrong with the web site, cause it won't let me log in (page not found error)

Who knows ....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

t-bear

  • Guest
(Challenge) Resizeable Form
« Reply #6 on: September 21, 2004, 02:22:13 PM »
I'm logged in but the link takes me to never-never land.........oh hum.

Jeff_M

  • King Gator
  • Posts: 4086
  • C3D user & customizer
(Challenge) Resizeable Form
« Reply #7 on: September 21, 2004, 02:44:03 PM »
Well, I didn't realize that was a 'member only' area....sorry.  Here's the disclaimer from the page
Quote from: Cadvault

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
Code: [Select]
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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Resizeable Form
« Reply #8 on: September 21, 2004, 04:28:53 PM »
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.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Jeff_M

  • King Gator
  • Posts: 4086
  • C3D user & customizer
(Challenge) Resizeable Form
« Reply #9 on: September 22, 2004, 12:14:13 PM »
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?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Resizeable Form
« Reply #10 on: September 22, 2004, 02:02:28 PM »
No problem ...
I suspect it CAN be done, I just have not had the time to look into it ... been busy on other proggies
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
(Challenge) Resizeable Form
« Reply #11 on: September 22, 2004, 09:40:47 PM »
... well where is the code ? ...

:lol:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Resizeable Form
« Reply #12 on: September 22, 2004, 11:07:35 PM »
Here it is ....

Place in UserForm1 Code Window
Code: [Select]

'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
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
(Challenge) Resizeable Form
« Reply #13 on: September 22, 2004, 11:23:29 PM »
Quote from: Keith
Here it is ....

Place in UserForm1 Code Window
Code: [Select]

'define these as global vars
Dim XPointPrev As Single
Dim YPointPrev As Single

...

Wouldn't it be more correct to declare 'em
Code: [Select]
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?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Resizeable Form
« Reply #14 on: September 22, 2004, 11:35:50 PM »
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....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie