CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    50

    Angry Insert an icon at the place where i right click in the window

    Hi I have a class inherited from CCmdTarget which handles the right click event.when user select a choice from context menu then i have to show an icon at that window. plz help me.

  2. #2
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: Insert an icon at the place where i right click in the window

    How do you store the icons?? Do you need more then one icon to draw. I ask that because you can store in a CImageList and draw it by specifying the index
    Code:
    BOOL Draw( CDC* pDC,  int nImage, POINT pt,   UINT nStyle );
    or if you don't like that way get the icon handle and draw it on the screen with this function:
    Code:
    BOOL DrawIcon(int x,int y,HICON hIcon );
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  3. #3
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    50

    Re: Insert an icon at the place where i right click in the window

    I have only a single icon with me. how the application will identify x and y.

  4. #4
    Join Date
    Jan 2004
    Location
    Upper Austria
    Posts
    215

    Re: Insert an icon at the place where i right click in the window

    Quote Originally Posted by chetan_mnit2003
    I have only a single icon with me. how the application will identify x and y.
    you should get the x/y coordinates with the right-click window message. you could probably give a little more detail on your application or post some code, i'm sure someone can help you.

    btw: did you inherit directly from CCmdTarget? you should probably use CWnd or so as your base class, because i'm not sure if CCmdTarget offers a graphics context to draw the icon in.
    Last edited by reset-leo; March 27th, 2006 at 09:04 AM.
    reboot, and everything is good

    visit my website at hochleistung.at

  5. #5
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: Insert an icon at the place where i right click in the window

    You have to specify the x and the y coordinates...
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  6. #6
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    50

    Re: Insert an icon at the place where i right click in the window

    how can i get handle for the icon(HICON) because loadicon takes two parameters (HWND, Name) and i dont have HWND.

  7. #7
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: Insert an icon at the place where i right click in the window

    Try this
    Code:
    HICON hIcon=AfxGetApp()->Loadicon(IDI_YOURICON);
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  8. #8
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    50

    Re: Insert an icon at the place where i right click in the window

    Draw Icon takes CDC parameter. i have to show this icon on activeX control.so how can i take CDC for ActiveX Control.

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

Featured