reflect mouse on label to button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #46
    I am late to the party, did someone already suggest firing the mouseover event for the button?

    Comment

    • GaryTexmo
      Recognized Expert Top Contributor
      • Jul 2009
      • 1501

      #47
      I just tried and it's not working for me, did you try it, Plater? I admit I might be doing it wrong...

      Cool idea though!

      Comment

      • vishal1082
        New Member
        • Apr 2009
        • 92

        #48
        @gary sent you another private message, with the exe that also draws the text.., and its a .Net Form application :)
        @plater welcome to the party (lol)

        Comment

        • GaryTexmo
          Recognized Expert Top Contributor
          • Jul 2009
          • 1501

          #49
          It's gotta be something you're doing... attached is a screenshot of my button with the graphics drawing the text over a normal button.

          As it happens, when I mouse over the button it appears moused over, so no trickery needed :)

          How'd you colour your buttons and whatnot? Are you just setting foreground colours, or did you do anything special?
          Attached Files

          Comment

          • vishal1082
            New Member
            • Apr 2009
            • 92

            #50
            i use these :P

            Comment

            • ThatThatGuy
              Recognized Expert Contributor
              • Jul 2009
              • 453

              #51
              This post is getting way long....

              i read your first reply..... i understood what do you want to do.......

              Although this is not the right way to do.....

              you can call the Focus() method of the button when mouse is over the label the effect comes.....and then... press to lose focus out of it

              Comment

              • vishal1082
                New Member
                • Apr 2009
                • 92

                #52
                you dont get it, i got a label over button, i want the button to "glow" like the mouse is over it, while the mouse actually is over label, ur Focus method just gives the focus to button that dosent makes sense. (i tried it too like all the methods in this post, who knows what can work), By the way.. i was seeing your profile your join date is 7th July 2009, thats my birthday woo! :P

                Comment

                • vishal1082
                  New Member
                  • Apr 2009
                  • 92

                  #53
                  so? there's nothing? :(

                  i used Graphics class, TextRender class and a Label together...



                  See the difference? WHY is there so much difference? same font, same color, same style....

                  Comment

                  • GaryTexmo
                    Recognized Expert Top Contributor
                    • Jul 2009
                    • 1501

                    #54
                    You've got me, it doesn't make sense. But then, I don't know enough about the inner workings of that stuff to tell you anyway. In addition, you're using another graphics package (as mine doesn't have that result).

                    Let me ask you this. Does it matter if the graphics method looks different than the label method? From what I saw in your app, you're only having one bit of text displayed on the button.. so just use the graphics method to display it.

                    Comment

                    • vishal1082
                      New Member
                      • Apr 2009
                      • 92

                      #55
                      as u saw in application, that *button* is in the form displaying all the events on that date.. each button will contain time, discription, title and reoccurence of events, only for now i write the "Sample"s.

                      Anyways i thought of "another" idea that no one suggested me in this whole post... take a screenshot of label using DrawToBitmap and paint the image! howz that?, keeps the quality of text from label too, so i did that and wrote this OnPaint event:
                      Code:
                      Graphics g = e.Graphics;
                      Bitmap btmap = new Bitmap(labelX1.Size.Width, labelX1.Size.Height);
                      labelX1.DrawToBitmap(btmap, new Rectangle(0, 0, labelX1.Size.Width, labelX1.Size.Height));
                      g.DrawImage(btmap, new Point(5, 5));
                      //g.DrawString("Sample Graphics...", Font, Brush, new PointF(0, 0));
                      //TextRenderer.DrawText(g, "Sample TextRenderer...", Font, new Point(0, 25), Color.Navy);
                      g.Dispose();
                      but for some strange reason, it freezes my app (keeps painting again and again and again...forever ) and then after 15 seconds gives this Exception:
                      Code:
                      System.Argument Exception: Parameter is not valid.
                      any ideas?

                      Comment

                      • GaryTexmo
                        Recognized Expert Top Contributor
                        • Jul 2009
                        • 1501

                        #56
                        What I was saying was, use the graphics to draw all the text. Anything you want on your button, you can draw yourself.

                        I'll try looking at the bitmap thing later, but I think it's a good idea. So long as you realize that it wont' change with the OS theme, which I dont' think you care about anyway.

                        Comment

                        • vishal1082
                          New Member
                          • Apr 2009
                          • 92

                          #57
                          nope i have tested it on windows 2000 too, it does not change theme :) i run on Win7

                          Comment

                          • vishal1082
                            New Member
                            • Apr 2009
                            • 92

                            #58
                            after being stuck on this part for about 2 weeks and support from all of you guys, i m happy to say that i m screwed, no, jokes, anyways i am successful to be able to draw the text correctly, neatly and nicely by drawing a bitmap of the label and make the background of bitmap transparent (a little little problem here), here's the codez:
                            Code:
                            using System;
                            using System.Collections.Generic;
                            using System.ComponentModel;
                            using System.Drawing;
                            using System.Data;
                            using VM = VishalMethods;
                            using System.Text;
                            using System.Windows.Forms;
                            using System.Threading;
                            
                            namespace organizer
                            {
                                public partial class task_show : UserControl
                                {
                                    #region variables
                                    sTask _task;
                                    Bitmap b_lbl_time;
                                    bool _bitmapavailable = false;
                                    #endregion
                            
                                    #region load
                                    private void task_show_Load(object sender, EventArgs e)
                                    {
                                        RefreshBitmaps();
                                        new Thread(new ThreadStart(delegate//you may learn something new here :)
                                            {
                                                SetTime();
                                            })).Start();
                                    }
                                    #endregion
                            
                                    #region set values and language
                                    private void SetTime()
                                    {
                                        string hour , minute, second;
                                        //hour
                                        if (Convert.ToInt32(VM.DateAndTime.Time.To12Hour(_task.DateTime.Hour)[0]) < 10)
                                            hour = "0" + VM.DateAndTime.Time.To12Hour(_task.DateTime.Hour)[0];
                                        else
                                            hour = VM.DateAndTime.Time.To12Hour(_task.DateTime.Hour)[0];
                                        //minute
                                        if (_task.DateTime.Minute < 10)
                                            minute = "0" + _task.DateTime.Minute;
                                        else
                                            minute = _task.DateTime.Minute.ToString();
                                        //second
                                        if (_task.DateTime.Second < 10)
                                            second = "0" + _task.DateTime.Second;
                                        else
                                            second = _task.DateTime.Second.ToString();
                                        string time = Language.ConvertNumberToSelectedLang(hour) + ":" + Language.ConvertNumberToSelectedLang(minute) + ":" + Language.ConvertNumberToSelectedLang(second) + " " + VM.DateAndTime.Time.To12Hour(_task.DateTime.Hour)[1];
                            
                                        lbl_time.Text = time;
                                    }
                                    #endregion
                            
                                    #region text painting and stuff
                                    private void task_show_Paint(object sender, PaintEventArgs e)
                                    {
                                        if (!_bitmapavailable) { RefreshBitmaps(); }
                                        PaintAll();
                                    }
                            
                                    private void PaintAll()
                                    {
                                        using(Graphics g = back.CreateGraphics())
                                        {
                                            this.Invoke((MethodInvoker)delegate { g.DrawImage(b_lbl_time, lbl_time.Location); });
                                        }            
                                    }
                            
                                    private void RefreshBitmaps()
                                    {
                                        Bitmap btmap = new Bitmap(lbl_time.Size.Width, lbl_time.Size.Height);
                                        lbl_time.DrawToBitmap(btmap, new Rectangle(0, 0, lbl_time.Size.Width, lbl_time.Size.Height));
                                        b_lbl_time = MakeTransparent(btmap, lbl_time.BackColor);
                                        //b_lbl_time.Save(VM.FilesAndFolders.Paths.Desktop + "\\woo.png");
                            
                            
                                        _bitmapavailable = true;
                                    }
                            
                                    private Bitmap MakeTransparent(Bitmap Image, Color Base)
                                    {
                                        Image.MakeTransparent(Base);
                                        return Image;
                                    }
                                    #endregion
                                }
                            }
                            see the Control's OnLoad event you may learn something new :) I use those type of Thread starters everywhere, you can just directly write your code in it, instead of calling a method seperatly...

                            for anyone wondering what is "using VM = VishalMethods;" i made a DLL of my own for use in all my applications, contains methods and structs I normally use and need time to time, from hardware info to Email, Downloads it also has a Sever and Client :)

                            BACK TO THE TOPIC! maheam

                            it looks like this when its not mouse over-ed:

                            and like this when thrs mouse over it:


                            and yes taking mouse over the text also make it glow, just perfect how i wanted but if you look closely in mouse over image you will see a little "blue" color around text, its not doing the transparency job nice, any ideas?

                            Comment

                            • vishal1082
                              New Member
                              • Apr 2009
                              • 92

                              #59
                              nothing for transparency?

                              Comment

                              • mikeil
                                New Member
                                • Dec 2011
                                • 1

                                #60
                                Hey :) there is a very simple answer for this - set label Enabled field to false. will ignore mouse interactions and button should be available.

                                Comment

                                Working...