drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box)
drag image in picbox (must be picture box) drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
Go Back  Xtreme Visual Basic Talk > > > drag image in picbox (must be picture box)


Reply
 
Thread Tools Display Modes
  #21  
Old 10-25-2016, 02:35 PM
passel's Avatar
passeldrag image in picbox (must be picture box) passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default


Quote:
Originally Posted by starmanMike View Post
...
But when I try to drag, the picture doesn't move and shudders madly, even for a short time after I release the mouse button.
... Maybe there is simply no solution?
No, I think Diletante's post (#6) was the simple solution.
There are a couple of reasons the picture would shudder madly but perhaps the most likely is that the scalemode of your inner picturebox and outer picturebox didn't match.
A second possibility is the inner picturebox wasn't parented in the output picturebox, which could still result in a scalemode mismatch.

In any case, here is a quick example project, doing the same thing D's code did, but the past history values are kept as static variables in the MouseMove event and updated in that event whenever the mouse button is not pressed. I just added code in the form load to create a "chart" in the inner picturebox (picture2) so you have something to see when dragging around.
Code:
Option Explicit

Private Sub Form_Load()
  Dim w As Integer, h As Integer
  Dim x As Single, y As Single, s As Single
  Dim i As Integer
  Randomize
  
  Picture1.ScaleMode = vbPixels
  With Picture2
    .Width = 2 * Picture1.ScaleWidth
    .Height = 2 * Picture1.ScaleHeight
    .ScaleMode = vbPixels
     w = .ScaleWidth - 3
     h = .ScaleHeight - 3
    .AutoRedraw = True
    .FillColor = vbRed
    .ForeColor = vbBlack
    .FillStyle = vbFSSolid
    For i = 1 To 500
      x = Rnd * w
      y = Rnd * h
      s = 3 + Rnd * 7
      Picture2.Circle (x, y), s
    Next
    .FillStyle = vbFSTransparent
    .DrawWidth = 3
    Picture2.Line (1, 1)-(.ScaleWidth - 3, .ScaleHeight - 3), vbRed, B
  End With
  
End Sub

Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  Static lastX As Single, lastY As Single
  If Button And vbLeftButton Then
    With Picture2
      .Move .Left + (x - lastX), .Top + (y - lastY)
    End With
  Else
    lastX = x: lastY = y
  End If
End Sub
Attached Files
File Type: zip ScrollChart.zip (1.4 KB, 3 views)
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #22  
Old 10-31-2016, 08:24 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 289
Default

OK - thanks. Downloaded the zip file and ran the project. Instantly on running I get a popup saying that the image file can't be found - but it's there! In the same folder as all the project files. Help!
Reply With Quote
  #23  
Old 10-31-2016, 07:43 PM
dilettante's Avatar
dilettantedrag image in picbox (must be picture box) dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

When a program uses a relative file path, that path is relative to the current directory.

If you do something unusual, such as starting the VB6 editor separately instead of by running it via its file association with a VBP file the current directory is the directory of the IDE itself (VB6.EXE) instead of the Project.

If you work that way a lot you'll either want to avoid using relative paths or else change the current directory to the App.Path as one of the very first steps in your programs. Of course that habit is even worse since it breaks current directory for your compiled programs.

Better to leave it alone.

About the only time it makes sense to run VB6.EXE standalone from a shortcut, etc. is when creating a new project. Then as soon as possible save the Project, exit the IDE, then restart it via Explorer by clicking on the newly saved .VBP file. Always do that from then on. That way CD is always the project directory.

But perhaps something else is going on here?
Reply With Quote
  #24  
Old 11-01-2016, 07:51 AM
Cerian Knight's Avatar
Cerian Knightdrag image in picbox (must be picture box) Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,194
Default

Should read: Downloaded the zip file, extracted the zip file, opened the extracted folder and opened/ran the project. Also, projects should be stored in a user writable area (e.g. Documents\Projects).

I did notice a dependency on a VB5 StatusBar that does not automatically upgrade. Refitting with the VB6 version was a little tedious, but then all worked well.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #25  
Old 11-01-2016, 12:08 PM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 289
Default

Yes, that could be the problem. I would normally use app.path but just used the files 'out of the box'. I'll move everything to my current working directory and see what transpires! Cheers.
Reply With Quote
  #26  
Old 11-02-2016, 04:30 AM
dilettante's Avatar
dilettantedrag image in picbox (must be picture box) dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

I don't think you understand the concept of relative paths and current directory.

As for the so-called "VB6" Statusbar... does anyone use that? It is actually far older than the "VB5" one since it can't use the Win32 StatusBar that gets updated with each Windows version as well as for that matter the CC6 assembly.

Of course there are some headaches because of the games Microsoft played breaking binary interface compatibility. Some systems get "upgraded" to the 2.1 interfaces while others have the 2.0 interfaces. They discovered the error a while back (Win7 SP1) but Win7 is screwed now and newer versions of Windows reverted to the "universal" 2.0 interfaces.

That was another reason why people were expected to move off Windows 7. But now it is in only extended support and will never be repaired. There are a number of ADO compatibility breaks on Win7 SP1 as well that require manual fiddling and detours.

Windows 7 is thus nearly as "dead" already as XP, though Vista doesn't carry that baggage. Because these are compile time issues for the most part supporting Win7 isn't a problem, you just don't want to develop on Win7.
Reply With Quote
  #27  
Old 11-02-2016, 10:12 PM
Cerian Knight's Avatar
Cerian Knightdrag image in picbox (must be picture box) Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,194
Default

Quote:
Originally Posted by dilettante View Post
Some systems get "upgraded" to the 2.1 interfaces while others have the 2.0 interfaces.
What a mess, but that might explain why no StatusBar issue on both my home PCs (Win 10 and Win 7)... only an issue with my Win 7 PC at work (which I have to look into now). I did not know that crap-shoot issue was lurking, as I haven't committed a StatusBar to my own non-VB.NET projects since VB5. I'm no stranger to other upgrade issues... the ones that convert some of your ComCtrls to a PictureBox when opening a project (which this didn't do).

Just noticed CryptGenRandom API seems almost 8 times faster under Windows 10 as compared to Windows 7 (possibly due to use of new CPU instructions). At least some things seem to be moving in the right direction.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #28  
Old 11-04-2016, 06:26 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 289
Default

Latest news (this is getting to be like a Norse saga!)...
I went to include draggio in my actual project but neither 'references' nor 'components' (what's the difference?) will allow the .ctl or .ctx files to be installed. Between they either want .ocx, .exe or .dll files.
Please, if either of you guys think this thread has gone on long enough, feel free to drop out gracefully. Just a shame that I can't seem to do what on the surface seems such a straightforward thing. But whatever, thanks for your help.
Reply With Quote
  #29  
Old 11-04-2016, 07:52 AM
Cerian Knight's Avatar
Cerian Knightdrag image in picbox (must be picture box) Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,194
Default

Try Project/Add User Control/Existing/Draggio.ctl/Open. It will appear in your Toolbox.

With regard to Components and References, the former typically represent canned (i.e. wrapped ActiveX) Controls (unlike User Controls, which can be flexibly modified), where the latter could be anything containing code (and may also contain controls or whole application interfaces) which you must instantiate (e.g. CreateObject) or otherwise access through your own code since they don't, and often cannot (e.g. no wrapper included) show up in your Toolbox.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').

Last edited by Cerian Knight; 11-04-2016 at 08:01 AM.
Reply With Quote
  #30  
Old 11-04-2016, 09:25 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 289
Default

Hi, and thanks. That did it! But...
when I run (f5) I get an error message saying "property toolboxbitmap in Draggio had an invalid file reference" in the error log.
Reply With Quote
  #31  
Old 11-04-2016, 11:10 AM
Cerian Knight's Avatar
Cerian Knightdrag image in picbox (must be picture box) Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,194
Default

Did you:
1. Place the 'Draggio.ctl' file, 'Draggio.ctx' file, 'Resource' folder and your picture file in the project folder?
2. Add and position the Draggio control to your form.
3. Add 'Set Draggio.Picture = LoadPicture("yourpicturefilename") to Form_Load?

You will not need to in this case, but it may help to know (when modifying or designing a UserControl, as dilettante did) that there is a setting: Tools/Options/General/Break in Class Module. Do not change the setting unless you are debugging the UserControl code.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').

Last edited by Cerian Knight; 11-04-2016 at 11:20 AM.
Reply With Quote
  #32  
Old 11-04-2016, 06:32 PM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 289
Default

Whooo! It worked!
Millions of thanks. If you're ever in the SE of the UK I'll buy you a pint of our warm English beer!
The picture I displayed was Black-on-White, so presumably I can use standard VB code (I think I have the code somewhere, again from this forum) to convert it to red-on-black. But thanks loads for bearing with me guys.
Reply With Quote
  #33  
Old 11-05-2016, 06:38 AM
dilettante's Avatar
dilettantedrag image in picbox (must be picture box) dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Sorry I didn't get back here very soon but at least you got assistance to help you move ahead.

I'm not sure why you needed the "resources" folder at all really since all of those resources were already imported into the .CTX and .FRX files. This implies that those files were not placed where they should be either. That folder was only provided so you'd have the original source images in case you want to edit them or replace them with something else.

For both Form and Control modules there are optional auxiliary files. You have one file for the module text (.FRM or .CTL) and one optional binary resource file. The text "source" file has references in it to binary items within the "resource" file (the .FRX or .CTX file) when such a file is used.

So to add a Control to a new Project you have to copy both files, together next to each other. The .CTL file contains a relative path to the .CTX file (almost always just a simple file name). If this references a file that doesn't exist you'll get the error message and LOG file entry you observed.

But the main thing is that you got past these issues.
Reply With Quote
Reply

Tags
box, drag, image, pic, picture, picbox


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
drag image in picbox (must be picture box) drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box) drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
 
drag image in picbox (must be picture box)
drag image in picbox (must be picture box)
 
-->