|
Thanks Mark. I understand using the rename to eliminate the warning, but won't that cause other problems. If the writer of the typelib used 'identifier', isn't it reasonable to assume that elsewhere in the code there will be references to this 'identifier' type and these will now compile to the incorrect 'identifer' type as I've aliased away the intended one with the rename?
Also I'm probably missing something, but why doesn't the producer of the type library recognize that a macro and an identifier share a common name and change one to avoid the warning.
Chris Meech
I am Canadian. [heard in a local bar]
I agree with you that my argument is useless. [Red Stateler]
Hey, I am part of a special bread, we are called smart people [Captain See Sharp]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
What Mr Hewitt said
Depending on the office version, there's others like PlaySound and RGB
|
|
|
|
|
From <winbase.h> which is included by <windows.h> :
#ifdef UNICODE
#define CopyFile CopyFileW
#else
#define CopyFile CopyFileA
#endif // !UNICODE
This is the macro the warning is referring to. This is all part of the evils of macros: because macros don't obey C++ scoping rules namespaces and such can't be used to have multiple but non-conflicting duplicate names. I don't think this warning will cause you any problems however. To rename the method (although you don't really need to) you do something like this:
#import "C:\\Program Files\\Microsoft Office\\OFFICE11\\MSOUTL.OLB" no_namespace rename("CopyFile", "OfficeCopyFile")
Steve
|
|
|
|
|
Great explanation, Stephen. Clears things up perfectly for me.
Chris Meech
I am Canadian. [heard in a local bar]
I agree with you that my argument is useless. [Red Stateler]
Hey, I am part of a special bread, we are called smart people [Captain See Sharp]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
There's a flag to #import called (I think) exclude that will prevent certain symbols from being included in the generated tli/tlh files. Try that if you don't need the CopyFile method in the typelib.
|
|
|
|
|
I am managing some medium sized projects in C++ 6. Are there some good reasons to migrate to Visual C++ 2005? The only ones I can think of are:
1. Potentials to utilize 64bit technology. I guess c++ 6 compiler will not support 64 bit.
2. Potentials to write .NET modules to the project. However, it could be complicated to have managed code and unmanaged code mix together.
3. Better IDE.
Anyone already done the migration? Please share your precious experience with me.
Thanks!
|
|
|
|
|
VC6 is rubbish, in terms of STL and standards conformance. That's why I would move.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
|
Just be careful of the potential headaches caused by VS2005's manifest generation. Apps built by VS2005 require the presence of an embedded or external manifest when run on XP and Vista. I've suffered (and continue to suffer) no end of pain trying to get my app to run on other people's XP boxes, thanks to VS2005's inconsistent generation of manifests.
I've had no such problem with VC6 built versions of the same app.
/ravi
|
|
|
|
|
There's no simple answer. If VC6 is meeting your current needs, why switch? I for one don't think the VC8 IDE is better.
|
|
|
|
|
If you're writing VC++ code, VS2005 makes your life harder because the new IDE is built around .Net development.
For VC++ programmers, the ONLY real reason to switch is to get the newest version of MFC, but be prepared for a bit of work to get your code to compile clean. A lot of MFC functionality has changed (be especially aware of COleDateTime changes). Also, if you do move to VS2005, make sure you also download and install the service pack that was released in December.
We had an app that was over 670,000 lines of code spread across 24 sub-projects. The initial compile resulted in over 2000 errors, and over 4000 warnings. It only took about two hours re-factor the code code because a lot of the warnings/errors were just duplicates of prior entries.
Lastly, despite what Christian said, VC6 is most certainly NOT rubbish. If you're in the middle of development on a project using VC6, I'd stick with VC6 for that version and move to VS2005 for the next major revision.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks for all the input. It's very helpful.
When do you think that Visual C++ 6 will be out-of-date? i.e, Microsoft may decide one day to stop supporting it and it may have trouble with compatability with the next version of windows.
|
|
|
|
|
I am using Visual C++ 6.0 with MFC. I have an application that spawns a user interface thread that is a 'CProgress' dialog box with a progress control and a 'Cancel Thread' button. There are a couple of things happening depending where I put the declaration of the CProgress.
BOOL UIThread::InitInstance()
{
m_pMainWnd = new CProgress;
m_pMainWnd->SetForegroundWindow();
m_pMainWnd->CenterWindow(NULL);
m_pMainWnd->ShowWindow(SW_SHOW);
CoInitialize();
return TRUE;
}
int UIThread::Run()
{
CMyDialog dlgMyDialog;
dlgMyDialog.DoModal();
return CWinThread::Run();
}
If the CProgress dialog box is declared in InitInstance() as shown above the call to dlgMyDialog.DoModal() doesn't cause any problems but the CProgress dialog box is displayed without any of the buttons or controls and it does not have focus. I can fix this problem by putting the declaration of CProgress into the UIThread constructor but then the call to dlgMyDialog.DoModal() crashes the app (specifically at file wincore.cpp line 895). Now if I keep the declaration of CProgress in InitInstance() to keep the app from crashing, the CProgress dialog box is not fully drawn until CWinThread::Run() is executed. Can anyone help me with the commands needed to make the CProgress dialog box fully functional so I can cancel the thread with the click of a button?
Thanks
Buck
|
|
|
|
|
It doesn't look like your UIThread thread processes any messages so that won't work.
I think it would be much much easier to use a modeless dialog.
|
|
|
|
|
The point is that the class wizard creates the code when adding a class with a base class of CWinThread() and that the code the thread executes should be in the UIThread::Run() function. If my thread execution is not performed by Run() then where do I put my thread code? This really shouldn't be this difficult. All I want is to click a button to start the test and click another button to abort the test.
|
|
|
|
|
Right. Kind of a catch-22 deal - you can't create a window without running the threads message
loop and you can't run the message loop before creating the window
If you insist on a separate thread for just the modal dialog then start the UI thread - run it,
and post a thread message to it. Respond to the thread message and then call DoModal() on the
dialog.
That's still way more complicated than it needs to be.
|
|
|
|
|
Very much a catch 22. Let me say that I am NOT a Windows programmer. How would you set it up? My tab page has a button that invokes OnButtonBeginTest() that executes the test code (that could take an hour). While the test is running I can't click on any other buttons on my tab page. If I could then I would add an abort test button to the tab page.
|
|
|
|
|
BuckBrown wrote: Let me say that I am NOT a Windows programmer
Too late - you're a windows programmer.
I prefer 1 UI thread (the CWinApp one in MFC).
So, I would
1) respond to the button click
2) create/show a modeless progress dialog
3) disable the main window if appropriate or at least the button so the user can't click it again
4) start a worker thread which executes the test code
4a)The worker thread could periodically post messages to the modeless dialog to indicate progress
(if that info is available) - this could be done via class method as well but then you may have
to handle thread synchronization.
5) If the user clicks cancel (if provided in the modeless dialog) then somehow inform the thread
to terminate - using a flag variable or event object.
6) If the test thread ends normally then it could post a message to the main window or the dialog
(whichever is appropriate) indicating completion.
7) on receipt of the completion message, destroy/cleanup the thread object, the modeless dialog,
and reanable any disabled windows from step 3
Something like that.
Mark
|
|
|
|
|
Thanks, I'll try this approach tomorrow. Something's gotta give. I've been trying to do this since Monday morning - 32 hours to not yet do what an experienced Windows guy could do in 32 minutes!
|
|
|
|
|
Also, the following code (where I was spawing the UI thread) greys out the area on my tab page where the modeless dialog should appear but the modeless box does not appear until the AfxMessageBox() command.
pInProgress->Create(IDD_DIALOG_PROGRESS, this);
pInProgress->CenterWindow();
pInProgress->SetForegroundWindow();
pInProgress->UpdateData(TRUE);
pInProgress->UpdateWindow();
pInProgress->ShowWindow(SW_SHOW);
Sleep(5000);
AfxMessageBox("Wait");
// theApp.m_pThread = AfxBeginThread(RUNTIME_CLASS(UIThread), 0, THREAD_PRIORITY_NORMAL);
Isn't there a way to flush the messages? Or at least FORCE this window to display?
Everthing I do in Windows needs some information that I dont have access to!
|
|
|
|
|
The messages won't flush until the thread flushing the messages runs
The Sleep() is preventing that.
|
|
|
|
|
What happens if you move the "pInProgress->UpdateWindow();" below the ShowWindow() call?
|
|
|
|
|
|
If you can break up the work done in the spawned thread into separate subtasks, you could use this[^] progress dialog class.
/ravi
|
|
|
|