|
cy163@hotmail.com wrote: You mean ONLY one ListCtrl can be associated with one view?
Yes, unless the view is a CFormView .
cy163@hotmail.com wrote: If so, Why there may be more than one ListCtrl in a dialog
Because a dialog is not a view.
cy163@hotmail.com wrote: Or, I misunderstand the view concept.
Perhaps. But, have no fear, there's plenty of online documentation/examples to help you out.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
If a view is drived from CFormView. How to distinguish between ListCtrls associated with it.
|
|
|
|
|
They each have a unique control ID, and thus a separate instance of CListCtrl .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
So, for a view derived from a non CFormView, GetListCtrl is used to get the reference of the ListCtrl associated with it.
for a view derived from a CFormView, how to get the references of ListCtrls associated with it. What command should be used.
|
|
|
|
|
cy163@hotmail.com wrote: So, for a view derived from a non CFormView...
Specifically, a CListView .
cy163@hotmail.com wrote: for a view derived from a CFormView, how to get the references of ListCtrls associated with it.
Like a dialog, each control has a unique ID and its own control variable (e.g., CListCtrl ).
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I am using VC 6.0. I would like to create a CFormView based project by using ClassWizard, so that I can see the following line in the CxxxxView class.
Class CxxxxView:CFormView
{
....
....
}
Please tell me how to do this using ClassWizard,
Thanks
|
|
|
|
|
The base view class to be used can be selected from the second last page I guess.
Click on your view class and select its base class.
The default is CView.
|
|
|
|
|
Thanks you superman for your reply.
Another question concerns the following code snippet. I wonder why
CListView::OnInitialUpdate();
can be called directly, without declaring an instance of the class CListView.
void CMyListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
ASSERT(GetStyle() & LVS_REPORT);
CListCtrl& theCtrl = GetListCtrl();
theCtrl.InsertColumn(0, _T("Player Name"), LVCFMT_LEFT);
LVCOLUMN col;
col.mask = LVCF_FMT | LVCF_TEXT;
col.pszText = _T("Jersey Number");
col.fmt = LVCFMT_LEFT;
theCtrl.InsertColumn(1, &col);
|
|
|
|
|
CListView is the base class of CMyListView .
The object already existing is made of both these classes and of course the other base classes.
So creating another object will not effect the current object.
Also, this is the way the overridden derived class function calls the base class function.
|
|
|
|
|
CListView::OnInitialUpdate();
is equals this->CListView::OnInitialUpdate();
CMyListView is derived from CListView. It can derives base class's function {public, protected}.
OnInitialUpdate is the virtual function. CListView::OnInitialUpdate() means call the base class 's function OnInitialUpdate() .
I think that you should read <<c++ primary="">> <<mfc programming="">> firstly.
|
|
|
|
|
Thanks for your attention on my postinngs and your replyes.
|
|
|
|
|
Hello, I have to Write/read a file with a structure wich contains CString data, if drop out the CString data from the structure it works but if I left the CString data the program crashes when attemps to read.
Here the structure
struct MyStructure
{
CString label
unsignet char data1
BYTE data2
}
the writing
struct MyStructure Estructura;
CFile FileConfig;
FileConfig.Open("ROMconfig.dat",CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite);
FileConfig.Seek(0,CFile::begin);
FileConfig.Write(&Estructura,sizeof(Estructura));
FileConfig.Close();
the reading
struct MyStructure Estructura;
CFile FileConfig ;
FileConfig.Open("ROMconfig.dat",CFile::modeCreate|CFile::modeNoTruncate|CFile::modeRead);
FileConfig.Seek(0,CFile::begin);
FileConfig.Read(&Estructura,sizeof(Estructura));
FileConfig.Close();
What I'm doing wrong, may be is something in relation with CString size, but I'm not sure.
And the file has to be a .dat file because is modification to an older application.
|
|
|
|
|
You can't save and read your data this way. Internally, a CString object stores its data in a pointer, so you will save only the address of the pointer and not its content. I suggest you read this article[^] which is about serialization in MFC. You'll get some ideas about how to serialize your data properly.
|
|
|
|
|
Ok, thanks , i will check it, very usefull. But for the other data types is it ok to save data i as described before? , I mean pherhaps is not the elegant way but it's working (not with CString), as I have to finish this work for tomorrow I was hoping there was a easier way, I only have to store some few words.
|
|
|
|
|
It would be easier to provide a function to save and a function to load the structure (functions in the structure itself). These functions will save and load all members of the structure. For the CString type, you first have to save the lenght of the string then the string itself (when loading, you read the lenght and then read that many characters from the file).
|
|
|
|
|
If you are using MFC then you could use the CArchive[^] class.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
hi
what is the note of using SHFileOperation function in win XP?
my program work correctly in vista but in XP it is crashed!
please help me
Zo.Naderi-Iran
|
|
|
|
|
Connot you debug it? At least, to get better help, you should post here the relevant code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
oh, thank you and excuse me
my problem solved.
its problem was in VS 2005. with VS 2008, it is ok.
thanks
Zo.Naderi-Iran
|
|
|
|
|
Hi all,
I want save the image with the annotation made on it.But i am able to save only the image but not the annotation.
I am using LeadTools 16.5 version(C DLL).
I know this is not the right place for this question.
But if anyone knows how to save the image with annotation .please help me.
I will be really greatful to you
Thanks
Raj
|
|
|
|
|
Hi
You musr ask your question in leadtools forum.
Are you working on a DICOM/PACS project?
www.logicsims.ir
|
|
|
|
|
Hi All
I try to create database and table in Access database through this way.
_CatalogPtr m_pCatalog = NULL;
CString con="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb;Jet OLEDB:Engine Type=5";
HRESULT hr = S_OK;
try
{
TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
m_pCatalog->Create((_bstr_t)con);
}
catch(_com_error pCE)
{
}
.
.
.
.
m_pCatalog->Release();
CoUninitialize();
Database name(test.mdb) read from list(list have more than one database name).I use here m_pCatalog->Release();
Now when i select different database name that time this line TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
through exception.
Exception show
HRESULT CreateInstance(const CLSID& rclsid, IUnknown* pOuter = NULL, DWORD dwClsContext = CLSCTX_ALL) throw()
{
HRESULT hr;
point out this line
_Release();
if (dwClsContext & (CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)) {
IUnknown* pIUnknown;
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast<void**>(&pIUnknown));
if (SUCCEEDED(hr)) {
hr = OleRun(pIUnknown);
if (SUCCEEDED(hr)) {
hr = pIUnknown->QueryInterface(GetIID(), reinterpret_cast<void**>(&m_pInterface));
}
pIUnknown->Release();
}
}
else {
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, GetIID(), reinterpret_cast<void**>(&m_pInterface));
}
if (FAILED(hr)) {
m_pInterface = NULL;
}
return hr;
}
I use m_pCatalog->Release() because once i create database and table then i try to free particular database.
Please help me
|
|
|
|
|
What was the exception message?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for reply
Unhandled exception at 0x004098ec in test.exe: 0xC0000005: Access violation reading location 0x00000008
|
|
|
|
|
Did you call Release , CoUninitialize , and then CreateInstance aqain?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|