|
No, that doesn't help - I'm still not receiving any messages, even when I take away the icon and tip. Thanks for the advice, though... it's unusual how code that's so similar isn't working. I'm updating my Platform SDK, so maybe that will help... I wish I had something better than dialup
|
|
|
|
|
... yes it is odd.. are you using Visual Studio?
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
The only thing I see missing is
request.uID = IDI_ICONSCREEN_SMALL; //instead of 0
Also make sure you're looking for MSG_STATUSICON in your message loop, and when you process that
message, the MSG.lParam is what you should switch() on (as shown in your code). You may already
be doing that, but you didn't show it in your code above.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
jamestheprogrammer wrote: #define MSG_STATUSICON (WM_USER + 101)
My first suggestion is to change this to WM_APP instead of WM_USER. WM_USER is used internally by various Win32 controls and I'm seen some weird bugs when those controls are used on the same window as one that processes your own WM_USER message. This probably isn't your problem, but I hate seeing WM_USER used when WM_APP exists and is guaranteed to be unique in your app.
Looking in some code of mine where I have a service displaying a tray icon, I also set the version number in the notify request structure
Here's my entire "create the tray icon" routine that is called from within my interactive service.
if (CreateEx (0, AfxRegisterWndClass (0), "", WS_POPUP, 0, 0, 10, 10, NULL, 0) == 0)
{
return false;
}
m_notifyIconData.cbSize = sizeof (NOTIFYICONDATA);
m_notifyIconData.hWnd = m_hWnd;
m_notifyIconData.uID = 1;
m_notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
m_notifyIconData.uCallbackMessage = WM_APP;
m_notifyIconData.hIcon = ::LoadIcon (AfxGetResourceHandle (),
MAKEINTRESOURCE (IDI_ICONTRAY));
m_notifyIconData.uVersion = NOTIFYICON_VERSION;
strcpy_s (m_notifyIconData.szTip, 64, "xxx Service");
if (Shell_NotifyIcon (NIM_ADD, &m_notifyIconData) == FALSE)
{
return false;
}
m_notifyIconData is a variable of type NOTIFYICONDATA that I keep around so that the service can destroy the icon later if it wants. m_hWnd is the handle created by the CreateEx call.
Hope this helps
Judy
|
|
|
|
|
Yeah, I'm thinking that the problem has something to do with the uVersion variable... I'm actually stuck with VC6 for the time being, and the Platform SDK I have is so old that the uVersion variable doesn't even exist. I'm downloading the February 2003 Platform SDK, so hopefully that will help.
Thanks.
|
|
|
|
|
jamestheprogrammer wrote: I'm thinking that the problem has something to do with the uVersion variable
That's only used when sending a NIM_SETVERSION (via Shell_NotifyIcon), not for NIM_ADD.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
You're not receiving any messages from the icon, right?
In your code you show
/* in the callback for HiddenWindow */
...
What is the callback? You should be looking for the MSG_STATUSICON message in the windowproc for
the HWND passed to Shell_NotifyIcon().
LRESULT CALLBACK MyWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (MSG_STATUSICON == uMsg)
{
UINT IconID = (UINT)wParam;
switch((UINT)lParam)
{
case WM_RBUTTONUP:
...
case WM_CONTEXTMENU:
...
case WM_LBUTTONDBLCLK:
...
case WM_LBUTTONDOWN:
...
case WM_RBUTTONDOWN:
...
default:
...
}
}
...
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Yeah, I think so (unless there's something I'm missing). I've created a Window class called SMStatusHelper, with lpfnWndProc set to the callback in the code I first posted.
<br />
<br />
WNDCLASSEX wndClass;<br />
wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.style = CS_DBLCLKS; <br />
wndClass.lpfnWndProc = WndProc; <br />
wndClass.cbClsExtra = 0; <br />
wndClass.cbWndExtra = 0; <br />
wndClass.hInstance = hInstance; <br />
wndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICONSCREEN));<br />
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wndClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);<br />
wndClass.lpszMenuName = NULL;<br />
wndClass.lpszClassName = "SMStatusHelper";<br />
wndClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICONSCREEN_SMALL));<br />
RegisterClassEx(&wndClass);<br /> Then I create a new window using the SMStatusHelper class, WS_EX_TOOLWINDOW extended style, and WS_POPUP|WS_VISIBLE for the regular style, using the CreateWindowEx method. I take the return value of that and set it to a global variable called HiddenWindow, which is the hWnd value of the NOTIFYICONDATA structure I pass to Shell_NotifyIcon. So I'm pretty sure that's the right callback...
Thanks.
|
|
|
|
|
Sounds good.
I'm just wondering about the "callback" you mentioned since you didn't post complete code.
You showed case statements but not the switch() and the switch argument
Now that I see your window class, the MyWindowProc (or whatever I called it) example in the code
I posted (last post) would go in your "WndProc".
Are you checking for the notification message in a similar way?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Ha! I figured out what was wrong!
Figures... it had nothing to do with the icon at all. See, I'm new to Windows programming, and I'm still used to writing daemons and such for Linux... I messed up my main loop, so there were all sorts of weird problems there.
Thanks for all the help!
|
|
|
|
|
Task Manager
Check the debug window within the IDE
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Could you elaborate more. There have been some third party tools developed around for the same. What is the thind line between memory leaks and resource (Process objects and GDI objects) leaks. I know bouncechecker and RationalPurify could provide some way by which these leaks could be determined.
|
|
|
|
|
See Mem Usage of your program on the TaskManager and PF Usage of TaskManager when you work on the GDI+ if your code is correct then it doesnt any problem if you have a leaky on your code these elements will be increase.
|
|
|
|
|
Hi Guys
i using DeviceIoControl to block a external hard drive by using flowing code
m_hDevHndl = CreateFile(szUc,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(m_hDevHndl != NULL)
{
if(DeviceIoControl DevHndl,FSCTL_LOCK_VOLUME,NULL,0,NULL,0,&junk,NULL))
But DeviceIoControl is failing
with regards
Ryk
|
|
|
|
|
First, CreateFile(...) is supposed to return INVALID_HANDLE_VALUE when things go wrong, not NULL , so you need to correct that to ensure that the device is really being opened.
Second, you should be checking the error code returned from GetLastError() whenever a function fails, so you can try to determine exactly what went wrong.
Correct those two mistakes and then see what is really going on.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi
I'm trying to add a picture in my excel automation code.All i need to do is ,say i have an image whose path is stored in a variable ,say strFileName, then i have to display this image in an excel sheet through my code.I tried doing something like this:
Pictures pict;
pict.Insert("c:\\tree.gif", covOptional);
pict.Select(covTrue);
pict.CopyPicture((long)1,(long)-4147);
range=sheet.GetRange(COleVariant("A1"),COleVariant("A1"));
range.Select();
sheet.Paste(covOptional,covFalse);
But,on running the application this would only display the above text in the column beginning from A1 upto A7. I dunno what to do.I looked at the the following website :
http://www.codeproject.com/com/ComExcelImages.asp
But this code was too complicated and i don't really need this level of complexity in my code.
Can someone help me??
Thanks a lot,
Priyanka
|
|
|
|
|
Hi,
I am using Visual Studio 2005 and I have made a MFC application(Use MFC in a Shared DLL) and test it on same machine then it works fine but when i test that on other machine i get the error "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.", but when i change the configuration of application (Use MFC in a Static Library), then it works fine. I thought that might be the problem that MFC Redistributable are not installed, but I have tested that on machine where visual studio 2005 is installed and i am getting the same error, does any one know about it.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
|
|
|
|
|
I think you answer your question already You are going to have to install the missing mfc dlls that are required for your app to run!
Do a search on the MS site for MFC redistributable and then download them and get them installed on the other pc and see if that doesn't fix your problem!
There might be a few dlls missing, one way for you to find out what dlls are loaded by your app is to use the dump bin utility, or you can go to the sysinternals site and download their cool tools and either use the 'ListDLLs' utility or "Process Explorer" when your mfc app is running in your development environment.
|
|
|
|
|
Thanks for the reply.
I have checked that MFC's binary with Dependency Walker, it doesn't show any of the dependency error, the only error it shows the same which i have mentioned "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.", I have tested my application on multiple machines where VS2005 is installed, but still i see the same error.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
|
|
|
|
|
Mushq wrote: I have tested my application on multiple machines where VS2005 is installed, but still i see the same error.
But if you go one step further and build the app on those machines, do you still get the error?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: go one step further and build the app on those machines
Thanks a lot!
I build the app on one more machine, there it worked fine and as well as on another remote machine, so i think there is some problem in visual studio settings of my machine.Now i have got my app in a working form.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
|
|
|
|
|
|
Seeing that you are not getting errors about missing DLLs or missing ordinals, and the fact that the word "configuration" is mentioned, my first guess would be something up with your manifest (<appname>.exe.manifest file, or embededd into the resources), if any.
Have you looked into the Event Viewer to see if any more detail is available (it might be a DLL problem, after all)? SxS (Side By Side) problems can raise that message as well (which leads me back to the manifest ).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I was just about to add that possibly it has something to do with no menifest file / information, or something along that line
Would be nice if our friend could report back on this as I am curious as to what his problem really is? If he can go back to the offending PC, build the app with the manifest imbedded and run it on the other PCs to see if things are working fine this time.
|
|
|
|
|
Are you trying to run a Debug Build version on the Other Machine?
Debug Versions will only run on which have a suitable Compiler installed. The Debug Version tries to link to various DEBUG Dll's which are installed on your machine as part of you installing MSVC2005. Off the shelf XP Machines would not have these DLL's, hence a Problem!
LateNightsInNewry
|
|
|
|