Results 1 to 12 of 12

Thread: [RESOLVED] Have a picturebox appear raised

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [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.
    Attached Images Attached Images  
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Have a picturebox appear raised

    Maybe like....?
    EDIT Na that's no good, messes with the picture! Sorry!
    Last edited by Edgemeal; Sep 9th, 2008 at 08:39 AM.

  3. #3
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Have a picturebox appear raised

    Heres an idea using DrawEdge API,
    Edit added updated version.
    Attached Files Attached Files
    Last edited by Edgemeal; Sep 9th, 2008 at 12:04 PM.

  4. #4

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  5. #5
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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

  6. #6

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: [RESOLVED] Have a picturebox appear raised

    So finally, after a slight modification of your demo code this is what I had in mind
    Attached Files Attached Files
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  8. #8
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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
    Last edited by Edgemeal; Sep 10th, 2008 at 02:02 PM.

  9. #9

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  10. #10
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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
    Last edited by Edgemeal; Sep 10th, 2008 at 04:38 PM.

  11. #11
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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
    Last edited by Edgemeal; Sep 10th, 2008 at 05:29 PM.

  12. #12

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width