Results 1 to 16 of 16

Thread: [2005] Panel roll up/down ideas

  1. #1

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    [2005] Panel roll up/down ideas

    Hi All,

    I have created a few corner-rounded gradient panels that replicate the XP 'MyComputer' (left hand menu items) theme.

    I can currently click on the panel title (a Label) and the panel retracts up to the bottom of the Label. No problem here except I would like it to progressively (scroll) shrink up (and down if re-clicked) as the panels in the XP theame does.

    I guess I could use a Timer, and reduce the .Height property but I was curious if there is a better idea someone has come up with


    Cheers 'n' Beers,
    Last edited by Bruce Fox; Jun 8th, 2007 at 04:48 AM. Reason: Corrected the .Top property to .Height - being the property in question :)

  2. #2
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Re: [2005] Panel roll up/down ideas

    Just a guess but maybe try a loop and decrease the height every loop.
    Prefix has no suffix, but suffix has a prefix.

  3. #3

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [2005] Panel roll up/down ideas

    Hi Troy,

    Yep, thats another option. But I would pause during that loop so it takes about 0.5 sec to roll up etc.

  4. #4

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [2005] Panel roll up/down ideas

    Ok, this seems to work. I would appreciate feedback/criticism etc....

    vb Code:
    1. Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    2.         ' Note: The second Parameter could (should) be captured at Form_Load in a varable for example
    3.         Roll_Panel(Panel1, 100, Label1.Height, 1)
    4.  
    5.     End Sub
    6.  
    7.     Private Sub Roll_Panel(ByRef pnl As Panel, ByVal intOriginalPanelHeight As Integer, ByVal intLabelHeight As Integer, ByVal intDelay As Integer)
    8.         If pnl.Height <> intLabelHeight Then
    9.             Do Until pnl.Height <= intLabelHeight
    10.                 pnl.Height -= 1
    11.                 Threading.Thread.Sleep(intDelay)
    12.                 pnl.Refresh()
    13.             Loop
    14.         Else
    15.             Do Until pnl.Height >= intOriginalPanelHeight
    16.                 pnl.Height += 1
    17.                 Threading.Thread.Sleep(intDelay)
    18.                 pnl.Refresh()
    19.             Loop
    20.         End If
    21.     End Sub
    Last edited by Bruce Fox; Jun 8th, 2007 at 04:38 AM.

  5. #5
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Re: [2005] Panel roll up/down ideas

    The main problem I see is that you are telling your UI thread to sleep. This may not be an issue if the delay is low enough, though.

    Instead of using <= and >= just use =, since your increment (or decrement) is only one pixel.

    Another thought is since you are sleeping for 1 millisecond and the panel is only 100 pixels high, this would mean it would take 100 milliseconds to complete. If it takes longer than this then your code is slowing down. It is not bad that your code slows the process, but on a faster computer the same process might take less time.

    Those are just thoughts.
    Prefix has no suffix, but suffix has a prefix.

  6. #6
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: [2005] Panel roll up/down ideas

    I don’t see why you don’t want to use Timer component. The problem with the current code is that you use Thread.Sleep in the same thread so your app is being frozen during that time. But Timer is a separate thread so it does a better performance. Bottom of the line they both do the same.

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Panel roll up/down ideas

    Quote Originally Posted by Bruce Fox
    Ok, this seems to work. I would appreciate feedback/criticism etc....

    vb Code:
    1. Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    2.         ' Note: The second Parameter could (should) be captured at Form_Load in a varable for example
    3.         Roll_Panel(Panel1, 100, Label1.Height, 1)
    4.  
    5.     End Sub
    6.  
    7.     Private Sub Roll_Panel(ByRef pnl As Panel, ByVal intOriginalPanelHeight As Integer, ByVal intLabelHeight As Integer, ByVal intDelay As Integer)
    8.         If pnl.Height <> intLabelHeight Then
    9.             Do Until pnl.Height <= intLabelHeight
    10.                 pnl.Height -= 1
    11.                 Threading.Thread.Sleep(intDelay)
    12.                 pnl.Refresh()
    13.             Loop
    14.         Else
    15.             Do Until pnl.Height >= intOriginalPanelHeight
    16.                 pnl.Height += 1
    17.                 Threading.Thread.Sleep(intDelay)
    18.                 pnl.Refresh()
    19.             Loop
    20.         End If
    21.     End Sub
    If you want to use this method, you'd need to modify it to run in a thread, so the application doesnt look "frozen" during the sleeping.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  8. #8

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [2005] Panel roll up/down ideas

    Thanks for the replies guys.

    The time it takes is small, and the UI freeze is negligible in this case - However, there is room for improvement.

    VBDT, I may try a Timer as a different method too - will be good to compare.
    At least using a Timer will also allow use on a different machine with different specs.

    I will remove the <> as I was experimenting with values. They can go as it's one pixel as mentioned.


    Thanks again all for your input.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Panel roll up/down ideas

    Sup Bruce! Long time no see.

    I have done this already and ran into an issue with using a timer. You accidentally double click or click again before the "animation scroll" is completed it will queue the click and look stupid lol.

    Have you tried searching the forums for my threads on my XP Nav Panel control?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [2005] Panel roll up/down ideas

    Hey Rob,

    I emailed you a about four weeks ago - not sure if it got thru I used my work email.

    I haven't looked for that Nav Panel, but will now tho.
    I remember you did something like this a few years back, and I did find some classes that helped.

    I wasthinking of a timer, and a flag that would prevent any additional operations. Never the less, I will look for your Nav Panel.

    Hope all is well your way

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Panel roll up/down ideas

    Thanks, things are ok and hope they are good with you as well. Didnt get the email.

    I just remembered that I had a performance issue too because of resizing the panel. Not just one panel but when I had multiple panels. Say you collapsed the top one, well when you resize it you have to move the other ones up like it works in XP. I had too many steps in the timer resizing it by 4-8 pizels at a time. Best scenerio is to resize it by 1/2-1/3 steps so its allot less intense.

    Using a boolean flag to make a click will work to prevent wueueing of clicks I think.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [2005] Panel roll up/down ideas

    In your case you built a user control (from recent memory).

    I will just have 3 collapsible panels, that are gradient, and rounded (that part done); just working on the collapsing side of the house. Having said that the code I posted above does the trick. Out of all this I came across XPCC (XP Common Controls) that jmcilhinney referenced - just trying to decipher how to implement the classes.....


    Edit: No need to decipher etc once you download the right bloody thing...


    Any one else tried XPCC?

    Have a great weekend all.
    Last edited by Bruce Fox; Jun 10th, 2007 at 06:53 AM.

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Panel roll up/down ideas

    Nope, but I heard something about some minor issues with it.
    Have you looked at vbaccelerator's site where they have a good similar XP nav control?

    I started out doing what your doing with a grouping of controls and then I found I was going to need it on other forms so I figured it would be worht creating the UC. But little did I know how deep I would get into it
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [2005] Panel roll up/down ideas

    I could imagine.

    I have been playing with the 'XpTaskBox' from the XPCC items - nice (but I have already done most of it - but for a simple adding of a reference may be worth it). That said it seems to be a great one stop shop!

    One thing that I realized I could improve in the code snippet I posted was to sleep and refresh based on Mod - every 2 or 3rd iteration; that keeps the speed up etc. This came about from collapsing the panel up to the one above that was collapsed.

    I will now continue a look into the 'XP nav control'. - cheers

  15. #15

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [2005] Panel roll up/down ideas

    Hmmm, seems the only thing available now from vbaccelerator (circa 2004) is the '.NET ExplorerBar Control'.

    Not to worry, I think I'm good - it's an app for me in any case (famous last words right ).

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Panel roll up/down ideas

    Yes, that was what it was called. Yes, its VB 6 but its a very very close duplication of the original windows control.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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