Solved

VB6 Drag and Drop Label onto another Form

Posted on 2009-05-07
4
1,359 Views
Last Modified: 2013-12-26
Hi.
VB6.  I have a Label on a PictureBox on Form1 which I want to Drag and Drop onto a PictureBox on a separate Form2.  I get error message 425 Invalid object use.  Dragging and Dropping the label from one PictureBox to another on the same Form1 works OK.
TIA.

EDIT: This is not a Drag and Drop problem, it's the Container property.  It looks like the 'Container' has to be on the same Form as the Source.  Is there a way round this?

Code for Form1:
Private Sub Form_Load()
  Form2.Show
End Sub

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Label1.Drag vbBeginDrag
End Sub

Code for Form2:
Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
  Set Source.Container = Picture1
  Source.Drag vbEndDrag
End Sub
0
Comment
Question by:Sat2b
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Antagony1960 earned 25 total points
ID: 24335120
You can only change the container property of an object within the form in which it has been created. To drag between forms you have to create a matching object on the target form and change the visibility of the two objects accordingly.
0
 
LVL 1

Assisted Solution

by:mystami
mystami earned 25 total points
ID: 24346737
Therefore basically if you drag and drop it to the main area on your original form, then you will be able to drag that new one and drop it to the new form in the main area.  Because neither will have any containers at that point.
0
 

Author Closing Comment

by:Sat2b
ID: 31578912
Thanks guys, I dropped the label info into a FlexGrid in the end.
0
 

Author Comment

by:Sat2b
ID: 24383509
Thanks Guys.

I added a FlexGrid to the second Form, Dropped the Label info into a cell and made the Label invisible on the first Form.  Probably works better than how I'd planned to do it with the Label!

Cheers.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using Access 8 68
to transfer string from C lanaguage to VBA 4 64
Exit a vb6 apps when a calling it apps closes 15 46
Protecting vb6 & .Net code Obfuscation 18 121
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question