dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: GDI+ PNG can have mouse events?

  1. #1
    Join Date
    Jan 2008
    Posts
    85

    GDI+ PNG can have mouse events?

    Is there a way to capture mouse events in a GDI+ PNG?

    I would like to do something like this:

    http://www.codeproject.com/KB/button...select=2596212

    Does any one knows where i can find a tutorial cuz i have searched well over 5 hours without luck.

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: GDI+ PNG can have mouse events?

    GDI+ PNG have nothing to with events. . they are graphical representations. On windows have mouse events. The link to your article is about buttons. Buttons are windows, so they have mouse events.

    So, what have you actually been looking for those 5 hours ?

  3. #3
    Join Date
    Jan 2008
    Posts
    85

    Re: GDI+ PNG can have mouse events?

    Quote Originally Posted by Skizmo View Post
    GDI+ PNG have nothing to with events. . they are graphical representations. On windows have mouse events. The link to your article is about buttons. Buttons are windows, so they have mouse events.
    Oh ok,So how can i actually load a png with transparency for the buttons?

    Quote Originally Posted by Skizmo View Post
    So, what have you actually been looking for those 5 hours ?
    Apparently something that doesn't exist.

  4. #4
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: GDI+ PNG can have mouse events?

    Oh ok,So how can i actually load a png with transparency for the buttons?
    Sure, you can. But first decide what exactly you want to accomplish. Transparency, PNG viewing or button control?
    If all of them, plan to complete them one by one!
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  5. #5
    Join Date
    Jan 2008
    Posts
    85

    Re: GDI+ PNG can have mouse events?

    What i plan to make i a Transparent Button with a PNG image.

    So that it can be any shape the PNG has,For a beautiful GUI.

    *Edit*

    The PNG has transparency of course.

  6. #6
    Join Date
    Jan 2008
    Posts
    85

    Re: GDI+ PNG can have mouse events?

    Help?

  7. #7
    Join Date
    Jan 2008
    Posts
    85

    Re: GDI+ PNG can have mouse events?

    at least some one point me to a tutorial cuz i can't find any

  8. #8
    Join Date
    Jan 2008
    Posts
    85

    Re: GDI+ PNG can have mouse events?

    Quote Originally Posted by Ajay Vijay View Post
    Sure, you can. But first decide what exactly you want to accomplish. Transparency, PNG viewing or button control?
    If all of them, plan to complete them one by one!
    Can you point me to a tutorial?

  9. #9
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,116

    Re: GDI+ PNG can have mouse events?

    Quote Originally Posted by I_want_to_learn View Post
    Can you point me to a tutorial?
    You are not getting any responses because you have not shown any effort.

    There have already been three distinct tasks identified. Have you tried them each independantly (as recommended). Did you get at least one of them to work? If not working, then at least compilng?

    If you are having problems with one of the three, then post a minimal (nothing extra) yet complete (we can copy/paste your code into an empty file and duplicate your results) sample [using proper code tags, as explained in the BEFORE you post announcement].
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  10. #10
    Join Date
    Jan 2008
    Posts
    85

    Re: GDI+ PNG can have mouse events?

    Quote Originally Posted by TheCPUWizard View Post
    You are not getting any responses because you have not shown any effort.

    There have already been three distinct tasks identified. Have you tried them each independently (as recommended). Did you get at least one of them to work? If not working, then at least compiling?

    If you are having problems with one of the three, then post a minimal (nothing extra) yet complete (we can copy/paste your code into an empty file and duplicate your results) sample [using proper code tags, as explained in the BEFORE you post announcement].
    what tasks?

    These?:
    Sure, you can. But first decide what exactly you want to accomplish. Transparency, PNG viewing or button control?
    If all of them, plan to complete them one by one!
    Anyways i did some testing before posting making the thread but couldn't even compile so i didn't put them here cuz it would be pointless.

    bit here it is:

    This is what i do to display a PNG on my dialog on run time.

    But i need a way to do this on a button.
    Code:
    #include <gdiplus.h>
    
    #pragma comment (lib,"gdiplus.lib")
    
    using namespace Gdiplus;
    
    ... all MFC stuff
    
    void CAppName::OnPaint()
    {
           CPaintDC dc(this); // device context for painting
    
       if (IsIconic())
       {
    
          SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
    
          // Center icon in client rectangle
          int cxIcon = GetSystemMetrics(SM_CXICON);
          int cyIcon = GetSystemMetrics(SM_CYICON);
          CRect rect;
          GetClientRect(&rect);
          int x = (rect.Width() - cxIcon + 1) / 2;
          int y = (rect.Height() - cyIcon + 1) / 2;
    
          // Draw the icon
          dc.DrawIcon(x, y, m_hIcon);
       }
       else
       {
          CDialog::OnPaint();
       }
    
          //heres where i put the code to paint a PNG on runtime
    
           Rect rect(20,20,50,50);
           Graphics grpx(dc);
           Image * Img = Image::FromFile(L"DriveIcon.png",FALSE);
           grpx.DrawImage(Img,rect);
    }

  11. #11
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,116

    Re: GDI+ PNG can have mouse events?

    There is no supriise that your code will not compile...
    Code:
    ... all MFC stuff
    is not valid C++.

    Go back and carefully re-read my post about what should be in a code post.

    Take your file that does not compile, and make a copy. Then start removing lines that have nothing to do with the problem. You should be left with a small (typically under 20 lines not coundiong breaces and blanks) that reproduces the problem. Then you post that. Along with the exact (copy/paste to not re-type) error messages you are getting.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  12. #12
    Join Date
    Jan 2008
    Posts
    85

    Re: GDI+ PNG can have mouse events?

    Quote Originally Posted by TheCPUWizard View Post
    There is no supriise that your code will not compile...
    Code:
    ... all MFC stuff
    is not valid C++.
    I know that is not C++,I posted that code so people could have a basic idea of what i'm triyng to do.

    Quote Originally Posted by TheCPUWizard View Post
    Go back and carefully re-read my post about what should be in a code post.

    Take your file that does not compile, and make a copy. Then start removing lines that have nothing to do with the problem. You should be left with a small (typically under 20 lines not coundiong breaces and blanks) that reproduces the problem. Then you post that. Along with the exact (copy/paste to not re-type) error messages you are getting.
    The problem is that i don't have an idea on how to draw a PNG to the button,i don't know where to start.

  13. #13
    Join Date
    Jan 2008
    Posts
    178

    Re: GDI+ PNG can have mouse events?

    See Google Groups, it has been answered many times...

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)