|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Anyway to move Image control at runtimeWhat I am trying to do is be able to move an image control around a form on
runtime. I would prefer to use an Imagebox (because the imagebox control can automatically resize image to control), however I would go with picturebox if this can't be done with an ImageBox. I would appreciate any pointers. Thanks. On Sat, 6 Dec 2008 09:55:36 -0500, "jpBless"
<jp3blessNoSpam@hotmail.com> wrote: >What I am trying to do is be able to move an image control around a form on Do you mean move the image box using the mouse?>runtime. I would prefer to use an Imagebox (because the imagebox control can >automatically resize image to control), however I would go with picturebox >if this can't be done with an ImageBox. I would appreciate any pointers. >Thanks. > Ed Yes ED... thanks for pointing that out. Ideally I would want the user to be
able to move the picture box by pressing and holding down the mouse, I would like the picture to appear at the last spot it was moved to when the app loads next time. Show quoteHide quote "Ed" <nospam@hotmail.com> wrote in message news:q29lj4l7ptsmoragifveb4t712vrtsn3j4@4ax.com... > On Sat, 6 Dec 2008 09:55:36 -0500, "jpBless" > <jp3blessNoSpam@hotmail.com> wrote: > >>What I am trying to do is be able to move an image control around a form >>on >>runtime. I would prefer to use an Imagebox (because the imagebox control >>can >>automatically resize image to control), however I would go with picturebox >>if this can't be done with an ImageBox. I would appreciate any pointers. >>Thanks. >> > > Do you mean move the image box using the mouse? > Ed On Sat, 6 Dec 2008 12:11:17 -0500, "jpBless" <jp3blessNoSpam@hotmail.com> wrote: Option Explicit>Yes ED... thanks for pointing that out. Ideally I would want the user to be >able to move the picture box by pressing and holding down the mouse, I would >like the picture to appear at the last spot it was moved to when the app >loads next time. > Private bPressed As Boolean Private iX As Long, iY As Long Private Sub Form_Load() Dim t As Long, l As Long t = GetSetting(App.CompanyName, App.Title, "Image1_Top", 0) l = GetSetting(App.CompanyName, App.Title, "Image1_Left", 0) Image1.Move l, t End Sub Private Sub Form_Unload(Cancel As Integer) ' save image1 position SaveSetting App.CompanyName, App.Title, "Image1_Top", Image1.Top SaveSetting App.CompanyName, App.Title, "Image1_Left", Image1.Left End Sub Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then bPressed = True iX = X iY = Y End If End Sub Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If bPressed = True Then Image1.Left = Image1.Left + X - iX Image1.Top = Image1.Top + Y - iY End If End Sub Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) bPressed = False End Sub hth, Ed Give this a try (it uses Shift coupled with the left mouse button to move
the Image1 control)... '********** START OF CODE ********** Private Type POINTAPI X As Long Y As Long End Type Private Declare Function GetCursorPos& Lib "user32" _ (lpPoint As POINTAPI) Dim Initialized As Boolean Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) Static LastPoint As POINTAPI Dim CurrentPoint As POINTAPI If Button = vbLeftButton And Shift = vbShiftMask Then GetCursorPos CurrentPoint If Not Initialized Then LastPoint.X = CurrentPoint.X LastPoint.Y = CurrentPoint.Y Initialized = True End If With Image1 .Move .Left + Screen.TwipsPerPixelX * (CurrentPoint.X - _ LastPoint.X), .Top + Screen.TwipsPerPixelY * _ (CurrentPoint.Y - LastPoint.Y) End With LastPoint = CurrentPoint End If End Sub Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, _ X As Single, Y As Single) Initialized = False End Sub '********** END OF CODE ********** -- Show quoteHide quoteRick (MVP - Excel) "jpBless" <jp3blessNoSpam@hotmail.com> wrote in message news:uONsnW8VJHA.3740@TK2MSFTNGP06.phx.gbl... > Yes ED... thanks for pointing that out. Ideally I would want the user to > be able to move the picture box by pressing and holding down the mouse, I > would like the picture to appear at the last spot it was moved to when the > app loads next time. > > > > "Ed" <nospam@hotmail.com> wrote in message > news:q29lj4l7ptsmoragifveb4t712vrtsn3j4@4ax.com... >> On Sat, 6 Dec 2008 09:55:36 -0500, "jpBless" >> <jp3blessNoSpam@hotmail.com> wrote: >> >>>What I am trying to do is be able to move an image control around a form >>>on >>>runtime. I would prefer to use an Imagebox (because the imagebox control >>>can >>>automatically resize image to control), however I would go with >>>picturebox >>>if this can't be done with an ImageBox. I would appreciate any pointers. >>>Thanks. >>> >> >> Do you mean move the image box using the mouse? >> Ed > > "jpBless" <jp3blessNoSpam@hotmail.com> wrote in message Both a PictureBox and a Image Control are capable of displaying a resized news:efmizK7VJHA.3908@TK2MSFTNGP06.phx.gbl... > What I am trying to do is be able to move an image control around > a form on runtime. I would prefer to use an Imagebox (because the > imagebox control can automatically resize image to control), however > I would go with picturebox if this can't be done with an ImageBox. picture, but in the case of the PictureBox you need to draw the picture into it at the size you require whereas the Image Control, as you have noted, draws it at the appropriate size automatically for you. So essentially you can use either of them for your purposes. When you say that you want to move the control around a Form at runtime, do you mean that you want to move it in code or do you want to allow the user to move it using the mouse? For moving it in code you just need to set its Left and Top properties to wherever you want it to be, incrementing them with a slight time delay if you want a visible motion rather than a "jump" from one place to another. For allowing the user to move it you can place suitable code in the Control's MouseMove event. Post back with more details of exactly what it is you wish to do. Mike Thanks Mike for responding
Ideally I would want the user to be able to move the picture box (to where ever he/she desires on the form) by pressing and holding down the mouse, I would like the picture to appear at the last spot it was moved to when the app loads next time. Thanks for responding Show quoteHide quote "Mike Williams" <M***@WhiskyAndCoke.com> wrote in message news:%23DAvA67VJHA.1220@TK2MSFTNGP04.phx.gbl... > "jpBless" <jp3blessNoSpam@hotmail.com> wrote in message > news:efmizK7VJHA.3908@TK2MSFTNGP06.phx.gbl... > >> What I am trying to do is be able to move an image control around >> a form on runtime. I would prefer to use an Imagebox (because the >> imagebox control can automatically resize image to control), however >> I would go with picturebox if this can't be done with an ImageBox. > > Both a PictureBox and a Image Control are capable of displaying a resized > picture, but in the case of the PictureBox you need to draw the picture > into it at the size you require whereas the Image Control, as you have > noted, draws it at the appropriate size automatically for you. So > essentially you can use either of them for your purposes. > > When you say that you want to move the control around a Form at runtime, > do you mean that you want to move it in code or do you want to allow the > user to move it using the mouse? For moving it in code you just need to > set its Left and Top properties to wherever you want it to be, > incrementing them with a slight time delay if you want a visible motion > rather than a "jump" from one place to another. For allowing the user to > move it you can place suitable code in the Control's MouseMove event. Post > back with more details of exactly what it is you wish to do. > > Mike > > > "jpBless" <jp3blessNoSpam@hotmail.com> wrote in message I see Ed has beaten me to it and posted some code for you. His code should news:eX2cxY8VJHA.5520@TK2MSFTNGP03.phx.gbl... > Thanks Mike for responding. Ideally I would want the user > to be able to move the picture box (to where ever he/she > desires on the form) by pressing and holding down the > mouse, I would like the picture to appear at the last spot > it was moved to when the app loads next time. Thanks for responding be fine for your needs so there is no need for me to respond other than to say that if you also want to allow the user to resize the image using the mouse then post again. Mike Thanks very much Ed, Rick, Mike... I appreciate your help sooo much.
Show quoteHide quote "jpBless" <jp3blessNoSpam@hotmail.com> wrote in message news:efmizK7VJHA.3908@TK2MSFTNGP06.phx.gbl... > What I am trying to do is be able to move an image control around a form > on runtime. I would prefer to use an Imagebox (because the imagebox > control can automatically resize image to control), however I would go > with picturebox if this can't be done with an ImageBox. I would appreciate > any pointers. Thanks. >
SendMessage and BM_CLICK
Adding Doctype to XML Recommended IDE for the PocketPC Dim WithEvents * As HTMLDocument with an Iframe - access denied!? Automatic determine .Rows in MSHFLexgrid form must be modeless but should behave modal Access Rights All Users folder convert Unicode string Ultima de aesthetica vb. user control |
|||||||||||||||||||||||