1 Attachment(s)
[RESOLVED] Have a picturebox appear raised
I have a bitmap on a picturebox which can be drawn either in a color scale or a gray scale. Either mode is represented by another 2 tiny control pictureboxes.
If the current state is grayscale (color), then I'd like the color (grayscale) control pbox to appear raised, i.e. the colors of the upper and left borders exchanged with those of the lower and right borders (see picture).
I think there was a very easy way but I have forgotten and it's no longer in my bag of tricks.
Re: Have a picturebox appear raised
Maybe like....?
EDIT Na that's no good, messes with the picture! Sorry!
1 Attachment(s)
Re: Have a picturebox appear raised
Heres an idea using DrawEdge API,
Edit added updated version.
Re: Have a picturebox appear raised
Quote:
Originally Posted by Edgemeal
Heres an idea using DrawEdge API,
Edit added updated version.
That's a good enough idea and I'm going to use your code.
Still I seem to recall there was a very straighforward method, also based on drawing a rectangle but without the API, with the Line method and some setting of the DrawMode property. But I don't even remember if it was with pictureboxes, command buttons or what.
Re: [RESOLVED] Have a picturebox appear raised
Ya heres a lame one,
Code:
Sub Apply3D(Frm As Form, Ctl As Control)
Frm.CurrentX = Ctl.Left - 1
Frm.CurrentY = Ctl.Top + Ctl.Height
Frm.Line -Step(0, -(Ctl.Height + 1)), vbButtonShadow
Frm.Line -Step(Ctl.Width + 1, 0), vbButtonShadow
Frm.Line -Step(0, Ctl.Height + 1), vbWhite
Frm.Line -Step(-(Ctl.Width + 1), 0), vbWhite
End Sub
Re: [RESOLVED] Have a picturebox appear raised
Quote:
Originally Posted by Edgemeal
Ya heres a lame one,
Code:
Sub Apply3D(Frm As Form, Ctl As Control)
Frm.CurrentX = Ctl.Left - 1
Frm.CurrentY = Ctl.Top + Ctl.Height
Frm.Line -Step(0, -(Ctl.Height + 1)), vbButtonShadow
Frm.Line -Step(Ctl.Width + 1, 0), vbButtonShadow
Frm.Line -Step(0, Ctl.Height + 1), vbWhite
Frm.Line -Step(-(Ctl.Width + 1), 0), vbWhite
End Sub
Something along these lines, yes, but I remember it used only one Line statement with the B (box) parameter. Because of the DrawMode value each call to the function would toggle the colors. I wonder if there's a DrawMode value that can accomplish this and what colours those were.
1 Attachment(s)
Re: [RESOLVED] Have a picturebox appear raised
So finally, after a slight modification of your demo code this is what I had in mind :)
Re: [RESOLVED] Have a picturebox appear raised
Quote:
Originally Posted by krtxmrtz
So finally, after a slight modification of your demo code this is what I had in mind :)
Heres another way you could do it without any API, add 2 check boxes to a form and set their Style to Graphical and add a picture to them.
Edit And If you use 2 Option boxes instead, you can away with even less code. ;)
Code:
Option Explicit
Private Sub Form_Load()
Check1.Value = 1 ' Color selected (down)
End Sub
Private Sub Check1_Click() 'Color pic.
If Check1.Value = 1 Then
Check2.Value = 0
Else
Check2.Value = 1
End If
SomeOtherControl.SetFocus ' move focus away
End Sub
Private Sub Check2_Click() ' B&W pic.
If Check2.Value = 1 Then
Check1.Value = 0
Else
Check1.Value = 1
End If
End Sub
Re: [RESOLVED] Have a picturebox appear raised
Quote:
Originally Posted by Edgemeal
Heres another way you could do it without any API, add 2 check boxes to a form and set their Style to Graphical and add a picture to them....
That's interesting: the code works but it produces run time error 5 (invalid procedure call or argument) when it tries to set the focus to some other control. Have you tried out the code?
Re: [RESOLVED] Have a picturebox appear raised
Quote:
Originally Posted by krtxmrtz
That's interesting: the code works but it produces run time error 5 (invalid procedure call or argument) when it tries to set the focus to some other control. Have you tried out the code?
Ya, but I had SomeOtherControl.SetFocus in the Check2_Click event instead and seems to solve the error.
Edit: hmmmm maybe not, cause check1 has a rect around it on start now, maybe it has something to do with the tab order, cause I had it working perfectly, should of save project, not sure what I did now :lol:
Re: [RESOLVED] Have a picturebox appear raised
I must of set the Tabstops off in the IDE for the checkboxes, so the focus rect wasn't shown on start up for check one.
Code:
Option Explicit
Private Sub Check1_Click() 'Color pic.
If Check1.Value = 1 Then
Check2.Value = 0
Else
Check2.Value = 1
End If
End Sub
Private Sub Check2_Click() ' B&W pic.
If Check2.Value = 1 Then
Check1.Value = 0
Else
Check1.Value = 1
End If
SomeOtherControl.SetFocus ' move focus away
End Sub
Private Sub Form_Load()
SomeOtherControl.TabStop = True
SomeOtherControl.TabIndex = 0
Check1.TabStop = False
Check2.TabStop = False
Check1.Value = 1
End Sub
Private Sub SomeOtherControl_Click()
'...
End Sub
Using two Option boxes set to Graphical seems to be the simplest way tho the toggle acts a little different, I think overall I'd rather just use the API way.
Code:
Option Explicit
Private Sub Form_Load()
SomeOtherControl.TabStop = True
SomeOtherControl.TabIndex = 0
Option1(0).TabStop = False ' Color
Option1(1).TabStop = False ' B&W
Option1(0).Value = True ' Select Color as default
End Sub
Private Sub Option1_Click(Index As Integer)
On Error Resume Next
SomeOtherControl.SetFocus
End Sub
Private Sub SomeOtherControl_Click()
' ...
End Sub
Re: [RESOLVED] Have a picturebox appear raised
Quote:
Originally Posted by Edgemeal
...I think overall I'd rather just use the API way.
I agree.