|
It should work!
if u use CListCtrl object as a data member of a view or dialog class, it is destroyed when its owner is destroyed. If you use aCListView, the framework destroys the control when it destroys the view.
lokesh
|
|
|
|
|
Hi,
Are you using SetItemData to store pointer to objects? If so, have you remembered to delete them before removing the item from the list?
Also, have you included:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
to your .cpp files so that you can track the new's and trace the leaks?
Cheers,
Andy
|
|
|
|
|
I need to put three different forms in SDI application's CView window so that user can choose which view he wants to see. If I make 3 different CFormView classes how do I select one to be shown in a CView window?
|
|
|
|
|
http://www.codeproject.com/useritems/MultiViewsMFC_MDI.asp
Hope this article will help you .
|
|
|
|
|
thanx. hopefully, it will help.
|
|
|
|
|
Hi there,
Create your first view as normal:
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CForm1));
AddDocTemplate(pDocTemplate);
Then, still in InitInstance, store an array (or obarray) to hold the other views...
CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView();
m_pViews[0] = pActiveView;
m_pViews[1] = (CView*) new CForm2;
m_pViews[2] = (CView*) new CForm3;
CDocument* pCurrentDoc = ((CFrameWnd*) m_pMainWnd)->GetActiveDocument();
CCreateContext newContext;
newContext.m_pNewViewClass = NULL;
newContext.m_pNewDocTemplate = NULL;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = NULL;
newContext.m_pCurrentDoc = pCurrentDoc;
UINT viewID[3];
viewID[1] = AFX_IDW_PANE_FIRST + 1;
viewID[2] = AFX_IDW_PANE_FIRST + 2;
CRect rect(0, 0, 0, 0);
for ( int nView=1; nView<NUMVIEWS; nView++ )
{
m_pViews[nView]->Create(NULL, NULL,
(AFX_WS_DEFAULT_VIEW & ~WS_VISIBLE),
rect, m_pMainWnd,
viewID[nView], &newContext);
}
((CForm2*)m_pViews[1])->OnInitialUpdate();
((CForm3*)m_pViews[2])->OnInitialUpdate();
Here's a function to help you switch dynamically between the views...
CView* CMyApp::SwitchView( UINT nIndex, BOOL bSaveData )
{
ASSERT( nIndex >=0 && nIndex < NUMVIEWS );
CView* pNewView = m_pViews[nIndex];
CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView();
if ( !pActiveView )
return NULL;
if ( pNewView == pActiveView )
return pActiveView;
if(bSaveData)
{
if (!SaveActiveViewsData() )
{
return pActiveView;
}
}
UINT temp = ::GetWindowLong(pActiveView->m_hWnd, GWL_ID);
::SetWindowLong(pActiveView->m_hWnd, GWL_ID,::GetWindowLong(pNewView->m_hWnd, GWL_ID));
::SetWindowLong(pNewView->m_hWnd, GWL_ID, temp);
pActiveView->ShowWindow(SW_HIDE);
((CFormView*)pNewView)->ResizeParentToFit(FALSE);
((CFrameWnd*) m_pMainWnd)->SetActiveView(pNewView);
pNewView->ShowWindow(SW_SHOW);
return pActiveView;
}
Any questions, I'll be happy to help.
Hope this helps,
Andy
|
|
|
|
|
Thanx for your help.
I'll try to implement this today and let you know how it works.
|
|
|
|
|
I just wanted to thank you again for your help. I applied the code you gave me in the application and it works. I had some problems with the SwitchView(), particulary this line
<br />
((CFormView*)pNewView)->ResizeParentToFit(FALSE);<br />
because it would produce strange windows sizes for the first 7-8 calls of SwitchView(), and then it would work fine.
So I put
<br />
((CFrameWnd*) m_pMainWnd)->RecalcLayout();<br />
instead. It works fine now.
And I'd like to ask you one more question. I have a button "quit" on one of CFormView's forms. What should I put in OnButtonQuit() message handler, so that the application exits after the button is pressed?
|
|
|
|
|
I gave the link for MDI
Think same thing will work for this also
|
|
|
|
|
Hello Coders,
I'm running my own Software Development Company located in India and I'm looking for a VC++/ATL/WTL programmer to do some of the extra work we have. the work will be mostly related to developing IE toolbars with Pop-up killers based on XML format and BHO (Browser Helper Objects) Development.
So, If anyone of you have required experience in these fields, skilled in VC++, ATL, WTL and XML and looking for extra money then you are most welcome to get in touch with me at ajay@chadhaajay.net
I'll pay you good if you will do excellent work. At start, I'll give you a simple project to do to check your skills and coding style. I've excellent knowledge of what I need and I can explain things pretty well to others.
So, Good Luck
Ajay Chadha (Director)
Chadha Software Technologies (INDIA)
|
|
|
|
|
I use a tab control to display several dialog, when I switch from one tab to another and click on button controls on that page, the mouse click has no response, In each of the nested dialog class, I have a pointer of the based dialog which the tab ctrl is built on, using the pointer to call tab switch function. Not all switches have this problem, only when I switch to a tab containing Directshow Video capturing/displaying tab. but after I use Alt+Tab switch to other running application and switch back, mouse works fine. Anybody knows how come?
|
|
|
|
|
Hi All
i have a Excel.csv file, and i need to import that into SQL server,
does ne1 know how to programatically DTS something ?? or can you
point me in the right direction
thanks
Si
|
|
|
|
|
Hi,
Could someone please help me, I need to make a plug-in for Outlook Express. I've heard that it may not support plug-ins, so even a way to add hooks could be very helpful.
Thanx,
robinfinity
|
|
|
|
|
Hi. Yes you wil have to use hooking try to read something about subclassing in msdn pages. Its a hard and time consuming job. Wish you luck.
Pain is a weakness living the body
|
|
|
|
|
Thank You ravjak!
|
|
|
|
|
This is the current code that is used before access to any data.
<big>bool CTestGUI1Dlg::WaitForMutex(void)<br />
{<br />
<br />
<br />
m_hMutex = ::CreateMutex( NULL,<br />
FALSE,<br />
"CSLSharedMemLock"<br />
);<br />
<br />
if(m_hMutex)<br />
{<br />
if (::WaitForSingleObject(m_hMutex,INFINITE) == WAIT_OBJECT_0)<br />
{<br />
ReleaseMutex(m_hMutex);<br />
return true;<br />
}<br />
}<br />
return false;<br />
}</big>
Note that currently I create it each time. If I dont then I never return.
If I now create the Mutex in the InitDialog() section of the program and modify the WaitForMutex as follows I get error = 6
<big><br />
bool CTestGUI1Dlg::WaitForMutex(void)<br />
{<br />
<br />
<br />
<br />
if(m_hMutex)<br />
{<br />
if (::WaitForSingleObject(m_hMutex,300) == WAIT_OBJECT_0)<br />
{<br />
ReleaseMutex(m_hMutex);<br />
return true;<br />
}<br />
}<br />
int error = GetLastError();<br />
return false;<br />
}</big>
|
|
|
|
|
Yeah that error indicates an invalid handle. Try creating (openning of already exist) the mutex in the constructor.
Kuphryn
|
|
|
|
|
I create the Mutex in the InitDialog() function, where do you suggest Create/Open the Mutex.
Also in the libray (DLL) is a native C library with no constructor.
One other thought, do I need Mutex to protect the shared memory as the EXE is single threaded and only one will ever exist.
grahamfff
|
|
|
|
|
I need to browse a folder only for rtf files, i'm not interested in other files like image,etc.How can i do this?and also i need to search for a specific folder, not file like My Documents,in order to get the path.SHGetFolderLocation( or something like this) doesn't work.How can i do this?Thanks a lot.
|
|
|
|
|
I need to browse a folder only for rtf files, i'm not interested in other files like image,etc.
>
static char BASED_CODE szFilter[] = "RTF Files (*.rtf)|*.rtf||";<br />
CFileDialog BrowseDlg(TRUE,NULL,NULL,OFN_FILEMUSTEXIST,szFilter,NULL); <br />
BrowseDlg.DoModal();
|
|
|
|
|
Add before DoModal something like this:
BrowseDlg.m_ofn.lpstrInitialDir = "c:\\windows"; // choice your path
|
|
|
|
|
I'm sorry.I have forgotten to say that i need this in SHBrowseForFolder.I need to browse only for rtf files.
|
|
|
|
|
Hi all, i dont get it, heres some "sample" code to explain my problem:
const int SOME_INT = 100; // notice the "const" at the start
int num=0;
switch(num)
{
case SOME_INT:
ATLTRACE("someint");
break;
default:
// whatever
};
gives me: error C2051: case expression not constant.
BUT:
#define SOME_INT 100; // using define instead
int num=0;
switch(num)
{
case SOME_INT:
ATLTRACE("someint");
break;
default:
// whatever
};
Gives me no trouble! WTF???? "case expression not constant"???? isnt SOME_INT clearly defined as constant in the first case??
|
|
|
|
|
shouldn't this be:
switch(num)
{
case SOME_INT:
ATLTRACE("someint");
break;
default:
};
Cheers,
Andy
|
|
|
|
|
Sorry, the ":" after case is a mistake i made while writting the post ( edited the post and corrected it now), but even without it, if you try to compile the code you wrote, and assuming you declared SOME_INT as
const int SOME_INT = 0;
it will give you the error, but if you declare it like:
#define SOME_INT 0
then it will work fine.
any idea why?
|
|
|
|