Click here to Skip to main content
15,914,225 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalmanaged c++ and licenses Pin
Roger Alsing27-Jan-04 21:38
Roger Alsing27-Jan-04 21:38 
GeneralGetting the Windows FontWidth Pin
Pazzuzu27-Jan-04 21:28
Pazzuzu27-Jan-04 21:28 
GeneralRe: Getting the Windows FontWidth Pin
Antti Keskinen27-Jan-04 21:46
Antti Keskinen27-Jan-04 21:46 
GeneralRe: Getting the Windows FontWidth Pin
Pazzuzu27-Jan-04 22:00
Pazzuzu27-Jan-04 22:00 
GeneralRe: Getting the Windows FontWidth Pin
Antti Keskinen28-Jan-04 1:39
Antti Keskinen28-Jan-04 1:39 
GeneralRe: Getting the Windows FontWidth Pin
Pazzuzu27-Jan-04 23:04
Pazzuzu27-Jan-04 23:04 
GeneralPaste gif, jpg images Pin
Filomela27-Jan-04 20:25
Filomela27-Jan-04 20:25 
GeneralRe: Paste gif, jpg images Pin
CodeBrain28-Jan-04 21:22
CodeBrain28-Jan-04 21:22 
You can't do this without using COM.
If you don't know COM it is a very ugly thing...

As I can remeber you have to implement the IRichEditOleCallback COM interface and then you have to set this interface as OLE callback in your rich edit control.

// Class REOLECallback implemenets IRichEditOleCallback
IRichEditOleCallback* mREOLECallback = new REOLECallback();
::SendMessage((HWND)m_yourRTFCtrl.GetSafeHwnd(), EM_SETOLECALLBACK, 0, (LPARAM) mREOLECallback);

If have found an implementation in the internet which seems to work, the method which does the main thing is GetNewStorage:
<br />
class REOLECallback : public IRichEditOleCallback<br />
{<br />
public:<br />
    // Constructor / Destructor<br />
    REOLECallback()	{   mRefCounter = 0;    }<br />
    ~REOLECallback(){}<br />
<br />
    // Methods of the IUnknown interface<br />
    STDMETHOD_(ULONG, AddRef)       (void);<br />
    STDMETHOD_(ULONG, Release)      (void);<br />
    STDMETHOD(QueryInterface)       (REFIID iid, void** ppvObject);<br />
<br />
    // Methods of the IRichEditOleCallback interface<br />
    STDMETHOD(ContextSensitiveHelp) (BOOL fEnterMode)                                                                                           {   return E_NOTIMPL;   }<br />
    STDMETHOD(DeleteObject)         (LPOLEOBJECT lpoleobj)                                                                                      {   return E_NOTIMPL;   }<br />
    STDMETHOD(GetClipboardData)     (CHARRANGE FAR *lpchrg, DWORD reco, LPDATAOBJECT FAR *lplpdataobj)                                          {   return E_NOTIMPL;   }<br />
    STDMETHOD(GetContextMenu)       (WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE FAR *lpchrg, HMENU FAR *lphmenu)                             {   return E_NOTIMPL;   }<br />
    STDMETHOD(GetDragDropEffect)    (BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect)                                                          {   return E_NOTIMPL;   }<br />
    STDMETHOD(GetInPlaceContext)    (LPOLEINPLACEFRAME FAR *lplpFrame, LPOLEINPLACEUIWINDOW FAR *lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo)    {   return E_NOTIMPL;   }<br />
    STDMETHOD(GetNewStorage)        (LPSTORAGE FAR *lplpstg);<br />
    STDMETHOD(QueryAcceptData)      (LPDATAOBJECT lpdataobj, CLIPFORMAT FAR *lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict)           {   return E_NOTIMPL;   }<br />
    STDMETHOD(QueryInsertObject)    (LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp)                                                                 {   return S_OK;        }<br />
    STDMETHOD(ShowContainerUI)      (BOOL fShow)                                                                                                {   return E_NOTIMPL;   }<br />
<br />
    // Data<br />
private:<br />
    DWORD      mRefCounter;<br />
};<br />


<br />
STDMETHODIMP REOLECallback::GetNewStorage(LPSTORAGE FAR *lplpstg)<br />
{<br />
    // Initialize a Storage Object from a DocFile in memory<br />
    LPLOCKBYTES lpLockBytes = NULL;<br />
    SCODE       sc  = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);<br />
    if (sc != S_OK) return sc;<br />
    sc = ::StgCreateDocfileOnILockBytes(lpLockBytes, STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, lplpstg);<br />
    if (sc != S_OK) lpLockBytes->Release();<br />
    return sc;<br />
}<br />
<br />
STDMETHODIMP REOLECallback::QueryInterface(REFIID iid, void** ppvObject)<br />
{<br />
    if (iid == IID_IUnknown || iid == IID_IRichEditOleCallback)<br />
	{<br />
		*ppvObject = this;  AddRef();<br />
		return S_OK;<br />
	}<br />
    else<br />
	{<br />
		return E_NOINTERFACE;<br />
	}<br />
}<br />
<br />
STDMETHODIMP_(ULONG) REOLECallback::AddRef()<br />
{<br />
	mRefCounter++;<br />
	return mRefCounter; <br />
}<br />
<br />
STDMETHODIMP_(ULONG) REOLECallback::Release()<br />
{<br />
	if ( --mRefCounter == 0 )<br />
	{<br />
		delete this;<br />
		return 0;<br />
	}<br />
	else<br />
	{<br />
		return mRefCounter; <br />
	}<br />
}<br />


As I remember this is what you have to do, but I am not sure if there was soemthing else what you have to consider.
BUT this seems only to work if you paste images which are embbeded into RTF text. So if you paste an image from Wordpad it will work, but if you want to paste an image from Paint in may not work!
GeneralRe: Paste gif, jpg images Pin
Filomela29-Jan-04 20:34
Filomela29-Jan-04 20:34 
GeneralRe: Paste gif, jpg images Pin
CodeBrain29-Jan-04 21:30
CodeBrain29-Jan-04 21:30 
GeneralRe: Paste gif, jpg images Pin
Filomela1-Feb-04 20:55
Filomela1-Feb-04 20:55 
GeneralRe: Paste gif, jpg images Pin
CodeBrain1-Feb-04 21:12
CodeBrain1-Feb-04 21:12 
GeneralRe: Paste gif, jpg images Pin
CodeBrain2-Feb-04 3:02
CodeBrain2-Feb-04 3:02 
GeneralRe: Paste gif, jpg images Pin
Filomela2-Feb-04 20:35
Filomela2-Feb-04 20:35 
GeneralRe: Paste gif, jpg images Pin
CodeBrain2-Feb-04 21:16
CodeBrain2-Feb-04 21:16 
GeneralRe: Paste gif, jpg images Pin
Filomela16-Feb-04 20:23
Filomela16-Feb-04 20:23 
GeneralRe: Paste gif, jpg images Pin
Filomela26-Mar-04 4:55
Filomela26-Mar-04 4:55 
GeneralAuthenticate the remote user credentials Pin
Mr Bose Dayala27-Jan-04 19:47
Mr Bose Dayala27-Jan-04 19:47 
GeneralFocus problem! Pin
rohit.dhamija27-Jan-04 19:28
rohit.dhamija27-Jan-04 19:28 
GeneralRe: Focus problem! Pin
Antti Keskinen27-Jan-04 21:15
Antti Keskinen27-Jan-04 21:15 
GeneralMore Help Plz Pin
MrNiceBerG27-Jan-04 18:39
MrNiceBerG27-Jan-04 18:39 
GeneralTrying to capture the screen, Getting some Error Pin
santosh k27-Jan-04 18:24
santosh k27-Jan-04 18:24 
GeneralRe: Trying to capture the screen, Getting some Error Pin
Diddy28-Jan-04 22:40
Diddy28-Jan-04 22:40 
GeneralClass/Overloaded funtion help Pin
tekkie241227-Jan-04 16:29
tekkie241227-Jan-04 16:29 
GeneralRe: Class/Overloaded funtion help Pin
Michael Gunlock27-Jan-04 16:45
Michael Gunlock27-Jan-04 16:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.