Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pic box data interrogation 1

Status
Not open for further replies.

erstout

MIS
Dec 11, 2002
16
US
I have a pic box (picDefects) loaded from the following code fragment - it generates a frame with red dots.

Do Until aPoints.EOF
If aListDefects Then
msg = aPoints.rdoColumns("DefectName")
picDefects.CurrentX = AddToX + SX + 500
lastY = lastY + picDefects.TextHeight(msg)
picDefects.CurrentY = lastY
picDefects.Print msg
.
.
.
Loop
My question is: is there a way to examine the contents of the completed picDefects (say a user clicks on a dot) to find out what the contents of the picDefects is at that spot?
Thanks.
-erstout
 
i think this may be possible with the mouse_down event of the picture box... nfortunately i cant back myself up because ive never tried it, but it may be worth looking into!

bear in mind the mouse down event has a reference to the mouse pointer x and y value
 
Well, yes and no. The mouse_down will return the x,y of the clicked location (of the picturebox) BUT from that, I can only tell the click location. What I need to know is whether I can actually tell what was .PRINTed into that 'cell' of the picture box. In other words - if I am understanding where I'm going correctly, I have a page of text and someone taps a pencil somewhere on the page. I have to find out what text is at the location that was tapped; can I query the page somehow to find out what is at the tapped location, without having to maintain a buffer of the picbox contents and relate it to the clicked spot?
 
eek!

not sure, at a guess i would say no without the buffer you mention (but theres still a hell of a lot i dont know about VB so dont give up on my behalf)

Sorry i couldnt help out any more!
 
haven't given up :)
someone else suggested (on gasp! another forum) that using color= picBox.Point upon MouseDown() could at least tell me whether user clicked a red point - so I'm investigating trying to use a rolling color scheme to identify each dot as an offset from BaseColor...which might work (until I plot too many colored dots...)
 
I'm not quite sure I'm with you. How is printing the defect messages out ending up as a series of red dots? Once we have an answer to this there may be a variety of apprpriate solutions

In the meantime let's assume, as you describe in the roor post, that all you are getting is red dots plotted at specific positions. One method you could use would be to store the defect text into a collection, using the coordinates as the key. When you click on a red dot, you know the coordinates and can then retrieve the correct entry from the collection.

The following merely illustrates the idea, it is not a solution (and the only reason for the scaling is to make the points bigger):
[tt]
Option Explicit
Private Defects As Collection

Private Sub Command1_Click()
Dim X As Long
Dim Y As Long
Dim strDefectMessage As String
Dim myScale As Long

Set Defects = New Collection
myScale = 6

' Ok now add two defect 'points' for the example
Picture1.Cls
X = 5
Y = 5
Picture1.DrawWidth = myScale
Picture1.ScaleWidth = Picture1.Width / myScale
Picture1.ScaleHeight = Picture1.Height / myScale
strDefectMessage = "Test defect"
Picture1.CurrentX = X
Picture1.CurrentY = Y
Defects.Add strDefectMessage, CStr(X) & "x" & CStr(Y)
Picture1.PSet (X, Y), RGB(255, 0, 0)

X = 10
Y = 10

strDefectMessage = "Second test defect"
Picture1.CurrentX = X
Picture1.CurrentY = Y
Defects.Add strDefectMessage, CStr(X) & "x" & CStr(Y)
Picture1.PSet (X, Y), RGB(255, 0, 0)
End Sub


Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
MsgBox "Defect found at this point is: " & Defects(CStr(CInt(X)) & "x" & CStr(CInt(Y)))
On Error GoTo 0
End Sub

 
Brilliant! You've identified a significant problem with my initial post and I just realized it - I extracted and posted the WRONG Code fragment. (carp, carp carp.)
And before too many more posts are added, let me say I'm sorry. Yes, I do have a dataset of the defects, but not by picBox X,Y reference - they are being formatted into the picBox via picBox.line (sX - eX, sY - eY), RBG (255,0,0).
And the solution to identify the dot by color seems to be working out quite well.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top