|
|
Gulp .. did not know about the article ... sorry ...
~RaGE();
|
|
|
|
|
Yep, I had seen this article.
The question is : how can I use cin to get text entry and in the background have modeless dialogs ????
Jonathan de Halleux.
|
|
|
|
|
Create a worker thread in main .
When starting the worker, call CreateDialog to create the modeless as in the article. Then write the message loop and catch there all the messages you throw from the dialog. All this stuff in the worker's handler...
Then you could synchronize the worker with the main , using the system dedicated objects.
Generally, when you call CreateDialog from a thread with NULL as the parent window, the modeless' messages will be droped in that thread's message loop.
rechi
|
|
|
|
|
i have an mfc dialog based app.
in the initInstance function, I'm creating an object of the dialog box (provided by the wizard) and creating a tray icon using NotifyIconData.(without showing the dialog box).
NOW i want to show this dialog box when i right click on this icon but multiple instances of dialog box appear even if i move my mouse over the icon, while i have used WM_LBUTTONDBLCLK in the code below (InitInstance)?
how do i go about it?
this is my src code
CSchdDlg dlg;
m_NotifyIconData.cbSize = sizeof m_NotifyIconData;
m_NotifyIconData.hWnd =dlg.GetSafeHwnd();
m_NotifyIconData.uID = 1;
m_NotifyIconData.uCallbackMessage = WM_LBUTTONDBLCLK ;
m_NotifyIconData.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
m_NotifyIconData.hIcon = LoadIcon(IDR_MAINFRAME);
strcpy(m_NotifyIconData.szTip, AfxGetAppName());
Shell_NotifyIcon(NIM_ADD, &m_NotifyIconData);
a quick & detailed response will be heartly appreciated!
thanx
rishabhs
rishabhs
|
|
|
|
|
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();
|
|
|
|