|
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
|
|
|
|
|
Thanks for your reply, actually I want to read the content of .doc file. I do not know how to do that, if you have some idea about it please tell me how to do that?
I also searched on google but could not get much help, I just came to know that COleStreamFile class might be usefull but how to do that with this class I don't know?
|
|
|
|
|
I suppose you did not read the article I linked to in my previous post...
Well, let's try another one: http://support.microsoft.com/kb/178749/[^]
The article describes how to create a dialog based MFC application with a "run" button. When the button is clicked it starts Excel.
To make it start Word instead of Excel, you import the Word object library corresponding to your Word version instead of the Excel library. You will find the name of the Word object library in the table in the article. When you import the library a header file will be generated which you are supposed to include instead of "Excel8.h".
You also have to alter the ProgID from "Excel.Application" to "Word.Application".
Build and run the application.
When you click the "run" button, Word will start and you're up and running.
In order to open a document and read some of its contents, you will find appropriate interface methods to call in the generated header file(s).
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi,
I am trying to write a multiline character string to the registry (REG_MULTI_SZ).
for this i am doing this
LPTSTR Value = TEXT("0\02\0MANAGER\0");
after doing this if i look at the memory location where Value is stored this is what i see
30 00 02 00 00 00 4d 00 41 00 4e 00 41 00 47 00 45 00 52 00 00 00 00 00
check out the third byte, when it actually should be
30 00 00 00 02 00 00 00 4d 00 41 00 4e 00 41 00 47 00 45 00 52 00 00 00 00 00
there is some weird thing happening with the '\0' escape sequence and the '2' character.
or something's going on that im not aware of..
Please Help
Regards
~Sameer
|
|
|
|
|
Sameer Naik wrote: there is some weird thing happening with the '\0' escape sequence and the '2' character.
or something's going on that im not aware of..
\02 is a valid octal escape sequence for ASCII code 2 .
You should use replace \02 with \0002 or 0x002 to do the trick.
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]
|
|
|
|
|
Hi All,
I have created an .exe file using vc++ 2005 but when i copy this file to some other Vista machine its not working on way. How can I make my exe of project portable on any Vista machine? It's gaving some error on othere machine.
regards,
|
|
|
|
|