|
This sounds like an owner drawn control to me, unless the richedit box has a property to centre the text.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i guess u want m_Text.LineLength() ??
V
|
|
|
|
|
You can use MFC CEdit::GetLineCount() or the Win32 Message EM_GETLINECOUNT to get the number of lines.
--> . If the number of lines is three or less it should come the center of the dialog vertically.
I can't understand your question properly. do you meant to say if the number of lines are 3 or less, you don't want any scrollbar?
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
It sounds like you need to use the ES_CENTER and ES_MULTILINE styles.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hello there guys.
Using VC++/MFC, I successfully created a new html file, but when the application was launch, an empty window appeared. The html created didn't display on that window.
For more details:
Inside of the MyAppView.cpp ::OnInitialUpdate(), a function is called that will create a html file(for e.g. CreateHtml("./test.htm") )where "test.htm" is the htm file created. Then Displaying the html using Navigate("file://..../test.htm"); I'm wondering why the window is empty. I check the test.htm file created and it's not empty. I also tried Navigate2("file://...../menu.htm") and still empty window was display...
Also, I tried passing it to an existing URL like "http://www.codeproject.com" and there's no problem with it.
I'd like to ask if I miss something there?. Is there's a way that the created html file is the display on the window?
Thanks..
With great power comes a great responsibility.
|
|
|
|
|
I have re-created another project that had similar functions. It worked correctly.
Please, try to open created HTML files by IE to check whether that files display well or not.
Contact me if you want to get a working sample project by email.
|
|
|
|
|
Thanks for the reply.
I already try to open the created HTML files by IE and also by Mozilla and it display fine. That's why I'm wondering how I can deal with it.
Please... please... help me with this matter.
How can I contact you?
Thanks a lot....
With great power comes a great responsibility.
|
|
|
|
|
Hello Friends
I have developed an application in which I want to play my *.WAV, *.MP3 or any other audio file.
How to achieve this ? Any example ?
Regards,
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Embedd the Windows Media Player in your app or use DirectShow.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is it possible to view the Japanese text in the dialog box editor itself?
|
|
|
|
|
Try to use APPWZJPN.DLL for your project. Menubars, Dialogs, etc. will display in Japanase. If APPWZJPN.DLL is not existed in your "Microsoft Visual Studio\Common\MSDev98\Bin\IDE" folder, copy it from the CD installer of Visual C++. Or just google it and put it on that folder.
Hope it will helps.
With great power comes a great responsibility.
|
|
|
|
|
Ok. I will try in that way.
Thanks for your suggestion.
|
|
|
|
|
Hello All,
How can I give mulitlingual support to my dialogs?
Thank you.
- NS -
|
|
|
|
|
|
In my case I found that the best solution was the creation of several XML files (one for each language needed) with all the text needed referenced by a unique id and call each text from within the code like: GetMessage(int id).
then, the only hardcoded part is the id of the message, not the whole string.
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Hi,
Is there a free downloadable C++ Class design tool.
I am not looking a complex tool like UML tools. Simple tool which can represent the class and the properties in form of a diagram..
Thanks,
Shiva P
|
|
|
|
|
What about MS Visio? It's not free but it comes with Office packages and it meets your goals.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
This message will not be sent, when i use SetItemText to change the item
text.
I want the parent to be notified when SetItemText is called, because I don't call SetItemText in CListCtrl's parent.
|
|
|
|
|
followait wrote:
when i use SetItemText to change the item
text.
Look for LVN_ITEMCHANGED or LVN_ITEMCHANGING message
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I tried, but it didn't work.
There is no LVN_ITEMCHANGED or LVN_ITEMCHANGING when SetItemText is called.
|
|
|
|
|
Hi,
the CListCtrl is in a dialog?
Have you create a dialog member function for this CListCtrl (e.g. OnItemchangedMyCListCtrl)? (This is OK at my projects)
Or have you the dialog member function "PreTranslateMessage" and look for the LVN_ITEMCHANGED message?
Greetings
Frank
|
|
|
|
|
Maybe I can not express myself.I mean that I want to develop a ActiveX control container.
Firstly, my document CxxDoc is derived from COleDocument,and the constructor as following:
CxxDoc::CxxDoc()
{
// EnableCompoundFile();
// ^^^^^^^^^^^^^^^^^^^^^^^^^^I need a flat (uncompound) file.
...
}
Is it OK????
Secondly,my client item is CxxClientItem
class CxxClientItem : public COleClientItem
The WriteItem and ReadItem function (copied from the sample program of ActiceX control test container in Visual C++) as follows. They can work correctly in compound document. Please tell me how to change them from compound document to flat(uncompound) document.
void CxxClientItem::WriteItem( CArchive& ar )
{
USES_CONVERSION;
IStoragePtr pStorage;
IStreamPtr pStream;
IPersistStreamInitPtr pPSI;
TCHAR szItemName[64];
HRESULT hResult;
IPersistStoragePtr pPersistStorage;
CxxDoc* pDoc;
CLSID clsid;
(void)ar;
pDoc = GetDocument();
ASSERT_VALID( pDoc );
ASSERT( pDoc->m_lpRootStg != NULL );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
ASSERT( pDoc->m_bCompoundFile );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
ASSERT( m_lpStorage != NULL );
ASSERT( !ar.m_bForceFlat );
GetItemName( szItemName );
if( !pDoc->m_bSameAsLoad )
{
hResult = pDoc->m_lpRootStg->CreateStorage( T2COLE( szItemName ),STGM_CREATE|STGM_READWRITE|STGM_TRANSACTED|STGM_SHARE_EXCLUSIVE, 0, 0, &pStorage );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
m_lpNewStorage = pStorage;
m_lpNewStorage->AddRef();
m_bNeedCommit = TRUE;
}
else
{
pStorage = m_lpStorage;
}
pPersistStorage = m_lpObject;
if( pPersistStorage != NULL )
{
pPersistStorage->GetClassID( &clsid );
hResult = WriteClassStg( pStorage, clsid );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
hResult = pPersistStorage->Save( pStorage, pDoc->m_bSameAsLoad );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
}
else
{
pPSI = m_lpObject;
if( pPSI == NULL )
{
AfxThrowOleException( E_NOINTERFACE );
}
// Set the storage's CLSID to CLSID_NULL, so we know that we actually
// used a stream
hResult = WriteClassStg( pStorage, CLSID_NULL );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
hResult = pStorage->CreateStream( L"Contents", STGM_CREATE|
STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
pPSI->GetClassID( &clsid );
hResult = WriteClassStm( pStream, clsid );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
hResult = pPSI->Save( pStream, TRUE );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
pStream.Release();
}
m_bNeedCommit = TRUE;
pStorage->Commit( STGC_ONLYIFCURRENT );
}
void CxxClientItem::ReadItem( CArchive& ar )
{
USES_CONVERSION;
BOOL tUsedStream;
IStoragePtr pStorage;
IPersistStreamInitPtr pPSI;
IStreamPtr pStream;
TCHAR szItemName[64];
HRESULT hResult;
BOOL tQuickActivated;
IPersistStoragePtr pPersistStorage;
CLSID clsid;
(void)ar;
CxxDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
ASSERT(pDoc->m_lpRootStg != NULL);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document ASSERT(pDoc->m_bCompoundFile);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
ASSERT(m_lpStorage == NULL);
ASSERT(m_lpLockBytes == NULL);
ASSERT( !ar.m_bForceFlat );
// get item name
GetItemName( szItemName );
// open storage for this item
hResult = pDoc->m_lpRootStg->OpenStorage( T2COLE( szItemName ), NULL,
STGM_READWRITE|STGM_TRANSACTED|STGM_SHARE_EXCLUSIVE, 0, 0, &pStorage );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^It is wrong in uncompound document
if( hResult != S_OK )
{
TRACE1( "Warning: unable to open child storage %s.\n", szItemName );
// upon failure throw file exception (item will be cleaned up)
AfxThrowOleException( hResult );
}
ASSERT(pStorage != NULL);
// remember the storage
m_lpStorage = pStorage;
ASSERT(m_lpStorage != NULL);
m_lpStorage->AddRef();
// attempt to load the object from the storage
hResult = ReadClassStg( m_lpStorage, &clsid );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
tUsedStream = FALSE;
if( clsid == CLSID_NULL )
{
hResult = m_lpStorage->OpenStream( L"Contents", NULL, STGM_READ|
STGM_SHARE_EXCLUSIVE, 0, &pStream );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
hResult = ReadClassStm( pStream, &clsid );
if( FAILED( hResult ) )
{
AfxThrowOleException( hResult );
}
tUsedStream = TRUE;
}
m_tExtendedControl = TRUE;
hResult = CExtendedControl::CreateInstance( clsid, this, NULL,
IID_IOleObject, (void**)&m_lpObject );
if( FAILED( hResult ) )
{
m_tExtendedControl = FALSE;
// The control may not like being aggregated on, so just try to create it
// directly and punt the extended control stuff.
hResult = CoCreateInstance( clsid, NULL, CLSCTX_INPROC_SERVER|
CLSCTX_INPROC_HANDLER|CLSCTX_LOCAL_SERVER, IID_IOleObject,
(void**)&m_lpObject );
if( SUCCEEDED( hResult ) )
{
TCControlTrace( TRACELEVEL_NORMAL, this,
"Could not aggregate on the control, so it won't support extended properties.\n" );
}
}
if( SUCCEEDED( hResult ) )
{
CString strUserType;
GetUserType( USERCLASSTYPE_SHORT, strUserType );
GetDocument()->CreateUniqueItemName( this, strUserType,
m_strDisplayName );
}
if( m_tExtendedControl )
{
m_pExtendedControl = m_lpObject;
ASSERT( m_pExtendedControl != NULL );
m_pExtendedControl->Name = _bstr_t( m_strDisplayName );
}
if( SUCCEEDED( hResult ) )
{
hResult = InitControlInfo();
}
tQuickActivated = FALSE;
if( SUCCEEDED( hResult ) )
{
tQuickActivated = QuickActivate();
if( !tQuickActivated )
{
m_lpObject->GetMiscStatus( DVASPECT_CONTENT, &m_dwMiscStatus );
if( m_dwMiscStatus&OLEMISC_SETCLIENTSITEFIRST )
{
hResult = m_lpObject->SetClientSite( GetClientSite() );
if( FAILED( hResult ) )
{
TCControlTrace( TRACELEVEL_NORMAL, this,
"SetClientSite failed.\n" );
}
}
}
}
if( SUCCEEDED( hResult ) )
{
pPersistStorage = m_lpObject;
if( pPersistStorage != NULL )
{
hResult = pPersistStorage->Load( m_lpStorage );
}
else
{
if( !tUsedStream )
{
hResult = E_NOINTERFACE;
}
else
{
pPSI = m_lpObject;
if( pPSI == NULL )
{
hResult = E_NOINTERFACE;
}
else
{
hResult = pPSI->Load( pStream );
}
}
}
}
if( SUCCEEDED( hResult ) )
{
if( !tQuickActivated )
{
if( !(m_dwMiscStatus&OLEMISC_SETCLIENTSITEFIRST) )
{
hResult = m_lpObject->SetClientSite( GetClientSite() );
if( FAILED( hResult ) )
{
TCControlTrace( TRACELEVEL_NORMAL, this,
"SetClientSite failed.\n" );
}
}
}
}
CheckGeneral(hResult);
}
-- modified at 4:04 Thursday 8th September, 2005
|
|
|
|
|
I tried as bellow,but I think it doesn't work correctly.
Who knows how?? Thank you very much.
IHTMLDocument2 * pDoc = NULL;
IHTMLWindow2 *pHTMLWnd = NULL;
IHTMLDocument2 * pFrameDoc=NULL;
IHTMLFramesCollection2 *pFramesCollection=NULL;
LPDISPATCH lpDispatch;
long p;
VARIANT varindex,varresult;
varresult.vt=VT_DISPATCH;
varindex.vt = VT_I4;
try
{
pDoc = (IHTMLDocument2*)(GetHtmlDocument());
if(pDoc!=NULL)
{
pDoc->get_frames(&pFramesCollection);
if(pFramesCollection!=NULL)
{
pFramesCollection->get_length(&p);
if(p>0)
{
for(int i=0; i<p; i++)
="" {
="" varindex.lval="i;"
="" if(pframescollection-="">item(&varindex, &varresult) ==S_OK)
{
lpDispatch=(LPDISPATCH)varresult.ppdispVal;
if (SUCCEEDED(lpDispatch->QueryInterface(IID_IHTMLWindow2, (LPVOID *)&pHTMLWnd)))
{
if(SUCCEEDED(pHTMLWnd->get_document( &pFrameDoc)))
{
BSTR bstr=NULL;
HRESULT hr=pFrameDoc->get_URL(&bstr);
ASSERT(SUCCEEDED(hr));
CString str= bstr;
SysFreeString(bstr);
pFrameDoc->Release();
pFrameDoc=NULL;
}
pHTMLWnd->Release();
pHTMLWnd=NULL;
}
}
}
}
}
}
}
catch(...)
{
};
try
{
if(pDoc != NULL)
pDoc->Release();
if(pFramesCollection != NULL)
pFramesCollection->Release();
}
catch(...)
{
};
|
|
|
|
|
Code above doesn't look well . I paste it again .
IHTMLDocument2 * pDoc = NULL;
IHTMLWindow2 *pHTMLWnd = NULL;
IHTMLDocument2 * pFrameDoc=NULL;
IHTMLFramesCollection2 *pFramesCollection=NULL;
LPDISPATCH lpDispatch;
long p;
VARIANT varindex,varresult;
varresult.vt=VT_DISPATCH;
varindex.vt = VT_I4;
try
{
pDoc = (IHTMLDocument2*)(GetHtmlDocument());
if(pDoc!=NULL)
{
pDoc->get_frames(&pFramesCollection);
if(pFramesCollection!=NULL)
{
pFramesCollection->get_length(&p);
if(p>0)
{
for(int i=0; i<p; i++)
="" {
="" varindex.lval="i;"
="" if(pframescollection-="">item(&varindex, &varresult) ==S_OK)
{
lpDispatch=(LPDISPATCH)varresult.ppdispVal;
if (SUCCEEDED(lpDispatch->QueryInterface(IID_IHTMLWindow2, (LPVOID *)&pHTMLWnd)))
{
if(SUCCEEDED(pHTMLWnd->get_document( &pFrameDoc)))
{
BSTR bstr=NULL;
HRESULT hr=pFrameDoc->get_URL(&bstr);
ASSERT(SUCCEEDED(hr));
CString str= bstr;
SysFreeString(bstr);
pFrameDoc->Release();
pFrameDoc=NULL;
}
pHTMLWnd->Release();
pHTMLWnd=NULL;
}
}
}
}
}
}
}
catch(...)
{
};
try
{
if(pDoc != NULL)
pDoc->Release();
if(pFramesCollection != NULL)
pFramesCollection->Release();
}
catch(...)
{
};
|
|
|
|
|
It works perfect for me.
What's wrong?
"tous les sifflets des trains, toutes les sirènes des bateaux
m'ont chanté cent fois la chanson de l'Eldorado"
rechi+
|
|
|
|