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.
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 );
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.
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.
Re: Insert an icon at the place where i right click in the window
You have to specify the x and the y coordinates...
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.
Re: Insert an icon at the place where i right click in the window
Try this
Code:
HICON hIcon=AfxGetApp()->Loadicon(IDI_YOURICON);
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.