Results 1 to 6 of 6

Thread: Flickering button with PNG image

  1. #1
    Join Date
    Apr 2011
    Posts
    64

    Flickering button with PNG image

    I have noticed an issue in the project which you have mentioned over here. Well I have noticed that the location of the button is changing dynamically. The button is having the PNG image which is having transparent and background is also seems to be transparent. When I am moving the button it gets flickers. Let me know if you are having any issue to fix the matter of mine. Thanks a lot in advance.

  2. #2
    Join Date
    Apr 2009
    Posts
    569

    Re: Flickering button with PNG image

    Looking at the situation which you have provided over here I am suggesting that you should try to fix the matter of yours. I recommend that you should try with the double buffering by using the following piece of code.
    Code:
    Form1(void)
    {
    InitializeComponent();
    SetStyle(ControlStyles::UserPaint, true);
    SetStyle(ControlStyles::AllPaintingInWmPaint, true);
    SetStyle(ControlStyles:DoubleBuffer, true);
    UpdateStyles();
    }

  3. #3
    Join Date
    May 2009
    Posts
    529

    Re: Flickering button with PNG image

    I think you need to use the paint method of the button which you can redraw the button image in this particular situation. You should use the following code and see whether it is working or not.
    Code:
    private: System::Void Button_Palanca_IZQ_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
    g->DrawImage(image,loc);
    }
    you should copy and paste the above mentioned code into the project and see whether it is working or not.

  4. #4
    Join Date
    May 2009
    Posts
    543

    Re: Flickering button with PNG image

    Well I am suggesting following code which you can use to fix the matter of yours and see whether it is working or not.
    Code:
    // Load background image from file and adjust resolution
    
          Bitmap ^bmpTemp = gcnew Bitmap("..\\palancaBase_upsampled.bmp");
          Diagnostics::Trace::Assert(bmpTemp != nullptr, "Construction of background bitmap from file failed");
          Graphics ^grTemp = CreateGraphics();
          bmpTemp->SetResolution(grTemp->DpiX, grTemp->DpiY);
          BackgroundImage = bmpTemp;
    I am sure that the above mentioned code would definitely help you pout to fix the matter of yours.

  5. #5
    Join Date
    May 2009
    Posts
    511

    Re: Flickering button with PNG image

    I am suspecting that you have placed the button on the panel and hence you will not have any direct to the style. I recommend that you have to use the custom panel. Also there could be an issue with Overide OnPaint or there could be an issue with Paint event. You should derive a class from the user control and IDE should be provide support for this. You should create the same and append with the new class and s let me know about the result.

  6. #6
    Join Date
    May 2009
    Posts
    637

    Re: Flickering button with PNG image

    An invisible button in to the repainting would not make any repainting so I think we have to work with the timer tick handler which is responsible for the movement of the button into the project if yours. in order to implement the same you have to use the following code into the project of yours.
    Code:
    private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
    
                 loc+=5;
                 if(loc>600) loc=0;
                 Drawing::Region ^rgToInvalidate = gcnew Drawing::Region(button1->Bounds);  // Store old button area
                 button1->Location = System::Drawing::Point(loc,loc);
                 rgToInvalidate->Union(button1->Bounds);  // Add new button area
    
                 // Invalidate the union of the old and new button areas
    
                 Invalidate(rgToInvalidate);
               }
    The above mentioned code would make the repainting of the button so try the same and let me know whether it is working or not.

Similar Threads

  1. Replies: 12
    Last Post: 26-09-2011, 11:01 PM
  2. Replies: 3
    Last Post: 06-04-2011, 08:24 AM
  3. Flickering Of the LED With the Power Button In Dell U2410
    By Belendithas in forum Monitor & Video Cards
    Replies: 4
    Last Post: 25-11-2010, 05:04 AM
  4. I want image instead of Back and Foward button in HTML
    By Kasper in forum Software Development
    Replies: 4
    Last Post: 11-02-2010, 07:27 PM
  5. How can I display image on a button with pure HTML?
    By JangoRap in forum Software Development
    Replies: 3
    Last Post: 16-02-2009, 08:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,306,519.60524 seconds with 17 queries