|
Call DestroyWindow() only
if your class is derived from CView :
void CView::PostNcDestroy()
{
delete this;
}
virtual void BeHappy() = 0;
|
|
|
|
|
I did as you told...
But same problem I am facing.
If I use delete CMyView then only I am getting fresh view and not getting any refresh issue but crashing for next view.
|
|
|
|
|
Have you try ? :
pView->OnClose();
and after that , of course
delete pView;
modified on Monday, September 27, 2010 1:42 PM
|
|
|
|
|
Hello, I have an app which I need to make single instance. When the second instance is called it needs to bring the window of the first instance to the front, and pass it its command line params in some way. And I need the program to be single-instance on session only - i.e. only one instance is allowed per user, but many users logged on can each have their instance.
There are a lot of articles on this in codeproject, but I'm not sure which of them is the best and covers all the requirements.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Use the named mutex method.
This is by default unique per session unless you prefix "Global\" to the mutex name.
|
|
|
|
|
I think you can make your class as singleton by making you contructors and destructor as private and publically expose a static method which will return the same instance once an instance is created. That shud take care of your problem.. Google for singleton class examples ..u will get loads of them ..
-Kushagra
|
|
|
|
|
The singleton pattern is not applicable in this case: its purpose is to have a unique instance of an object for each process.
If you have two or more different instances of the same application, each of them runs on a different process with its own address space, then two applications cannot share the singleton object.
Cheers,
Sauro
|
|
|
|
|
another way, if you are certain about the window caption, is to use FindWindow() API to search for already running application. To make it unique, you may use your own name for your window class, and use it in FindWindow().
|
|
|
|
|
I've used FindWindow before, but I remember it had a lot of issues, for example (I don't remember) but didn't it fail if the window was minimized?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
no.. you can find out minimized windows also.
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
I am getting active view (say AV1) attached with main window (MainFrame) using GetActiveView, some other views are member of Av1 view.
If I use GetActiveView() just after initialzation of winow I am getting correct view.
But If I click of some another view then I am not getting Av1 view.
How to get same view at both instance?
|
|
|
|
|
john5632 wrote: But If I click of some another view then I am not getting Av1 view
That is correct, GetActiveView() returns "A pointer to the current CView . If there is no current view, returns NULL .", as described here[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I have drived a class from CStatic control. I am using my own method to set text CMyStatic::SetText().
I am drawing text using
dc.DrawText(strText,&rectWnd,DT_VCENTER| DT_RIGHT | DT_WORDBREAK);
in paint method but If I want to set another string It is getting overlapped. So I am not able to see the extact string.
How to solve this refreshing problem?
|
|
|
|
|
From where do you get the strText? The problem might be because the underlying CStatic controls window text is set (and drawn). In your SetText(), you might have to clear this by calling SetWindowText(_T("")).
Depending on what you mean by overlapping, another reason could be that your rectangle isn't large enough to fit the text, in which case you can use the flag DT_CALCRECT to get the size needed.
|
|
|
|
|
I am passing text from outside using SetText function.
This static control is drawn over a custome dialog which is having some color, If I use SetWindowText(_T()) I am getting window native color.
Overlapping means , One test is drawn on anothet text.
I am giving enough size to draw.
|
|
|
|
|
|
Are you erasing the background properly when your control is refreshed?
|
|
|
|
|
|
I am trying to decalare a CArray in side a CMap
CMap<CString,LPCSTR,CArray,&CArray> m_abc
But I get error C2955: 'CArray' : use of class template requires template argument list
Can you please help me!
Thanks
|
|
|
|
|
Try something like this:
CMap<CString,LPCTSTR,CArray<int,int>,&CArray<int,int>> m_abc
Please note:
the collections (nested - especially) can be faster and lower priced,
when they use the pointers inside, not the instances...
virtual void BeHappy() = 0;
|
|
|
|
|
I tried
CMap<CString,LPCTSTR,*CArray<CString,LPCTSTR>,&CArray<CString,LPCTSTR>> m_abc;
I get error C2275: 'CArray<TYPE,ARG_TYPE>' : illegal use of this type as an expression
|
|
|
|
|
And now ? :
CMap<CString,LPCTSTR,CArray<CString,LPCTSTR>*,CArray<CString,LPCTSTR>*> m_abc;
CMap<CString,LPCTSTR,CStringArray*,CStringArray*> m_abcd;
virtual void BeHappy() = 0;
|
|
|
|
|
why don't you simple put the CArray inside another class ? Me think it will make thing easier in the long run.
Watched code never compiles.
|
|
|
|
|
You can't write:
CArray myArray;
and expect it to compile without without telling it what you want to put in your array. You have to write something like:
CArray<int> myIntArray;
So the question is what type of data are you trying to store in your nested CArrays? Once you know that you can explicitly specify the type of your data in CMap. When you've done that you'll probably run into trouble because CArray hasn't got a copy constructor and I think the types supplied as arguments to CMap need to be copy constructable.
As a complete aside, how about binning this last century MFC collection class rubbish and use the standard library classes std::map and std::vector? They can do what you want with much less farting around than MFC.
Cheers,
Ash
PS: Thanks for Paul below pointing out the faux pas in the original post!
modified on Saturday, September 25, 2010 7:05 AM
|
|
|
|