By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,672 Members | 1,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,672 IT Pros & Developers. It's quick & easy.

MSComctLib.TreeView CreateDragImage issue

FishVal
Expert 2.5K+
P: 2,653
Hi!

Access2003, WinXP SP2, Control: MSComctLib.TreeView

I've recently add tree view to my database. Among other functionality it implements Drag-n-Drop. All works fine but one thing.
I want to create drag image from dragged node using Node.CreateDragImage function. But it returns IPictureDisp object containing a node image only, never the node text nothing to tell about a composite one I would like to see.
Any helpful advice will be appreciated.

Thanks.
Jun 11 '07 #1
Share this Question
Share on Google+
11 Replies

NeoPa
Expert Mod 15k+
P: 31,770
Hi!

Access2003, WinXP SP2, Control: MSComctLib.TreeView

I've recently add tree view to my database. Among other functionality it implements Drag-n-Drop. All works fine but one thing.
I want to create drag image from dragged node using Node.CreateDragImage function. But it returns IPictureDisp object containing a node image only, never the node text nothing to tell about a composite one I would like to see.
Any helpful advice will be appreciated.

Thanks.
Fish,
You may be lucky here and find someone who knows about this software, but the expertise is generally around MS Access rather than specific add-ons.
Good luck anyway.
Jun 11 '07 #2

FishVal
Expert 2.5K+
P: 2,653
Fish,
You may be lucky here and find someone who knows about this software, but the expertise is generally around MS Access rather than specific add-ons.
Good luck anyway.
Hmmm. You consider Treeview control is less native to Access than for example Chart control? :)
Anyway thanks.
Jun 11 '07 #3

NeoPa
Expert Mod 15k+
P: 31,770
Hmmm. You consider Treeview control is less native to Access than for example Chart control? :)
Anyway thanks.
I'm not saying you won't get an answer, just that the chances are less because it's less common usage. I don't know it at all personally - is it a M$ add-in then? Is it included in the base Access package even? If it is either of these then it's more likely you'll find an answer (not from me though 'cause I've not even heard of it before :D).
Jun 11 '07 #4

FishVal
Expert 2.5K+
P: 2,653
I'm not saying you won't get an answer, just that the chances are less because it's less common usage. I don't know it at all personally - is it a M$ add-in then? Is it included in the base Access package even? If it is either of these then it's more likely you'll find an answer (not from me though 'cause I've not even heard of it before :D).
It is in
"Microsoft Windows Common Controls 6.0 (SP6)"
\WINDOWS\system32\MSCOMCTL.OCX
MSDN documentation is minor.

Well. Maybe I should create mouseicon programmatically.
Really, I don't wait for solutions but for ideas.
Programming is much more interesting thing than program itself, isn't it?
Jun 11 '07 #5

ADezii
Expert 5K+
P: 8,750
Hi!

Access2003, WinXP SP2, Control: MSComctLib.TreeView

I've recently add tree view to my database. Among other functionality it implements Drag-n-Drop. All works fine but one thing.
I want to create drag image from dragged node using Node.CreateDragImage function. But it returns IPictureDisp object containing a node image only, never the node text nothing to tell about a composite one I would like to see.
Any helpful advice will be appreciated.

Thanks.
I'm familiar with VB but I need to see your code in order to attempt a response.
  1. Are you using Manual or Automatic Drag-N-Drop operations?
  2. If you are manually using Drag-N-Drop, have you initiated the Drag operation via the Drag Method?
  3. What are your settings for the OLEDragMode and OLEDropMode Propeerties?
  4. How are you initializing the CreateDragImage Method (TreeViewName.SelectedItem.CreateImage)?
  5. This Method creates a dithered version of an Object's Image. What are you assigning this Image to?
  6. The Node selected for Drag Operations - is it declared Publically?
  7. Please post all relevant code.
Jun 12 '07 #6

FishVal
Expert 2.5K+
P: 2,653
I'm familiar with VB but I need to see your code in order to attempt a response.
  1. Are you using Manual or Automatic Drag-N-Drop operations?
  2. If you are manually using Drag-N-Drop, have you initiated the Drag operation via the Drag Method?
  3. What are your settings for the OLEDragMode and OLEDropMode Propeerties?
  4. How are you initializing the CreateDragImage Method (TreeViewName.SelectedItem.CreateImage)?
  5. This Method creates a dithered version of an Object's Image. What are you assigning this Image to?
  6. The Node selected for Drag Operations - is it declared Publically?
  7. Please post all relevant code.
Hi! Thanks for cooperation. Hereby I'm providing code of Drag events handlers.
It is located in custom Class module as you can see. Treeview object is a global variable in Class module and is retrived via Me.TreeView property.


Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub trvTreeView_OLEDragDrop(Data As MSComctlLib.DataObject, _
  3.             Effect As Long, Button As Integer, Shift As Integer, _
  4.             x As Single, y As Single)
  5.  
  6.     With Me.TreeView
  7.         DragCompleted .SelectedItem, .HitTest(x, y), Shift
  8.         .DropHighlight = Nothing
  9.         .MousePointer = ccArrow
  10.     End With
  11.  
  12. End Sub
  13.  
  14. Private Sub trvTreeView_OLEDragOver(Data As MSComctlLib.DataObject, _
  15.             Effect As Long, Button As Integer, Shift As Integer, _
  16.             x As Single, y As Single, State As Integer)
  17.  
  18.     With Me.TreeView
  19.         If .SelectedItem Is Nothing Then
  20.             .SelectedItem = .HitTest(x, y)
  21.             .MouseIcon = .SelectedItem.CreateDragImage
  22.             .MousePointer = ccCustom
  23.         End If
  24.         .DropHighlight = .HitTest(x, y)
  25.     End With
  26.     If (Shift And 2) = 0 Then
  27.         Effect = ccOLEDropEffectMove
  28.     Else
  29.         Effect = ccOLEDropEffectCopy
  30.     End If
  31.  
  32. End Sub
  33.  
  34. Private Sub trvTreeView_OLEGiveFeedback(Effect As Long, _
  35.             DefaultCursors As Boolean)
  36.     DefaultCursors = False
  37. End Sub
  38.  
  39. Private Sub trvTreeView_OLEStartDrag(Data As MSComctlLib.DataObject, _
  40.             AllowedEffects As Long)
  41.  
  42.     Me.TreeView.SelectedItem = Nothing
  43.     AllowedEffects = ccOLEDropEffectCopy + ccOLEDropEffectMove
  44.  
  45. End Sub
  46.  
  47.  
Drag properties are the following:
.OLEDragMode = ccOLEDragAutomatic
.OLEDropMode = ccOLEDropManual

As I've already stated the result is that mouse cursor image changes to Node.Image with low resolution.
If Node object contains no Image and TreeView.Style=tvwTreelinesPlusMinusText CreateDragImage method returns empty bar image.

Actually I'm thinking about manual image creation instead of CreateDragImage method. Could you suggest how to create IPictureDisp object from text? Maybe some WinAPI function?

Thanks.
Jun 12 '07 #7

ADezii
Expert 5K+
P: 8,750
Hi! Thanks for cooperation. Hereby I'm providing code of Drag events handlers.
It is located in custom Class module as you can see. Treeview object is a global variable in Class module and is retrived via Me.TreeView property.


Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub trvTreeView_OLEDragDrop(Data As MSComctlLib.DataObject, _
  3.             Effect As Long, Button As Integer, Shift As Integer, _
  4.             x As Single, y As Single)
  5.  
  6.     With Me.TreeView
  7.         DragCompleted .SelectedItem, .HitTest(x, y), Shift
  8.         .DropHighlight = Nothing
  9.         .MousePointer = ccArrow
  10.     End With
  11.  
  12. End Sub
  13.  
  14. Private Sub trvTreeView_OLEDragOver(Data As MSComctlLib.DataObject, _
  15.             Effect As Long, Button As Integer, Shift As Integer, _
  16.             x As Single, y As Single, State As Integer)
  17.  
  18.     With Me.TreeView
  19.         If .SelectedItem Is Nothing Then
  20.             .SelectedItem = .HitTest(x, y)
  21.             .MouseIcon = .SelectedItem.CreateDragImage
  22.             .MousePointer = ccCustom
  23.         End If
  24.         .DropHighlight = .HitTest(x, y)
  25.     End With
  26.     If (Shift And 2) = 0 Then
  27.         Effect = ccOLEDropEffectMove
  28.     Else
  29.         Effect = ccOLEDropEffectCopy
  30.     End If
  31.  
  32. End Sub
  33.  
  34. Private Sub trvTreeView_OLEGiveFeedback(Effect As Long, _
  35.             DefaultCursors As Boolean)
  36.     DefaultCursors = False
  37. End Sub
  38.  
  39. Private Sub trvTreeView_OLEStartDrag(Data As MSComctlLib.DataObject, _
  40.             AllowedEffects As Long)
  41.  
  42.     Me.TreeView.SelectedItem = Nothing
  43.     AllowedEffects = ccOLEDropEffectCopy + ccOLEDropEffectMove
  44.  
  45. End Sub
  46.  
  47.  
Drag properties are the following:
.OLEDragMode = ccOLEDragAutomatic
.OLEDropMode = ccOLEDropManual

As I've already stated the result is that mouse cursor image changes to Node.Image with low resolution.
If Node object contains no Image and TreeView.Style=tvwTreelinesPlusMinusText CreateDragImage method returns empty bar image.

Actually I'm thinking about manual image creation instead of CreateDragImage method. Could you suggest how to create IPictureDisp object from text? Maybe some WinAPI function?

Thanks.
  1. Is the TreeView Property setting an explicit reference to tvwTreeView, and not a TreeView Object?
  2. Shouldn't there be some kind of specific reference to the actual Node being dragged in the MouseDown () Event? e.g.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub TreeView1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
    2.   Set MyNode = Me.TreeView.SelectedItem
    3. End Sub
  3. I definitely think that it is a bad idea to use 'TreeView' as a Custom Property. There could be some ambiguity - did you try changing this Property Name?
  4. A Picture Object implements an iPictureDisp Interface in order to provide access to trhe Picture's properties through Automation.From what I have researched, this interface is not meant to be implemented since there is an OLE-provided Picture Object. For all practical purposes, all properties contained within iPictureDisp are Read Only. I'm sure that an API Function exists to create one, but I have no idea of its name.
Jun 12 '07 #8

FishVal
Expert 2.5K+
P: 2,653
  1. Is the TreeView Property setting an explicit reference to tvwTreeView, and not a TreeView Object?
  2. Shouldn't there be some kind of specific reference to the actual Node being dragged in the MouseDown () Event? e.g.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub TreeView1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
    2.   Set MyNode = Me.TreeView.SelectedItem
    3. End Sub
  3. I definitely think that it is a bad idea to use 'TreeView' as a Custom Property. There could be some ambiguity - did you try changing this Property Name?
  4. A Picture Object implements an iPictureDisp Interface in order to provide access to trhe Picture's properties through Automation.From what I have researched, this interface is not meant to be implemented since there is an OLE-provided Picture Object. For all practical purposes, all properties contained within iPictureDisp are Read Only. I'm sure that an API Function exists to create one, but I have no idea of its name.
Thanks.
  • Surely TreeView property references TreeView object, not a trvTreeView control
  • What concerns referencing Node object, I'm 100% sure having debugged this that the referenced object is a right one
  • "TreeView" name of the custom class property does not conflict with class name TreeView, you can find many examples when a property returning particulary object has the same name as the object class has.
  • Finally, I've tried the folowing code after the tree has been populated, not in Drag-n-Drop context:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim pic As stdole.IPictureDisp
  3. ........................
  4. Set pic = .Nodes(2).CreateDragImage
  5. SavePicture pic, "C:\pic.dib"
  6. Set pic = Nothing
  7. .......................
  8.  
No way. Opened it in Paintbrush - image corresponding to the node, no text.
I think I will try search WinAPI. This seems to be more promissing.

Anyway thanks.
Jun 12 '07 #9

TheSmileyCoder
Expert Mod 100+
P: 2,321
I do realise this thread is ancient, but I also know both of you are still active on the forum. Did you ever find a way to create a composite image of the node icon and caption? I've been searching myself, and trying myself with no luck.
May 19 '11 #10

ADezii
Expert 5K+
P: 8,750
Sorry TheSmileyCode, no luck on this end. I'll have a fresh look later on and see if anything comes up.
May 19 '11 #11

TheSmileyCoder
Expert Mod 100+
P: 2,321
Thank you for replying ADezii. The best I have come up with myself is to use the OLEDragOver to continously remove the node, and add it at the location of the mouse. (I have to remove it and add it again, since I cannot change its index at runtime)

It almost looks like dragging, but its not perfect, I would prefer the CreateDragImage to work.
May 19 '11 #12

Post your reply

Sign in to post your reply or Sign up for a free account.