|
When your dialog receives a WM_CLOSE message, it closes. And this sounds like what is causing your icon to be removed from the tray.
You can handle the WM_CLOSE message yourself, with classwizard. The implementation it gives you will have a line to call OnClose() in the base class. If you leave that line in place, then your dialog will close.
Therefore, in your overridden OnClose() member, you need to NOT call the base class implementation, and instead do stuff to hide your window, and install your tray icon.
This will all work fine. Until you want to close your window for real!!! A way to sort this out (that i've used before):-
class CMyDialog
{
....
BOOL bClose;
}
CMyDialog::InitDialog()
{
....
bClose=FALSE;
....
}
CMyDialog::OnClose()
{
if (bClose)
{
CDialog::OnClose();
} else
{
}
}
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Look up Shell_NotifyIcon.
You need to use that to add an icon to your sytem tray. And then hide your window or dialog.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Thanx Nish,
But i'm sorry to say that i forgot to mention that i'm using SHELL_NOTIFYICON and the application is working just fine i.e. it minimizes to the systray, but the problem starts when i try to use CPropertySheet instead of CDialog class. And still i'm succesful in a way that the application is still(i.e. the CPropertySheet application) being minimized to the systray. But, when i close the application by either pressing 'x' or cancel or ok button the icon is removed from the tray.
For that matter i have to catch the close or cancel event of the PropertySheet so that i can, based on some var minimize it to the systray or exit the application.
Again thanx for atleast taking some time to read and reply
Pls try to find a solution for me??
Rohit
|
|
|
|
|
Can u explain as to which one of them is your problem :
(1) How to catch the CLOSE message, so that you can properly override it according to your needs?
or
(2) You have already overriden the close function and want to know how to minimize the application to the taskbar again ?
-kashif
peace to all
|
|
|
|
|
Hi,
Thanx Kashif
My problem is i'm not able to find a suitable event to catch where i can hide my window.
Anyways i have found a work around.
But still thanx
Rohit
|
|
|
|
|
Assuming that you have already overridden the OnClose() method (WM_CLOSE message) and want to hide the application again here's what you should do.
/* get the handle of the application and simply hide through the code similar to the pne given below. Since your application icon already exists in the taskbar you need not put it there again. Simply hiding the main window should do the trick*/
::ShowWindow(GetParent()->GetSafeHwnd(), SW_HIDE);
hope it helps,
-kashif manzoor
peace to all
|
|
|
|
|
Hello,
I wonder how to change the class name of the CDialog created with MS Visual C++ 6? By default it is '#32770' but I want to use another class name for my app. I can't find the answer anywhere. Please help!
CK
|
|
|
|
|
Add the following to your PrecreateWindow function:
// Remove 'Untitled' from caption
cs.style &= ~(LONG) FWS_ADDTOTITLE;
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
if (NULL == m_winClassName)
{
m_winClassName = RegisterSimilarClass("MyClassName", cs.lpszClass, IDR_MAINFRAME);
if (!m_winClassName)
return FALSE;
}
cs.lpszClass = m_winClassName;
and add the RegisterSimilarClass function as follows:
static LPCSTR RegisterSimilarClass(LPCSTR lpszNewClassName,
LPCSTR lpszOldClassName, UINT nIDResource)
{
// Get class info for old class.
//
HINSTANCE hInst = AfxGetInstanceHandle();
WNDCLASS wc;
if (!::GetClassInfo(hInst, lpszOldClassName, &wc)) {
TRACE("Can't find window class %s\n", lpszOldClassName);
return NULL;
}
// Register new class with same info, but different name and icon.
//
wc.lpszClassName = lpszNewClassName;
wc.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(nIDResource));
if (!AfxRegisterClass(&wc)) {
TRACE("Unable to register window class%s\n", lpszNewClassName);
return NULL;
}
return lpszNewClassName;
}
Replace IDR_MAINFRAME with the ID of your dialog. This *should* work, I've done it in a doc/view app, and the code is off MSDN, it's by Paul De Lascia.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
The PreCreateWindow function is not called when creating a dialog box:
(From Visual C++/MFC Frequently Asked Questions)
Why isn't my CDialog::PreCreateWindow() getting called?
PreCreateWindow does not get called when you create a dialog box. If you would like to init some data/controls for a dialog box, you have to trap the OnInitDialog message and then do your stuff there. PreCreateWindow is used to modify params for a window that you are creating.
I am going to try to debug into the creation of CDialog, maybe I will see where the class name is assigned...
|
|
|
|
|
- Manually edit your
.rc resource file and add the following to the definition of your dialog template:
IDD_TEST_DIALOG DIALOGEX 0, 0, 185, 92
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Test"
FONT 8, "MS Sans Serif"
<font color="#ff0000">CLASS "MYDIALOGCLASS"</font>
BEGIN Of course you can replace "MYDIALOGCLASS" with whatever name you please.
- Register the new class somewhere before the creation of the dialog (
InitInstance is a good place):
WNDCLASS wc;
GetClassInfo(NULL,"#32770",&wc);
wc.lpszClassName="MYDIALOGCLASS";
AfxRegisterClass(&wc); - Enjoy!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hey, it works. Thank you very much!
CK
|
|
|
|
|
Made a cd writing application and when it was creating the ISO I had a modeless dialog box, it was there for about 15 minutes and it crashed
It doesnt crash when its just there for a few minutes
anyone seen this before???
|
|
|
|
|
I have apps with modeless dialogs up constanty - the problem is with your code, modeless dialogs do not have a time limit.
Have you tried debugging and seeing where it crashes ?
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Modeless dialogs can stay around for as long as it is required provided the program doesn't do any nasty thing to them. I'd say you've got a bug here --try to locate the lines of your code where you issuing a delete pModelessDlg (where pModelessDlg is the variable you use to hold a pinter to the dialog) and set breakpoints on these lines to determine if they're executed when they shoudn't.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Its not getting deleted before its finished,
The pointer to HWind is NULL
Thanx guys
|
|
|
|
|
If it's NULL, then DestroyWindow has been called ( which is the correct way to delete a modeless dialog ).
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Hi,
How can I update the view of my flexgrid control at run time? I want to display different query output passed to the remote data control connected to the flexgrid, at runtime.
Please Help
|
|
|
|
|
You can use Update() or(refresh(),I'm not sure which one)for flexgrid controller,or you can use one of these functions for controller of it's Adoc.
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
My code is this....
m_Rdc.SetSql ("Select * from emppers");
m_Rdc.Refresh ();
m_Flex.Refresh ();
m_Rdc is the member variable of type RemoteDataControl and m_Flex is of FlexGridControl.
But this is not working. Is there any other way to do this.
Pls Help.....
|
|
|
|
|
My app loads data into a buffer at startup all of the same type of record, but variable length.
To make the data more readable i'm going to display it in differenct ways. The tree will have 2 root items each of which will use the same data, but displayed differently. One is structured the other is chronological.
Anyways how would you suggest I send the current item info to the corresponding ListView...?
Chronological will send all the data over to the list view.
Structured will send only relevent info into the listview.
There doesn't seem to be a GetIndex() that would map to an array of data items. How should i go about doing so...?
I'm thinking get the current HTREEITEM and iterate the buffered array of data items for a match and send the info then over to the listview...
Any ideas...?
Thanx muchly!!!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
If I understood your requirements correctly, seems to me like CTreeCtrl::SetItemData and CTreeCtrl::GetItemData can be used to store and retrieve pointers to an array of yours holding the data items.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanx again!
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I am trying to implement a type independant linked list in C++ for use in a C# program. The problem I have is that I have a class ListItemType that holds the data. I need to derive a class from this class in order to hold the lists data. I need to access the members of the derived class with a virtual function that is specifically coded for that class. Is there a way to cast it in C# so that this is possible? Secondly is there a better way to do this? Thanks.
Code follows:
public __gc class ListItem : public Object
{
public:
ListItem(Object *Obj);
void Delete();
bool isUsingSubItems;
int index;
ListItem *pNext;
ListItem *pPrev;
Object *pObject;
};
public __gc class LinkedList
{
public:
LinkedList();
void AddItem(Object *Obj);
Object *FindItem(Object*Obj);//Used to search the root object in each item
virtual Object *FindSubItem(Object *rootObj,Object *Obj) = 0;//Must be
// custom defined each time for the particulars of the list;
Object *GetAt(int index);
int GetIndex(Object *Obj);
void DeleteItem(Object *Obj); //Find a node and delete it
void DeleteList();//delete the whole list
void SetType(Type *type);
int GetNumItems(){return iNumItems;}//
void SetTypeSafe(){bTypeSafe = true;}
bool isTypeSafe(){return bTypeSafe;}
protected:
int iNumItems;
Type *pObjectType;
bool bTypeSafe;
protected:
ListItem *pListHead
ListItem *pListTail;
};
Steve
Not all who wander are lost...
|
|
|
|
|
Does anyone know of a commercial vector graphics library (compatible with MFC/VC++)? I need to use vector icons in a certain format (whichever the library requires) to display in a CView. I have been looking all over the net, but have not found anything decent.
Thanks.
|
|
|
|
|