Results 1 to 18 of 18

Thread: [RESOLVED] scrolling marquee - clickable links

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    39

    Resolved [RESOLVED] scrolling marquee - clickable links

    Hi,

    I want to import articles links/titles from an xml feed and display this using a scrolling marquee. I want the text in the marquee to be clickable so that when the item is clicked it opens up a browser window and displays the related article.

    Is there anyway to do this and can anyone help me complete this task?

    Many Thanks!

    Al

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: scrolling marquee - clickable links

    First of all... Welcome to the Forums

    It's not hard to do...
    show us what you have so far and what problems do you face and we'll try to help you
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    39

    Re: scrolling marquee - clickable links

    Hi ComputerJy,

    So far I have my winform that can be positioned either at the top or bottom of the available screen and the option to manage feeds. That is as far as I have got at the moment. I have examples and I am sure I can load the xml into my application but I am having difficulty finding any articles or solutions on how to create the scrolling marquee on my winform where the text is clickable (like a hyperlink) that opens up a url.

    Can you please help me to create the marquee element to display my data or do you have any examples/articles on how this can be done?

    Many Thanks,

    Al

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: scrolling marquee - clickable links

    Hyperlinks can be "LinkLabel" controls, you'll need a "Timer" to move them on TimerTick
    If you don't know how to use those controls go to MSDN and look there, you'll find great stuff
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    39

    Re: scrolling marquee - clickable links

    Thanks - I'll get looking at the LinkLabel straight away.

    Do you have any idea - why this doesn't seem to assign the temp point to 720 (in my case)?

    Code:
    int total = 0;
    			int AppHeight = 25;
    			int AvlScreenHeight = (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height);
    			total = AvlScreenHeight-=AppHeight;
    			this.Height = AppHeight;
    			
    			this.Width = (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width); // 100% width
    			
    			
    			Point tempPoint = new Point(0,total);
    			this.DesktopLocation = tempPoint;
    			this.TopMost = true;

  6. #6
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: scrolling marquee - clickable links

    Replace "WorkingArea" with "Bounds" in the 2nd line
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  7. #7
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: scrolling marquee - clickable links

    By far the easiest way to achieve this is to use a WebBrowser control, you manually stuff it with the HTML code to give you a linked marquee. Then you just handle the navigation events of the control.

    Don't bother using timers or linklabels. The Webbrowser woul dmake a much better job of it and it would look authentic too.
    I don't live here any more.

  8. #8

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    39

    Re: scrolling marquee - clickable links

    Quote Originally Posted by wossname
    By far the easiest way to achieve this is to use a WebBrowser control, you manually stuff it with the HTML code to give you a linked marquee. Then you just handle the navigation events of the control.

    Don't bother using timers or linklabels. The Webbrowser woul dmake a much better job of it and it would look authentic too.
    Do you have any examples of displaying xml in a html page via c#? Would this approach require greater resources than the linklabel approach?

    Thanks for your input wossname.

    Al

  9. #9
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: scrolling marquee - clickable links

    Code:
    myWebbrowser.DocumentText = "<?xml...blah blah...?><html>....marquee code goes here...</html>";
    If you stick a marquee in there it should work like normal.

    No witchcraft involved.
    I don't live here any more.

  10. #10

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    39

    Re: scrolling marquee - clickable links

    Hi ComputerJy,

    After playing with the WebBrowser suggestion I think the linklabel/timer is the way i'd like to do it.

    I need to be able to use a linklabel.LinkCollection so I can load in multiple links (from an XML feed). I don't know how to get a linklabel text to move left upon a timer_tick. Would you or anyone else be able to demostrate how this can be done? I have hunted high and low for a working solution but I can't find one.

    Many Thanks,

    Al

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: scrolling marquee - clickable links

    You don't move text within a label. You'd have to remove the leading characters from the text to get the others to move left. The way to do it would be to put the label in a Panel and then on the Tick of the Timer decrement its Left property to move it left. Once it has moved all the way to the left, i.e. its Right property is zero or less, then you move it al the way back to the right to start again, i.e. set its Left property to the Width of the Panel. Relatively elementary stuf. Give it a go and see what you can come up with.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    39

    Re: scrolling marquee - clickable links

    jmcilhinney - Upon a timer_tick how can I remove a pixel from the left of the panel and then add one to the right of the panel?

    I have tried this but this doesn't work

    Code:
            private void timer1_Tick(object sender, EventArgs e)
            {
                linkLabel1.Left = -5;
                //linkLabel1.Right = +5;
            }
    The linkLabel1.Left just moves the entire linkLabel1 to the left on the first tick. After that nothing happens. The code for the right handside is commented out as this throws an error up compiling.

    Am I going in the correct direction with this? and could anyone give me a hand to move the linklabel upon the timer_tick?

    Thanks for your time,

    Al

  13. #13
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: scrolling marquee - clickable links

    linkLabel1.Left += -5;
    I don't live here any more.

  14. #14

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    39

    Re: scrolling marquee - clickable links

    cool - I wasn't so far off!

    Now I have changed it to this:

    Code:
            private void timer1_Tick(object sender, EventArgs e)
            {
                if (linkLabel1.Right <= 0)
                {
                linkLabel1.Left = 500;
                }
                else
                {
                linkLabel1.Left += -5;
                }
            }
    which enables the scrolling but is using an if statement is the best solution for this?
    Last edited by Muller2; Sep 21st, 2006 at 04:01 PM.

  15. #15
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: scrolling marquee - clickable links

    Code:
    linkLabel1.Left += -5;
    Code:
    linkLabel1.Left -= 5;
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  16. #16
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: scrolling marquee - clickable links

    Quote Originally Posted by Muller2
    Code:
            private void timer1_Tick(object sender, EventArgs e)
            {
                if (linkLabel1.Right <= 0)
                {
                linkLabel1.Left = 500;
                }
                else
                {
                linkLabel1.Left -= 5;
                }
            }
    which enables the scrolling but is using an if statement is the best solution for this?
    I have fixed the code above, as jmc pointed out

    Also, there really isn't a better way than an if conditional. The only other way would be a switch...but its pointless for something so small:
    PHP Code:
    switch (linkLabel1.Right)
    {
        case -
    1:
            
    linkLabel1.Left 500;
            break;
        default:
            
    linkLabel1.Left -= 5;
            break;

    ...

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: scrolling marquee - clickable links

    Code:
    linkLabel1.Left = (linkLabel1.Right <= 0 ? linkLabel1.Parent.Width : linkLabel1.Left - 5);
    Not necessarily better but another way.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  18. #18
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: scrolling marquee - clickable links

    Been awake for almost 19 hours now, brain is kinda dead

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

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