|
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?
|
|
|
|
|
AndyQ wrote:
still classed as a variable (albeit a const).
Contradictory statement.
A variable cannot be constant and neither can a contant be variable.
Bikram Singh
|
|
|
|
|
Are you using VC6? Because it compiles just fine in VC.NET2003 (once the default case is filled in).
According to the standards, it should work, so either your compiler is breaking the standards, or what you've posted isn't quite the same as what you've been trying to compile.
|
|
|
|
|
Curi0us_George wrote:
According to the standards, it should work
Yes it should, but with Microsoft, there's no more standard... they implement their compiler how they like...
TOXCCT >>> GEII power
|
|
|
|
|
Actually, I'm pretty sure that VC.NET2003 is as compliant with the standards as GCC.
|
|
|
|