|
Here is an example about adding icon to the system tary:
<br />
#define WM_MY_NOTIFYICON WM_USER+100<br />
<br />
BOOL CMainFrame::TrayMessage(DWORD dwMessage, UINT uID, HICON hIcon, PSTR pszTip)<br />
{<br />
BOOL res;<br />
<br />
NOTIFYICONDATA tnd;<br />
<br />
tnd.cbSize = sizeof(NOTIFYICONDATA);<br />
tnd.hWnd = m_hWnd;<br />
tnd.uID = uID;<br />
<br />
tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;<br />
tnd.uCallbackMessage = WM_MY_NOTIFYICON;<br />
tnd.hIcon = hIcon;<br />
if (pszTip)<br />
{<br />
lstrcpyn(tnd.szTip, pszTip, sizeof(tnd.szTip));<br />
}<br />
else<br />
{<br />
tnd.szTip[0] = '\0';<br />
}<br />
<br />
res = Shell_NotifyIcon(dwMessage, &tnd);<br />
<br />
if (hIcon)<br />
DestroyIcon(hIcon);<br />
<br />
return res;<br />
}<br />
<br />
void CMainFrame::NotifyDelete()<br />
{<br />
HICON hIcon;<br />
CWinApp *theApp=::AfxGetApp();<br />
hIcon=theApp->LoadIcon(IDR_MAINFRAME);<br />
TrayMessage(NIM_DELETE, IDR_MAINFRAME, hIcon, "WinScheduler");<br />
}<br />
<br />
void CMainFrame::NotifyAdd()<br />
{<br />
HICON hIcon;<br />
CWinApp *theApp=::AfxGetApp();<br />
hIcon=theApp->LoadIcon(IDR_MAINFRAME);<br />
TrayMessage(NIM_ADD, IDR_MAINFRAME, hIcon, "WinScheduler");<br />
}<br />
<br />
long CMainFrame::OnTrayIconNotify(WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (lParam)<br />
{<br />
case WM_LBUTTONDOWN:<br />
{<br />
CWinApp *theApp=::AfxGetApp();<br />
CWnd *mainWnd=theApp->m_pMainWnd;<br />
if(mainWnd->IsIconic())<br />
{<br />
mainWnd->ShowWindow(SW_RESTORE);<br />
}<br />
mainWnd->SetForegroundWindow();<br />
}<br />
break;<br />
case WM_RBUTTONDOWN:<br />
break;<br />
}<br />
return 0;<br />
}<br />
Then add
ON_MESSAGE(WM_MY_NOTIFYICON, OnTrayIconNotify)
between
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) and
END_MESSAGE_MAP()
This adds an icon to the system tray and when you click on it it activates the window.
There is an article about removing your program's from taskbar in this site.
Best Regards.
Mustafa Demirhan
|
|
|
|
|
Sorry, I forgot the followings:
you have to add the following code to OnCreateClient (or add to another initialization code)
<br />
NotifyAdd();<br />
Then you have to call NotifyDelete(); in OnClose method.
Mustafa Demirhan
|
|
|
|
|
Just use WS_EX_TOOLWINDOW to eliminate the window from the taskbar.
See: http://msdn.microsoft.com/library/psdk/shellcc/shell/shell_int/taskbar.htm
|
|
|
|
|
(1) How can I play waw files with MFC?
(2) How can I play waw files with API?
|
|
|
|
|
You may try these API functions:
BOOL sndPlaySound(
LPCSTR lpszSound,
UINT fuSound
);
BOOL PlaySound(
LPCSTR pszSound,
HMODULE hmod,
DWORD fdwSound
);
The same for MFC applications
Cheers,
Paolo.
|
|
|
|
|
This is on NT 4.0, SP6 using dev studio 6.0, sp4
I've just upgraded to these to try to fix the problem I'm
about to describe. The code I'm describing used to work, then one day I noticed it no longer worked, and I hadn't touched the code! I think a service pack or something broke
the code. I've seen this once before and the only fix that
worked was to reinstall the OS and all the tools. I don't want to do that .
The code is some code that given an address uses the SymGetLineFromAddr() function in imagehlp.dll to get the
line number. I'm using the fix that John Robbins provided that accounts for the address not matching a line's exact
address. This used to work, but now I get no file or line
number information.
Anyone come across this and worked out how to fix it?
Cheers
Stephen (2 questions in 1 day...)
|
|
|
|
|
The problem is probably that the ImageHlp.dll was replaced by a service pack.
So the SymGetLineFromAddr() function is no longer present in your current NT4 version. (It's only available in the W2K aka NT5 version)
Since ImageHlp.dll is a redistributable you can replace it again with the most recent (W2K) version you can find.
Make sure your debug symbol files are A-OK.
If that does not help, re-read some of John Robbins' articles...
GBO.
|
|
|
|
|
Thanks,
But that isn't the problem. The functions are present and I am calling them, they just fail to return any valid info,
even thought the pdb files are valid.
I reinstalled the OS - which nicely trashed my partition table even though it shouldn't have, good job I had backups.
Stephen
|
|
|
|
|
Sorry my comments didn't help.
Can you use windbg on your system to read the Drwtsn32 "core" Dump files? This might give you a clue.
(you got to make DrWtsn32 your default debugger and let it generate core files but I am sure you already read how to do this in John Robbin's articles...)
You might want to change the debug info generation to "C7" compatible which is sufficient to read the line numbers and a get a function name context.
Then again if you reinstalled the OS, everything might be running OK now.
Good luck.
|
|
|
|
|
Has anyone had problems installing the latest platform SDK (August 2000 on CD 3)?
I can't get the installer to install. I've tried the advice in the readme, latest service packs everything. Fails
with error code 1603.
Thus I can't get the platform SDK to install.
This is on:-
Win NT 4.0, SP 6,
DevStudio 6, sp 4.
Stephen Kellett
snail@objmedia.demon.co.uk
|
|
|
|
|
I don't have an solid answer for you, but FYI:
Error code 1603 means:
The file [2][3] is being held in use{ by the following process: Name: [4], Id: [5], Window Title: '[6]'}.
|
|
|
|
|
When I use TransparentBlt , I get a 1st chance exception, althoght the image appears as I had hoped, eventually, the function fails and the image doesn't appear . Any Ideas, I'm pulling my hair out on this one.
Does it in Win2000 and 98
|
|
|
|
|
How do I set the resolution of a dialog to a specific setting, for example 640x480. Also, when this is done do all coinciding dialogs have this resolution or do they all have to be set to 640x480 in the same manner?
|
|
|
|
|
I cannot understand what you said.
However, you cannot change the resolution of a window. You change the resolution of all windows.
Mustafa Demirhan
|
|
|
|
|
I'm posting html from a form to an ISAPI extension. (The form content is html that I put together later to build pages.) When I post just a few lines it is handled correctly and it is inserted into the database. If I send more than a few lines, I get a "page page cannot be displayed" error specifying a dns error. I've even gone as far as replacing all the tags prior to the post and it still fails. The post works with large posts however if the content is html it dies.
Any ideas??
|
|
|
|
|
Hi Ed,
I'm sure there are others here with more hands-on ISAPI experience than I have, but I'll throw in my $.02.
I seem to remember that the automatic parsing routines supplied by MFC have a problem with very long request URLs, as would be generated by a long form post. I believe the solution is to get the raw post data and to parse it manually.
|
|
|
|
|
I have a unique problem that is only showing up when I run Chris's grid control under windows 2000 on a HP Vectra. I can not reproduce in under any other condition.
This involves the Drag Drop registration. On the HP the registration fails on the first call.
Initially it appeared that the window handle was incorrect but this is not the case.
The grid has a proper handle and the drop target is null. In tracing the code (on the HP)
Chris's code
BOOL CGridDropTarget::Register(CGridCtrl *pGridCtrl)
{
if (m_bRegistered)
return FALSE;
// Stop re-entry problems
static BOOL bInProcedure = FALSE;
if (bInProcedure)
return FALSE;
bInProcedure = TRUE;
ASSERT(pGridCtrl->IsKindOf(RUNTIME_CLASS(CGridCtrl)));
ASSERT(pGridCtrl);
if (!pGridCtrl || !pGridCtrl->IsKindOf(RUNTIME_CLASS(CGridCtrl)))
{
bInProcedure = FALSE;
return FALSE;
}
m_pGridCtrl = pGridCtrl;
ASSERT (COleDropTarget::m_hWnd==NULL); // OK HERE
m_bRegistered = COleDropTarget::Register(pGridCtrl); // THis call failes on the HP
bInProcedure = FALSE;
return m_bRegistered;
}
COleDropTraget Code:
BOOL COleDropTarget::Register(CWnd* pWnd)
{
ASSERT_VALID(this);
ASSERT(m_hWnd == NULL); // registering drop target twice?
ASSERT_VALID(pWnd);
LPUNKNOWN lpUnknown = (LPUNKNOWN)GetInterface(&IID_IUnknown);
ASSERT(lpUnknown != NULL);
// the object must be locked externally to keep LRPC connections alive
if (CoLockObjectExternal(lpUnknown, TRUE, FALSE) != S_OK)
return FALSE;
// connect the HWND to the IDropTarget implementation
if (RegisterDragDrop(pWnd->m_hWnd,
(LPDROPTARGET)GetInterface(&IID_IDropTarget)) != S_OK)
// Failure here but when should it not??
{
CoLockObjectExternal(lpUnknown, FALSE, FALSE);
return FALSE;
}
// connect internal data
m_hWnd = pWnd->m_hWnd;
ASSERT(pWnd->m_pDropTarget == NULL);
pWnd->m_pDropTarget = this;
return TRUE;
}
In RegisterDragDrop:
The first argument is the handle to the window that excepts the drop.
Now the trace gets "lost" in the os at this point. On the HP the next viewable code in the call stack following the assert is in a CWnd::Attach with the handle of the grid and it asserts since it is not null. It seems that this should have been the handle to the droptarget.
So what is wrong with the HP's to link in this code or why does it not fail on all platforms???
On other platforms it step right though this section with no problems and all handles appear to the consistent.
I have tried this under win 2k on two other (non-HP) machines and under ME and NT4 on this HP machine and they work fine.
Anyone else having experience with this?
Thanks Mike
|
|
|
|
|
Hi everyone,
I'm just wondering how you change the "Untitled" text found on the top left of a single document frame.
If anyone knows, plmk.
Thanks in advance!
Steve
|
|
|
|
|
Steve,
I'm not sure if you are asking how to change it to something else, or remove it. I'm assuming that you know that it says "Untitled" until the initial document is named while saving. This snippet below tells you how to remove the filename (or 'Untitled') from the Window title
I dug this up from an old copy of the MFC FAQ I had kicking around:
Override the PreCreateWindow() function in your MainFrame class and do the following in it..
cs.style &= ~FWS_ADDTOTITLE ;
You can also set the initial window position (cs.x, cs.y, cs.cx, cs.cy) this way and change your class (cs.lpszClass) this way! Remember to call CFrameWnd::PreCreateWindow at the end...
|
|
|
|
|
The FAQ is available at:
http://msdn.microsoft.com/library/backgrnd/html/msdn_mfcfaq50.htm
|
|
|
|
|
Sam, thanks. I tried the link at www.stingray.com/mfc_faq but it seemed to be broken, I'm happy to find this again in the MSDN.
|
|
|
|
|
The document name can be changed using CDocument::SetTitle. Also see: http://support.microsoft.com/support/kb/articles/q129/0/95.asp
|
|
|
|
|
Does anybody have an advice on how to first locate which drive on a Windows 2000 system is the CD-ROM drive and then how to execute a file on the CD-ROM (the file name is known). I cannot use a CFileDialog in order to have the user specify the drive and file name, it must be done without the user seeing anything.
|
|
|
|
|
Hi Roger,
A simple way could be a loop from "A:\" to "Z:\" in which you call GetDriveType(). Then you may stop at the first DRIVE_CDROM result or collect all CD-ROM drives and then choose the best.
Hope this helps,
Paolo.
|
|
|
|
|
I have a problem setting the colors of my MFC application. I have set the background of my dialog
window with SetDialogBgcolor(); but the border is still using the system colors. How do i set the color
of the border?
Another problem I have is that the little arrow on my ComboBox is also set by the system colors, and I can't find a
way to change it.
I have a slider in my application, wich background changed with SetDialogBgcolor(); but I also want to change the color
of the thing you slide and the area witch it slides on, but I have no clue how and where to change these.
I also need to know how I change the color om my menu.
Thankful for any help =)
/Fredrik
|
|
|
|