|
All is well, but it doesn't change the fact that it still does't break the notifications loop.
Think of this as the flow of events:
1. Subject starts it's notification loop
2. it reaches my observer is the list of observers and notifies it
3. the observer then notifies the singleton needs to be deleted
4. the object is deleted
5. the function (in the singleton and in the observer) returns and the next thing to do is for the subject to continue it's notification loop on to the next observer on the list, but then the program crashes on access violation since the memory space the subject has occupied is not longer allocated since it was deleted / has deleted itself.
Please try something else.
Thanks,
Lior.
|
|
|
|
|
check out my reply to the previous message I received.
In short, it still doesn't break the notifications loop.
Thanks,
Lior.
|
|
|
|
|
IMHO there's a conceptual mismatch here that's causing your problems: You have an observer entitled to delete the subject (so it is a rather powerful observer) but that might be sharing the observation with other observers. The design seems to fail to capture the special role played by this observer. Maybe you can transfer the responsibilty of deleting subjects to the singleton class that holds them, and keep the observers as passive objects, which is (as I see it) what this design pattern originally intends.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm getting the error message:
'Cx::Cx' : cannot access protected member declared in class 'Cx'
I used the classwizard to create a CWinThread derived class Cx.
And I see that i places the construtor in the protected section.
Now I read that there were two ways to start the thread, one that uses AfxBeginThread /ResumeThread and this one:
Cx * thread = new Cx();
thread->m_x = 1;
thread->CreateThread();
I like this implimentation and would like to get it to work but I'm not sure how.
|
|
|
|
|
Anonymous wrote:
And I see that i places the construtor in the protected section
You placed your constructor in the protected section or the class wizard did?
It seems to me that the contstructor should be in the public section.
|
|
|
|
|
Thats a typo, the sentance should read:
And I see that IT places the construtor in the protected section.
it = classwizard.
>It seems to me that the contstructor should be in the public section.
Yeah, thats what i thought (which is why i included that bit of info about the location of the constructor) but thats what the classwizard does so i don't want to go and change it.
So my question in the first post still stands.
|
|
|
|
|
I am not a big MFC programmer, but MSDN says that AfxBeginThread will create the instance of the object for you.
|
|
|
|
|
I can't believe this trivial/basic task is giving me trouble! I've figured pretty much everything else out -- but .. in VC++.NET how do you properly delete a classes member functions and variables?
Travis D. Mathison ---
--- After three days without programming, life becomes meaningless ...
|
|
|
|
|
Appart from any other IDE-assisted methods, you can always go to the corresponding .h and .cpp files and manually erase the occurrences of the member.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That's what I am doing now. I'm simply wondering where the IDE assisted feature for it is ..
Travis D. Mathison ---
--- After three days without programming, life becomes meaningless ...
|
|
|
|
|
Yes, I should have guessed. I don't know, I'm sorry I can't be more helpful.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
I have been looking all over the web(or at least as far as google takes you) for the source of a tab view. All i need are these nice Execl like tabs. I found some source on the codeproject for something similar, but these flicker way too much to be usefully.
Does anyone have an idea, where I can get a source for a Tab-view.
Thank You,
SD
|
|
|
|
|
|
I need help with showing me how to draw a bitmap that i have in the resources, into my application upon run time. CAn someone help me out and explain in detail please. Thanks
the meek shall inherit thee earth.......but they wont get the ball
|
|
|
|
|
If you want to draw the bitmap onto a window using a DC here is how you would do it:
PAINTSTRUCT ps;
HDC hdc;
hdc = ::BeginPaint(hWnd, &ps);
HBITMAP hBitmap;
::LoadImage(::GetModuleHandle(NULL),
MAKEINTRESOURCE(IDB_RESOURCEID),
IMAGE_BITMAP,
0,
0,
LR_DEFAULTSIZE
);
if (!hBitmap)
{
}
HDC memDC;
memDC = ::CreateCompatibleDC(hdc);
HBITMAP hBmpOld;
hBmpOld = (HBITMAP)::SelectObject(memDC, hBitmap);
BITMAP bm;
::GetObject(hBitmap, sizeof(BITMAP), &bm);
if (FALSE == ::BitBlt(hdc, 0,0, bm.bmWidth, bm.bmHeight, memDC, 0,0, SRCCOPY))
{
}
::SelectObject(memDC, hBmpOld);
::DeleteDC(memDC);
::DeleteObject(hBitmap);
::EndPaint(hWnd, &ps);
If you would like to paint a bitmap outside of the paint handler, you can replace the following code:
PAINTSTRUCT ps;
hdc = ::BeginPaint(hWnd, &ps);
...
::EndPaint(hWnd, &ps);
with this:
hdc = ::GetDC(hWnd);
...
::ReleaseDC(hWnd, hdc);
If you have any other questions, feel free to ask.
|
|
|
|
|
How can i pass a variant type data to a activex control in a mfc app?
the msdn says i need use COlevariant class, but how?
thanks for help
|
|
|
|
|
ALl you need to do is create a COleVariant object using the appropraite constructor, and either Detach it (to get a VARIANT) or use the LPVARIANT operator (to get a pointer to a VARIANT). For example, if you have an Automation function like:
HRESULT SomeFunction([in] VARIANT avtLabel, [in] VARIANT *apvtTimes);
you should be able to:
COleVariant vvtLabel(_T("My STring"));
COleVariant vvtInt(1000, VT_I4);
HRESULT vhRet;
vhRet = SomeFunction(vvtLabel.Detach(), vvtInt);
<pre>
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Thanks very much, that's would be very helpful.
|
|
|
|
|
Hi. Im starting de development of a new program and it will access files from a server protected directory, so it cant be accessed directly (except by admin). The program will be used by standart users, which, depending on their permissions, can only access some files. How can i access the directory from the program?
a) creating a user "administrator" that is actually the program (is that possible??)
b) Using a kind of FTP server that doesnt allow direct access, but allows authorized users to get the files
c) ...
|
|
|
|
|
How I can find if my application is running under debugger?
|
|
|
|
|
|
class x
{
typedef vector<string > STRINGLIST;
STRINGLIST y;
}
My question is: Is STRINGLIST seen outside the class?
I always wrote the typedefs outside, but recently I saw a few classes with typedefs like this. So, I thought it may have something to do with the scope.
And, is it advisable to do it this way? Any pros/cons?
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
If you make it public, you can say..
x::STRINGLIST z;
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
The default access specifier in a class is private, therefore you will not be able to see STRINGLIST ourside of your class.
However like Tim said, if you declare the STRINGLIST like this:
class x
{
public:
typedef vector<string > STRINGLIST;
STRINGLIST y;
};
it will be public and can be accessed by this:
X::STRINGLIST slVariable;
|
|
|
|