|
Well, for starters the parameter is a pointer to the callback function, so you might try &SaveCallback.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Hello,
In my app, I've got a function that performes a calculation on a string entered by the user in an editbox. If the text formatting (encrypted data) isnt correct the function fails with an unhandled exception error.
I've tried try{} and catch{}, but they don't seem to "Catch" the error. How can I trap the error (or any exception for that matter) so that I can handle this error gracefully.
Is there any way to find out exactly what type of CException (CFileException, etc) is being thrown?
Thanks,
Frank
|
|
|
|
|
It sounds to me either one of two things:
1. You haven't put your code in a try block:
try
{
}
catch (CMyException &e)
{
}
2. You're catching a different type than you threw. The best thing to do is to throw by value, catch by reference, as show below:
void MyFunc()
{
throw CMyException();
}
void main()
{
try
{
MyFunc();
}
catch (CMyExcetpion &e)
{
cout << "Error!";
}
}
Alternatively, you could use catch (...) which catches all exceptions.
> Andrew.
|
|
|
|
|
Thanks Andrew...
I'll give catch(...) a try.
Frank
|
|
|
|
|
I have a big project that has 5 ATL simple object. The first one is called as Header. This Header module will contain a collection of other objects. But cannot create these objects in the same application(though I can create them in another VB application). Can you help me?
Thanks a lot,
Cem
|
|
|
|
|
I have an MDI application using CView. I have a dialog that is setup as a CFormView. How can i show the CFormView as a child on command?
-Matt Newman
|
|
|
|
|
Why can't you just set it up as a dialog box ?
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
>Why can't you just set it up as a dialog box ?
Because this way the user can make it lose focus while the are working but don't have to close it.
-Matt Newman
|
|
|
|
|
Hi,
I use CPropertyPageEx to create Wizard, is there a way
to remove the close button on the upper right corner? thanks.
p.c.
|
|
|
|
|
Handle OnInitDialog in your CPropertySheetEx class.
This is how I've removed the maximize button (Or disabled it)...I believe you can do the same thing with the close button.
CMenu *pSysMenu = GetSystemMenu(FALSE);
ASSERT(pSysMenu != NULL);
VERIFY(pSysMenu->RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND));
Cheers,
Frank
Gumbercules? I love that guy!
Dr. Zoidberg
|
|
|
|
|
I've seen a few examples to avoid multiple instances of an application. In fact, there are a few of them here on code project. However, they all seem like a lot of code, when there is an easy solution like:
HANDLE hMutex = CreateMutex( NULL, TRUE, "MVD Load Utility" );
if( (hMutex == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS) )
{
AfxMessageBox( "Two copies of this program are not allowed to run at the same time." );
return FALSE;
}
Is there something wrong with this, I don't see why methods like this are necessary.
|
|
|
|
|
There is nothing wrong with that method and in fact, that is the most simple way possible.
|
|
|
|
|
Mr Newcomer's article does this. He tries to create a mutex, and if it already exists, an instance of the program is already running. He just added a feature where the instance that is running is brought to the top and made the active window, saving the user from having to look for it.
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
Infact you can replace the mutex name with a GUID.
Cheers
Kannan
|
|
|
|
|
Has anyone had any luck with this function? I'm trying to make a video by taking the video stream from an existing AVI, which works fine, and calling AVIMakeFileFromStreams using just that stream. The file is created by AVIFileOpen, except i can't play the file in my viewer or in Media Player, since it didn't make it correctly from the stream.
Any help is greatly appreciated, I didn't find any sample code online.
thanks,
Jake
|
|
|
|
|
I've been working on a small multi-threaded app for a while, and I've ironed out all of the bugs except for one. I'm not very proficient with threading in general, so for all I know, this could be a simple problem.
The app actually consists of two worker threads and the main GUI thread, but the problem lies within the GUI thread. As a quick note, the worker threads do not touch the GUI thread, so I know that's not what is causing the trouble. I have a simple Browse button that brings up a CFileDialog to allow the user to pick an input file, which works as it is supposed to. There are several other fields of data that the user must enter (basically data that is relevant to the file and how it will be processed). After entering the data, the user then pushes another button that will add this info to a CListCtrl and an internal list that is used for processing the file(s) later.
I also have an 'Options' button that brings up another dialog where the user sets various program parameters. Here is where the problem arises:
If the user clicks the 'Options' button before they save information to the list of files to be processed, the dialog comes up without any problems. So long as no information has been added to the CListCtrl, the 'Options' dialog works like it supposed to. As soon as any info is added to the CListCtrl, however, the program will lock upon the user clicking the 'Options' button.
I know from tracing through the code that the program locks upon the call
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate, pParentWnd->GetSafeHwnd(), AfxDlgProc);
The above statement is part of DLGCORE.CPP, and is called upon trying to open the 'Options' dialog. Could someone please enlighten me as to what I am doing wrong? Any ideas would be appreciated.
--Dean
|
|
|
|
|
Try Debug|Break when application hangs. You should be able to have a look at the other threads' stacks - this information may be helpful.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
The other threads have nothing to do with the GUI though. In fact, when the app hangs, the other (worker threads) haven't even been started.
--Dean
|
|
|
|
|
But what's on the stack when you Debug|Break? A call to ::CreateDialogIndirect or something else?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Funny -- this has been a bug for a very long time now, and now that I'm trying to reproduce it so I can see what's on the stack, everything works perfectly. You gotta love it...
|
|
|
|
|
Hi
I want to create an SDI-app with two splitter-windows.
It should look like this:
|--------------------|
| |
| |
| C(Rich)EditView |
| |
| |
|--------------------|
| CView |
|--------------------|
How can I realize it?`I already wrote some code, but unfortunately the MainFrame looks very weird and has some GUI-bugs. If someone could help me improve this code:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect cr;
GetClientRect( &cr );
if ( !m_mainSplitter.CreateStatic( this, 2, 1 ) )
{
MessageBox( "Fehler beim Erstellen der einzelnen Fenster!", "Fehler beim Initialisieren!",MB_OK | MB_ICONERROR );
return FALSE;
}
if ( !m_mainSplitter.CreateView( 0, 0, RUNTIME_CLASS(CMyAppView),CSize( cr.Width(), cr.Height()), pContext ) )
{
MessageBox( "Fehler beim Erstellen der einzelnen Fenster!", "Fehler beim Initialisieren!",MB_OK | MB_ICONERROR );
return FALSE;
}
if ( !m_mainSplitter.CreateView( 1, 0, RUNTIME_CLASS(CDebugView),CSize( cr.Width(), cr.Height()), pContext ) )
{
MessageBox( "Fehler beim Erstellen der einzelnen Fenster!", "Fehler beim Initialisieren!",MB_OK | MB_ICONERROR );
return FALSE;
}
m_initSplitters = TRUE;
return CFrameWnd::OnCreateClient(lpcs, pContext);
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
CRect cr;
if ( m_initSplitters && nType != SIZE_MINIMIZED )
{
m_mainSplitter.GetClientRect( &cr );
m_mainSplitter.SetRowInfo( 0, cy / 2, 0 );
m_mainSplitter.SetRowInfo( 1, cy / 2, 0 );
m_mainSplitter.SetColumnInfo( 0, cy, 0 );
m_mainSplitter.RecalcLayout();
}
}
thanks in advance
|
|
|
|
|
I already wrote some code, but unfortunately the MainFrame looks very weird and has some GUI-bugs
What are these GUI-bugs?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
You shouldn't call CFrameWnd::OnCreateClient in CMainFrame::OnCreateClient. Just return TRUE. CFrameWnd::OnCreateClient creates additional view using pContext. Your application has 3 (not 2) views and this is where problems begin.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have a list box that I am using to display a status log. When the visible list box fills up, I would like the list box to scroll down with each new entry. How can I accomplish this?
- John
|
|
|
|
|
I use this
CListBox::SetTopIndex()
Cheers!!!!
Carlos Antollini.
|
|
|
|