beebop
asked on
picture sizes
how can i enable a user to change the size of an image box at run time by clicking on it and dragging a side or corner out
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
just and idea .. use another form, make the image box the same size, then in the form_resize event resize the image box to be the same size
your question got me curious, so I created my idea as stated before: Copy the following text to notepad, then save as form1.frm:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4035
ClientLeft = 60
ClientTop = 360
ClientWidth = 6420
LinkTopic = "Form1"
ScaleHeight = 4035
ScaleWidth = 6420
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Sub Form_GotFocus()
Form2.Top = Me.Top + Me.Height / 2
Form2.Left = Me.Left + Me.Width / 2
SetWindowPos Form2.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
Private Sub Form_Load()
Form2.Show
Form2.Top = Me.Top + Me.Height / 2
Form2.Left = Me.Left + Me.Width / 2
SetWindowPos Form2.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
Private Sub Form_LostFocus()
Form2.Top = Me.Top + Me.Height / 2
Form2.Left = Me.Left + Me.Width / 2
SetWindowPos Form2.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
Private Sub Form_Resize()
Form2.Top = Me.Top + Me.Height / 2
Form2.Left = Me.Left + Me.Width / 2
End Sub
then copy the next text and save as form2.frm:
VERSION 5.00
Begin VB.Form Form2
ClientHeight = 3180
ClientLeft = 60
ClientTop = 60
ClientWidth = 4680
ClipControls = 0 'False
ControlBox = 0 'False
LinkTopic = "Form2"
MaxButton = 0 'False
Moveable = 0 'False
ScaleHeight = 3180
ScaleWidth = 4680
StartUpPosition = 1 'CenterOwner
Begin VB.Image Image1
Height = 3180
Left = 0
Picture = "Form2.frx":0000
Stretch = -1 'True
Top = 15
Width = 4695
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
End Sub
Private Sub Form_Resize()
Image1.Width = Me.Width
Image1.Height = Me.Height
Image1.Top = 0
Image1.Left = 0
End Sub
add both to a project and set form1 as startup
You may want to add more checking, to make sure form2 does not get sized beyond form1 and so forth . .. but it's a start.
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4035
ClientLeft = 60
ClientTop = 360
ClientWidth = 6420
LinkTopic = "Form1"
ScaleHeight = 4035
ScaleWidth = 6420
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Sub Form_GotFocus()
Form2.Top = Me.Top + Me.Height / 2
Form2.Left = Me.Left + Me.Width / 2
SetWindowPos Form2.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
Private Sub Form_Load()
Form2.Show
Form2.Top = Me.Top + Me.Height / 2
Form2.Left = Me.Left + Me.Width / 2
SetWindowPos Form2.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
Private Sub Form_LostFocus()
Form2.Top = Me.Top + Me.Height / 2
Form2.Left = Me.Left + Me.Width / 2
SetWindowPos Form2.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
Private Sub Form_Resize()
Form2.Top = Me.Top + Me.Height / 2
Form2.Left = Me.Left + Me.Width / 2
End Sub
then copy the next text and save as form2.frm:
VERSION 5.00
Begin VB.Form Form2
ClientHeight = 3180
ClientLeft = 60
ClientTop = 60
ClientWidth = 4680
ClipControls = 0 'False
ControlBox = 0 'False
LinkTopic = "Form2"
MaxButton = 0 'False
Moveable = 0 'False
ScaleHeight = 3180
ScaleWidth = 4680
StartUpPosition = 1 'CenterOwner
Begin VB.Image Image1
Height = 3180
Left = 0
Picture = "Form2.frx":0000
Stretch = -1 'True
Top = 15
Width = 4695
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
End Sub
Private Sub Form_Resize()
Image1.Width = Me.Width
Image1.Height = Me.Height
Image1.Top = 0
Image1.Left = 0
End Sub
add both to a project and set form1 as startup
You may want to add more checking, to make sure form2 does not get sized beyond form1 and so forth . .. but it's a start.
ASKER
the answer didn't really show an understanding of what I was after, maybe I didnt make myself clear. I've increased the points as the comments from Beedleguis were excellent. It worked and he knew exactly what I wanted.
hmmm . . then why did you accept s_lavie's answer?
ASKER
Sorry, its the first time i've used this, I wasn't sure what to do. I didnt realise the points went to the person. Can you explain how it works and I won't make the mistake again, if theres anyway of changing or reversing it then let me know and i'll gladly do that. It seems ridiculous that s_lavie should get the points for his answer. I could have given his answer, it was obvious.
It's alright .. next time just reject the worng answer.. then ask the expert with the right answer to lock your question. It would be nice if you'd post a free question in the customer service area describing the situation, that way points will be awarded where the are earned. By the way, did you get your sizable image working correctly? I can provide more help if needed. Make sure to include the q#Q.10183728 if you post a request in customer service.
ASKER
OK beedleGuis next time Ill try and get it right. Yes your answer worked well, initially there was a problem with loading the image box on form2, so I deleted it and added another and it worked fine. Ive posted a question on customer service.
thanks for your help.
thanks for your help.
BeedleGuis: Please post an answer to https://www.experts-exchange.com/bin/EQ.10184674
darinw
darin@experts-exchange
[My email notification is currently not working]
darinw
darin@experts-exchange
[My email notification is currently not working]