|
That's Perfect!!! then tell me how I can do this (in Vs2005) please.
Because...
I just created a test-project, I moved every .cpp and .h files in a different folder(d:\test\src), of course I delete the links to the old files in the project placing there the new links.
Then compiling I got some errors:
[Of course, you first need to 'clean' the contents of the debug folder, elseway obviously the error doesn't came]
Error 1 d:\test\src\stdafx.cpp 5 error C2859: d:\test\test\test\debug\vc80.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.
or (if you delete by hand every files in the debug folder):
Error 1 d:\test\src\stdafx.cpp 5 fatal error C1083: Cannot open precompiled header file: 'Debug\test.pch': No such file or directory
Please let me know
Russell
|
|
|
|
|
The first one - the pdb file - is easy. If clean doesn't
remove it, delete it by hand. That file probably has full
paths to source files so attached debuggers can magically find the
corresponding source code. It has to be regenerated for the
new source locations.
The PCH is a little trickier. After moving your source files
and re-adding them to the project in their new location:
1) From the solution explorer, right click on the project and choose
properties.
2) Navigate to the C/C++ Precompiled Headers section.
Typical setting should be
Use Precompiled Header (/Yu)
StdAfx.h
$(IntDir)\$(TargetName).pch
3) With the properties window still open, click on the
stdafx.cpp file in the solution explorer. The properties
window will change to show that individual file's settings.
Change the Create/Use Precompiled Header setting to create.
The settings should look like this.
Create Precompiled Header (/Yc)
StdAfx.h
$(IntDir)\$(TargetName).pch
That should be all you have to do.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
very helpfull,
I found also that StdAfx.h and StdAfx.cpp are the main problem when moving a project, maybe they can be copied, not moved, also because different with different compiler version.
thank you, now the problem is solved
Russell
|
|
|
|
|
Russell' wrote: I found also that StdAfx.h and StdAfx.cpp are the main problem when moving a project,
They're only a problem because if you use precompiled headers,
and those are the files that implement the precompiled headers,
then their compile settings need to be set properly.
Without the special PCH settings, they are just source files like
any others
You actually don't have to use those files - you are free to use precompiled
headers through any named source file, or not use precompiled headers at all.
It's the compiler settings that make the difference.
Russell' wrote: now the problem is solved
Cool!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have several projects shared between VC6 and VC8. The solution I use is after opening the solution in VS 2005, go to the properties of each project and change the "Output Directory" and "Intermediate Directory" to something like Debug8 (for debug builds obviously.)
This causes problems with .ncb files, but there's no reason to be actually editing both versions of the project at the same time. Despite the pain, I tend to edit in VC6 since that's what most the releases are in (we deploy to embedded devices which only have the VC6 runtimes.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thank you, that was my 'temporary' solution...I'm searching for something more 'clean', because place all the project files in the same folders is not good.
Elseway I'll continue to create VC6 projects and update they to Vc8, as before, as you suggest.
thanks
Russell
|
|
|
|
|
Hi to all.
I'm writing an app in which I wont to notify the user about optical media being inserted or removed from drive!
I did some research on web and found this WM. I included proper .h files but I cant get that message for handling it (I don't see it in my main dialog messages).
I founded article "Intercept the insertion/removal of a CD/DVD" by shaman74 (http://www.codeproject.com/KB/system/Message_Spy.aspx[^]). Is this is the only way (don't quite understand all this), no simple ON_WM...
Thanks in advance.
|
|
|
|
|
Read this[^] and this[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
You could also read the most AWESOME article on codeproject, but the most humble and extraordinary author EVER! (laying it on thick enough yet?)
http://www.codeproject.com/KB/system/Drive_Detect.aspx[^]
Just checked, and it does work detecting CDs going in / out, as well as usb drives being added in like origianlly intended.
Iain.
|
|
|
|
|
Hello all..
I'm trying to make window with specific requirement.. But that's not my issue. It's related to RegisterClassEx and CreateWindowEx.. Both actually fails.. I've no idea why.. I put GetLastError on both.
After RegisterClassEx it shows Error 6 which means "The handle is invalid."
After CreateWindowEx it shows Error 203 which means "The system could not find the environment option that was entered."
Here's code snippet.. Please take a look.
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd ;
MSG msg ;
WNDCLASSEX wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) CreateSolidBrush(RGB(255,255,255));
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = "WndProc";
DWORD eRR = GetLastError();
if (!RegisterClassEx (&wndclass))
{
MessageBox (NULL, "Registration Fails","Error", MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindowEx(WS_EX_TOOLWINDOW |WS_EX_LAYERED| WS_EX_APPWINDOW,
"WndProc",
NULL,
WS_POPUP,
10,
10,
100,
100,
NULL,
NULL,
hInstance,
NULL) ;
DWORD eRR1 = GetLastError();
ShowWindow (hwnd, iCmdShow) ;
SetLayeredWindowAttributes(hwnd, RGB(255,255,255), 255, LWA_COLORKEY|LWA_ALPHA);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
It also doesn't get into message loop..
Thanks..
|
|
|
|
|
Actually you're calling GetLastError before RegisterClassEx fails.
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]
|
|
|
|
|
Sorry.. My mistake...If i do something like this..
if (!RegisterClassEx (&wndclass))
{
DWORD eRR = GetLastError();
MessageBox (NULL, "Registration Fails","Error", MB_ICONERROR) ;
return 0 ;
}
i get Error 87.. which says "The parameter is incorrect".. I added
wndclass.cbSize = sizeof(WNDCLASSEX);
but no success...
And if i use WNDCLASS instead of WNDCLASSEX with RegisterClass it can skip registering the class and move to creating the window and then it gives error message 203....
|
|
|
|
|
If your not going to initialize all of the struct members you should initialize it to NULL.
WNDCLASSEX wndclass = {NULL};
Best Wishes,
-David Delaune
|
|
|
|
|
What value does wndclass.cbSize have? Are the unused members set to 0 ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Okay, first things first. The first call to GetLastError seems to be useless as it comes before the call to RegisterClassEx.
Next, the thing about RegisterClassEx compared to RegisterClass, is that you are expected to provide a valid handle for not only the standard icon, but also the small one.
You can do this like so:
wndclass.hIcon = wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
Finally, you've not set the cbSize member of wndclass. You can do that with the following:
wndclass.cbSize = sizeof (WNDCLASSEX);
As for the message loop - there's no window created, so no messages to process.
|
|
|
|
|
Thanks guys..
I added
ZeroMemory(&wndclass,sizeof(WNDCLASSEX));
And it register the class.. But no luck in CreateWindowEx.. It still returning NULL with Error message 203..
|
|
|
|
|
Here, try this:
#define _WIN32_WINNT 0x0601
#include <windows.h>
LRESULT CALLBACK WndProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd ;
MSG msg ;
WNDCLASSEX wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbSize = sizeof (WNDCLASSEX);
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIconSm = wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) CreateSolidBrush(RGB(255,255,255));
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = "myWndClassName";
if (!RegisterClassEx (&wndclass))
{
DWORD eRR = GetLastError();
MessageBox (NULL, "Registration Fails","Error", MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindowEx(
WS_EX_TOOLWINDOW | WS_EX_APPWINDOW,
"myWndClassName",
0,
WS_POPUP,
10,
10,
100,
100,
HWND_DESKTOP,
NULL,
hInstance,
NULL) ;
if (hwnd == NULL)
{
DWORD eRR = GetLastError();
MessageBox (NULL, "Window Creation Fails","Error", MB_ICONERROR) ;
return 0 ;
}
DWORD eRR1 = GetLastError();
ShowWindow (hwnd, iCmdShow) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
|
|
|
|
|
I tried the code.. But no success again.. Pops up the message box saying that "Window creation fails"..
Debugged that.. Still there is NULL in hwnd..
|
|
|
|
|
|
Yes it solved..
Thanks all..
|
|
|
|
|
I am getting problem in
IStorage *Storage;
CLSID clsidWord;
CoInitialize(NULL);
HRESULT hr=CoCreateInstance(clsidWord,NULL,CLSCTX_INPROC_SERVER,IID_IStorage,(void**) &Storage);
This is giving class not registred.
|
|
|
|
|
MPTP wrote: clsidWord
clsidWord parameter must be meaningfully initialized.
BTW you should post such questions in the COM forum [^] to get better help.
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]
|
|
|
|
|
You cannot create Microsoft Word as an in-process-server since it registers as an out-of-process server.
Change CLSCTX_INPROC_SERVER to CLSCTX_SERVER .
And, of course as CPallini mentioned, the class ID of Word must be initialized correctly.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
thank you, could you please give me nay link related to this Interface
|
|
|
|
|
MPTP wrote: could you please give me nay link related to this Interface
I don't know what interface you're talking about, but I saw you're requesting the IStorage interface upon creation of the server which seems strange and is most likely very wrong.
Have a look at this KB article here[^]. It shows how to get started with automating Word.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|