Click here to Skip to main content
15,916,379 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Phone Number Format Pin
David Crow22-Dec-04 8:13
David Crow22-Dec-04 8:13 
GeneralRe: Phone Number Format Pin
Anonymous22-Dec-04 9:36
Anonymous22-Dec-04 9:36 
GeneralScrollbar doesn't scroll all the way Pin
Budric B.22-Dec-04 4:49
Budric B.22-Dec-04 4:49 
GeneralChanging screen resolution in windows xp Pin
Mohammad A Gdeisat22-Dec-04 4:41
Mohammad A Gdeisat22-Dec-04 4:41 
GeneralRe: Changing screen resolution in windows xp Pin
David Crow22-Dec-04 5:07
David Crow22-Dec-04 5:07 
GeneralRe: Changing screen resolution in windows xp Pin
Mohammad A Gdeisat22-Dec-04 7:38
Mohammad A Gdeisat22-Dec-04 7:38 
GeneralStrange CTypedPtrArray error Pin
Polly Parrot22-Dec-04 3:31
Polly Parrot22-Dec-04 3:31 
Generalinserting bmp in file Pin
verma-rahul22-Dec-04 3:07
verma-rahul22-Dec-04 3:07 
I am using folowing code to insert BMP in RichEdit.

InsertPlotBitmap(CString szFileName)
{
USES_CONVERSION;
SCODE sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &m_lpLockBytes);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(m_lpLockBytes != NULL);
sc = ::StgCreateDocfileOnILockBytes(m_lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &m_lpStorage);
if (sc != S_OK)
{
VERIFY(m_lpLockBytes->Release() == 0);
m_lpLockBytes = NULL;
AfxThrowOleException(sc);
}

// CString szFileName=strSmile;


// attempt to create the object
sc = ::OleCreateFromFile(CLSID_NULL, T2COLE(szFileName),
IID_IUnknown, OLERENDER_DRAW, NULL, NULL, m_lpStorage, (void **) &m_lpObject);
if ( sc != S_OK )
{
TCHAR * lpMsgBuf;
::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL,
::GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf, 0, NULL );
CString msg( lpMsgBuf );
msg += _T("\n\n\n" );
msg += szFileName;
AfxMessageBox( msg, MB_OK );
::LocalFree( lpMsgBuf );
return;
}

// m_lpObject is currently an IUnknown, convert to IOleObject
if (m_lpObject != NULL)
{
LPUNKNOWN lpUnk = m_lpObject;
m_lpObject = QUERYINTERFACE(lpUnk, IOleObject);
lpUnk->Release();
if (m_lpObject == NULL)
AfxThrowOleException(E_OUTOFMEMORY);
}

// cache the IViewObject interface
m_lpViewObject = QUERYINTERFACE(m_lpObject, IViewObject2);
if (m_lpViewObject == NULL)
return;

// setup for advises; we assume that OLE cleans them up properly
LPADVISESINK lpAdviseSink =
(LPADVISESINK)GetInterface(&IID_IAdviseSink);

// set up view advise
VERIFY(m_lpViewObject->SetAdvise(DVASPECT_CONTENT, 0, lpAdviseSink)
== S_OK);

// the server shows these in its user-interface
// (as document title and in File Exit menu)
m_lpObject->SetHostNames(T2COLE(AfxGetAppName()),
T2COLE(_T("Test")));

// all items are "contained" -- this makes our reference to this object
// weak -- which is needed for links to embedding silent update.
OleSetContainedObject(m_lpObject, TRUE);

// CHARRANGE cr;
//m_Ctrl_RichEdit.GetSel( cr );
//cr.cpMin = cr.cpMax -1;
//m_Ctrl_RichEdit.SetSel( cr );

REOBJECT reo;
memset( &reo, 0, sizeof( reo ) );
reo.cbStruct = sizeof( reo );
CLSID classID;
if ( m_lpObject->GetUserClassID( &classID ) != S_OK)
classID = CLSID_NULL;
reo.clsid = classID;
reo.cp = REO_CP_SELECTION;
reo.poleobj = m_lpObject;
reo.pstg = m_lpStorage;
LPOLECLIENTSITE lpClientSite;
GetIRichEditOle()->GetClientSite( &lpClientSite );
reo.polesite = lpClientSite;
SIZEL sizel;
sizel.cx = sizel.cy = 0; // let richedit determine initial size
reo.sizel = sizel;
reo.dvaspect = DVASPECT_CONTENT;
reo.dwFlags = REO_RESIZABLE;
reo.dwUser = 0;
HRESULT hr = GetIRichEditOle()->InsertObject( &reo );
}

This code works fine if i call from same window.But it gives error if i invoke from another dialog it gives error in the following line .
GetIRichEditOle()->GetClientSite( &lpClientSite );
can any body help me .

Learner always
GeneralRe: inserting bmp in file Pin
David Crow22-Dec-04 5:04
David Crow22-Dec-04 5:04 
GeneralRe: inserting bmp in file Pin
verma-rahul22-Dec-04 19:00
verma-rahul22-Dec-04 19:00 
Questionhow to prevent mfc dialog based app beign displayed on taskbar Pin
muharrem22-Dec-04 3:03
muharrem22-Dec-04 3:03 
AnswerRe: how to prevent mfc dialog based app beign displayed on taskbar Pin
Mohammad A Gdeisat22-Dec-04 8:03
Mohammad A Gdeisat22-Dec-04 8:03 
AnswerRe: how to prevent mfc dialog based app beign displayed on taskbar Pin
Mohammad A Gdeisat22-Dec-04 8:10
Mohammad A Gdeisat22-Dec-04 8:10 
QuestionSDI Project-How is a Dialog Resource loaded in a Window? Pin
jerry1211a22-Dec-04 2:32
jerry1211a22-Dec-04 2:32 
AnswerRe: SDI Project-How is a Dialog Resource loaded in a Window? Pin
Michael P Butler22-Dec-04 3:17
Michael P Butler22-Dec-04 3:17 
GeneralExport data from a process memory Pin
stumdoes22-Dec-04 1:17
stumdoes22-Dec-04 1:17 
GeneralRe: Export data from a process memory Pin
David Crow22-Dec-04 2:43
David Crow22-Dec-04 2:43 
GeneralRe: Export data from a process memory Pin
stumdoes22-Dec-04 4:45
stumdoes22-Dec-04 4:45 
GeneralRe: Export data from a process memory Pin
David Crow22-Dec-04 5:00
David Crow22-Dec-04 5:00 
GeneralRe: Export data from a process memory Pin
stumdoes22-Dec-04 5:17
stumdoes22-Dec-04 5:17 
GeneralRe: Export data from a process memory Pin
David Crow22-Dec-04 5:23
David Crow22-Dec-04 5:23 
GeneralRe: Export data from a process memory Pin
stumdoes22-Dec-04 20:23
stumdoes22-Dec-04 20:23 
GeneralRe: Export data from a process memory Pin
David Crow23-Dec-04 2:48
David Crow23-Dec-04 2:48 
GeneralADO ERROR error C2143: '_Connection' Pin
x86Assembeler22-Dec-04 0:57
x86Assembeler22-Dec-04 0:57 
GeneralRe: ADO ERROR error C2143: '_Connection' Pin
Blake Miller22-Dec-04 5:46
Blake Miller22-Dec-04 5:46 

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.