|
This is what works for me:
#define UWM_ICONNOTIFY WM_APP+x
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//...
ON_MESSAGE(UWM_ICONNOTIFY, OnSystemTrayIconNotify)
//...
END_MESSAGE_MAP()
LRESULT CMyDlg::OnSystemTrayIconNotify(WPARAM, LPARAM lParam)
{
switch (lParam)
{
case WM_LBUTTONDBLCLK:
// do something
// etc.
}
return 0;
}
// Initialize system tray icon
//
m_nid.cbSize = sizeof(NOTIFYICONDATA);
m_nid.hWnd = m_hWnd;
m_nid.uID = ID_SYSTEMTRAYICON;
m_nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
m_nid.uCallbackMessage = UWM_ICONNOTIFY;
m_nid.hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MYTRAYICON), IMAGE_ICON, 16, 16, 0);
strcpy(m_nid.szTip, "Blah, blah");
Shell_NotifyIcon(NIM_ADD, &m_nid);
HTH
Zdenek
|
|
|
|
|
can u be a bit more specific with ur code.
how to get the :-
ON_MESSAGE(UWM_ICONNOTIFY, OnSystemTrayIconNotify)
in the message map declaration
|
|
|
|
|
I suppose a Class Wizard has created a
BEGIN_MESSAGE_MAP(CYourDialog, CDialog)...END_MESSAGE_MAP()
sequence for CYourDialog.
Using your editor, paste a line
ON_MESSAGE(UWM_ICONNOTIFY, OnSystemTrayIconNotify)
there (for example just below the BEGIN_MESSAGE_MAP() macro line).
Avoid a temptation to put it somewhere between
//{{AFX_MSG_MAP(CYourDialog)
//}}AFX_MSG_MAP
since Class Wizard might get confused.
Insert the declaration of your icon message handler OnSystemTrayIconNotify
into CYourDialog class. Like this:
afx_msg LRESULT OnSystemTrayIconNotify(WPARAM, LPARAM);
That's all.
Zdenek
|
|
|
|
|
Setting uCallbackMessage = WM_LBUTTONDBLCLK causes that message to be sent every time the mouse pointer is over the tray icon.
You need to specify your own message and handle that in a subclassed WindowProc.
Like:
#define WM_NOTIFY_ICON (WM_USER + 10) //+10 because some of the first may be used.
m_NotifyIconData.uCallbackMessage = WM_NOTIFY_ICON;
LRESULT MyDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_NOTIFY_ICON:
switch (lParam)
{
case WM_LBUTTONDBLCLK:
ShowWindow(SW_SHOWNORMAL);
TRACE("> Left mouse button double-clicked on icon.\n");
SetForegroundWindow();
break;
default:
break;
}
break;
default:
break;
}
return CDialog::WindowProc(message, wParam, lParam);
}
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
fredrik sorry to bother u but plz. tell me where do i put
the windowproc function (In the Cwnd derived class or CDialog derived class).
|
|
|
|
|
Use the Class Wizard to subclass the WindowProc of your dialog.
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
THANX FREDRIK! that worked fine.
but whenever i dblclick on the icon a new dialog box ois opened. How to make sure that only one dialog is opened at a time.
rishabhs
|
|
|
|
|
It would help if you posted some code.
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
How can i list network paths? Something like what the command dir does is what i want.
|
|
|
|
|
Have a look at the FindFile API for the dir functionality, the network part is a bit trickier (and depends on what you want to do).
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
|
in my app, i have the following code run successfully with
MS Access Driver 4.00.6019.00, but fail with version
4.00.6200.00. the exception thrown says
"[ODBC MS Access Driver] Too few parameters. Expected 1."
// _ConnectionPtr m_pConnection;
// _RecordsetPtr m_pRecordSet;
m_pRecordSet = m_pConnection->Execute(_bstr_t(query), &vRecsAffected, adOptionUnspecified);
How should i overcome this problem? is there a generic way
that works with different versions of MS Access Driver?
Thanks a lot!
Wenrich
|
|
|
|
|
What is in query?
Maybe some field name is equal to a reserved word added in new version?
Pavel
Sonork 100.15206
|
|
|
|
|
Thanks Varel!
this query is
CString query;
query.Format(_T("SELECT * FROM %s WHERE (%s='%s') AND (%s='%s')"), table, key, value1, field, value2);
// table:"client", key:"ID", value1:"some name", field:"Pass", values"some
// password"
Is there anything wrong with the field names?
Thanks a lot!
|
|
|
|
|
I would try:
SELECT * FROM [%s] WHERE ([%s]='%s') AND ([%s]='%s')
Doesn't some of the values contain an ' character (apostrof)?
Pavel
Sonork 100.15206
|
|
|
|
|
How do I get the Handle of a Bitmap image which is created in bitmap resource editor.
|
|
|
|
|
CBitmap bBitmap;
bBitmap.LoadBitmap(RESOURCE_ID);
HBITMAP hBitHandle = (HBITMAP)bBitmap;
Bear in mind when the CBitmap goes out of scope the handle will be invalid;
You may need to make the CBitmap a member Variable
|
|
|
|
|
First you have to load the bitmap using the LoadBitmap function. This function needs the instance of the app and an LPCTSTR string identifing the resource.
HBITMAP hbm;
hbm = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_REDCHICKEN));
...
DeleteObject(hbm);
Don't forget to release the bitmap handle using DeleteObject.
-Dominik
|
|
|
|
|
Try this, I haven't checked it but somthing along these lines should do it
char szFilePath[_MAX_PATH + 1];
char szDir[_MAX_DIR + 1];
char szDrive[_MAX_DRIVE + 1];
CString szFile;
::GetModuleFileName(NULL, szFilePath, MAX_PATH);
::_splitpath(szFilePath, szDrive, szDir, NULL, NULL);
szFile = szDrive + szDir + ""MyFile.txt"
|
|
|
|
|
Hi,
In a dialog based application, I have two classes such as
class A
{
do some calculation with a thread;
}
class B : public CDialog
{
here a have a static control, to show some text or numberical
information with the varible CSting m_show;
}
My problem is how to show the text info (class A) in the main dialog (class B) when the thread is started?
Thanks in advance!
chen
|
|
|
|
|
I did something like this a few months ago. B was my main Dialog, so I just used AfxGetMainWnd in A to retrieve a Cwnd* which I casted on the B class, just as you do with the thread parameter. The result of the operation was that I had a pointer on the B class inside A, and I synchronized the whole with Critical_section, in order not to show in B data being changed simultaneously in A.
A naive question : is it not possible to put your A data in a struct, and post it through a user message to B (I have really no idea if this is possible or not )?
~RaGE();
|
|
|
|
|
Hi RaGE,
Thank you very much for your reply!
I want to try the first method, but would you please say that in more detail or give me an simple example project?
Best Regards,
chen
|
|
|
|
|
Declare
CRITICAL_SECTION m_cs;
int *m_myData;
as member variables in B.
In OnInitDialog of B :
InitializeCriticalSection(&m_cs);
So, in the thread A :
CWnd* pWnd=AfxGetMainWnd();
CMainDlg *pMainDlg=(CMainDlg*)pWnd;
... do some stuff ...
EnterCriticalSection(&pMainDlg->m_cs);
pMainDlg->m_myData[8]=22;
LeaveCriticalSection(&pMainDlg->m_cs);
And in the "show" section of B:
EnterCriticalSection(m_cs);
LeaveCriticalSection(m_cs);
So that's the start. You may have member variables in B which simply copies member variables of A just for display purposes. Of course, this is not a _good_ way to do multithreading, but i think that it is simple enough, and it works if the updating of data in the thread is not too time-critical.
If this doesn't work, you're going to use CEvent 's ...
~RaGE();
|
|
|
|
|
If all you need to do is transfer a numeric value, use InterlockedExchange() which allows you to set a LONG as an atomic operation. (See help for explanation of Interlocked calls--if you do multithreading you should understand these.)
|
|
|
|
|
dianazheng wrote:
// Get the current time
CTime curTime = CTime::GetCurrentTime();
//Get the current date
CTime curDate = CTime::GetCurrentTime();
What is the point of this ? Both these objects are the same.
dianazheng wrote:
//Display the current date
m_sDate = curDate.Format("%b / %d / %y");
// Display the current time
m_sTime = curDate.Format("%H:%M:%S");
MSDN does not document these methods, have you tried using GetMonth/GetYear/GetDay instead ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
// Display the current time
m_sTime = curDate.Format("%H:%M:%S");
MSDN does not document these methods, have you tried using GetMonth/GetYear/GetDay instead ?
Actually, I have this one in my MSDN, so I guess that's why dianzheng wrote that "it works for time". Anyway, Chris is right, GetMonth/Year/Day is the best way to do it.
~RaGE();
|
|
|
|