|
Moak wrote: The beauty of STL glows in less trivial examples
Oh yes ... but reality is different: it is a matter of fact that vector (sequential indexed), list (sequential) and map (indexed) don't have same interfaces, and that the most of stl algorithm that are "non trivial" works with "sequential indexed" (aka "random access") iterators.
Two siple example:
std::list<int> alist;
std::vector<int> avector;
alist.remove(10);
avector.erase(std::remove(avector.begin(),avector.end(),10),avector.end());
Until someone doesn't demonstrate me how can I come to write the second example without having the knowledge of at least 20 pages of documentation (yes, I want a 8 y.o. baby coding that!), I will consider "you can use the same algorithm with a wide range of objects... and only have to learn it once = time saved." a pure marketing lye.
(The fake is that vector doesn't have a remove function, hence is not dual to list , and std::remove doesn't remove: it just swaps things around. You cannot know that unless someone tells you)
The pattern itself can be a good idea (iterators as a bridge between collections and algorithms) but the way is implemented is far from being obvious.
That's the point i was considering.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Please have a breakfast before making angry morning postings.
|
|
|
|
|
I have two applications, both of which I have written.
AppA was written in C++ using MFC. During startup it registers a CSingleDocTemplate and creates a document. The document provides a COM interface and registers itself in the ROT:
LPUNKNOWN punk = GetInterface(&IID_Welder);
::RegisterActiveObject(punk, CLSID_Interface, ACTIVEOBJECT_WEAK, &m_dwRegister);
AppA revokes the entry in the ROT when it is destroyed:
if (m_dwRegister)
::RevokeActiveObject(m_dwRegister, NULL);
The destructor is only called when AppA terminates.
AppB is written in C# and is a client of the interface provided by AppA:
private void Connect()
{
welderInterface = (Welder.Interface)Marshal.GetActiveObject("Welder.Interface");
Marshal.GetIUnknownForObject(welderInterface);
}
private void Disconnect()
{
if (welderInterface != null)
{
Marshal.ReleaseComObject(welderInterface);
welderInterface = null;
}
} (error handling omitted for clarity)
That all works perfectly the first time AppB runs after AppA has started; AppB can call Connect and Disconnect as often as it wants and use the interface between. However, if AppB terminates and runs again (AppA still running) the interface is no longer available - Marshal.GetActiveObject throws an exception from MK_E_UNAVAILABLE . The only way to make the interface available again is to restart AppA - not an acceptable solution!
Please can someone suggest how I might fix this?
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
modified on Monday, August 2, 2010 7:16 AM
|
|
|
|
|
My guess is that when you do this:
Phil J Pearson wrote: Marshal.ReleaseComObject(welderInterface);
your object's reference count reaches zero and it gets destroyed. If this is your COM object, try initializing its reference counter to 1 (i guess it is zero now), or AddRef it after creation and Release when your AppA exits.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
No, that's not it. as I said:
1. The destructor is only called when AppA exits (checked in the debugger).
2. AppB can call Connect and Disconnect many times without problem. The problem only occurs when AppB exits. There's nothing special done with the interface on exit.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
How did you check that your interface isn't deleted when AppB exits? I mean,
Phil J Pearson wrote: (checked in the debugger).
explain this, please.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Logging code and breakpoints in the doc destructor and in the doc OnFinalRelease . Only called when AppA exits - not AppB.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
Oops! Sorry! I take back my earlier rejection of your reply.
It seems that the interface was being destroyed even though the document that implements it was not.
I AddRef'd the interface in the doc constructor and Release'd it again in the destructor as you suggested and the problem is solved.
Thank you!
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
It happens...great it works now.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
i have a question i hava a ClistCtrl control in a modal dialog box (report type). Anyone knows how to make ClsiCtrl keep the values entered after closing the dialog box?when reopening the dialog the control to display the data entered before. Thank you.
|
|
|
|
|
This is already done for you and depends on the life time of the dialog object.
Also update the list control in a callable method other than OnInitDialog .
So each time you call DoModal , it will be on the same object of the dialog class.
|
|
|
|
|
alexander 1983 wrote: Anyone knows how to make ClsiCtrl keep the values entered after closing the dialog box?when reopening the dialog the control to display the data entered before.
Keep the values in some sort of container (e.g., list, array).
"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
|
|
|
|
|
What others said is right. You have to store the data - the data that's supposed to be shown - elsewhere and in order to show that data in the control, you have to feed that, may be through the dialog object, may be something like this.
CMyDialog : public CDialog
{
public:
CMyDialog(CListCtrlData *pd):m_pd(pd)...
BOOL OnInitDialog(...)
{
}
private:
CListCtrlData *m_pd;
};
CListCtrlData gDataA;
void SomeFunction()
{
CMyDialog dlg(&gDataA);
dlg.DoModal();
}
CListCtrlData gDataB;
void SomeOtherFunction()
{
CMyDialog dlg(&gDataB);
dlg.DoModal();
}
If the data is supposed to be editable, just make sure that your data class has appropriate methods to update and call these methods from the relevant event handlers for the control.
byte till it megahurtz
|
|
|
|
|
this question leads to the great theme of separating data from the GUI => MVC
<a href="http://en.wikipedia.org/wiki/Model_View_Controller">http://en.wikipedia.org/wiki/Model_View_Controller</a>[<a href="http://en.wikipedia.org/wiki/Model_View_Controller" target="_blank" title="New Window">^</a>]
Do your homeworks...
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi @all,
i am creating a bho in c++ which should run different actions based on the session cookie which is set.
I tried to read the cookie with this code sample:
void CMyBHOClass::GetCookie(LPTSTR &strCookie)
{
DWORD dwPufferSize = 0;
CString strServer = _T("https://www.mydomain.com");
InternetGetCookie(strServer, NULL, NULL, &dwPufferSize);
TCHAR *strTempData = new TCHAR[dwPufferSize];
ZeroMemory(strTempData, dwPufferSize);
InternetGetCookie(strServer, NULL, strTempData, &dwPufferSize);
strCookie = strTempData;
}
But this is just for normal cookies and my session based cookies will not appear.
Any ideas how to retrieve the session based cookies too?
Thanks for help
Aendy
|
|
|
|
|
The documentation for InternetGetCookie states that it also searches for session cookies.
Here is an excerpt -
InternetGetCookie also searches memory for any session cookies, that is, cookies that do not have an expiration date that were created in the same process by InternetSetCookie, because these cookies are not written to any files.
|
|
|
|
|
Hi Superman,
thanks for your answer.
I also found this information but it wont work, there is not the cookie I need.
But in the HTTP-Header (using fiddler2) i could see it.
Maybe this problem is based on this adivse:
As noted in HTTP Cookies, InternetGetCookie does not return cookies that the server marked as non-scriptable with the "HttpOnly" attribute in the Set-Cookie header.
Any other ideas how to get this cookie?
It is not my server so i could not change the method of cookie creation.
|
|
|
|
|
Hi,
in my VC project, there is this error : "this application has failed to start because MSVCP71.dll was not found. Re-installing the application may fix this problem"
i put the MSVCP71.dll into my system32 folder, still the same thing!!!
please help me
Zo.Naderi-Iran
|
|
|
|
|
I think the comments on this site[^] may have the solution you need.
It's time for a new signature.
|
|
|
|
|
Hi,
Is there any way to put bitmap on CDateTimeCtrl top and bown button in Time format (spin control)?
|
|
|
|
|
Hi everybady.
I Inserted a richedit control in a Dialog.When I typed string in richedit control I found the control didnt response RETURN key.There was not problem in CRichEditView in single document app.
I think perhaps the dialog would process the RETURN down message,and the richedit control had no chance to response it.
I used "ModifyStyle(0,ES_WANTRETURN)" set richedit control's style but this didnt resolve the problem.
What's the different between richedit control in dialog and document-view app ?
Thanks.
Thanks everybody,I found I must set ES_WANTRETURN in visual studio ,
ModifyStyle(0,ES_WANTRETURN) in the OnInitDialog() can't modify the style.
I wonder whether the RichEditCtrl's style must be set when create.
|
|
|
|
|
I think you're absolutely right on that, the dialog eats your return key press in IsDialogMessage . If you're using a dialog template you could try modifing the style in the resource editor instead of in your code.
/M
|
|
|
|
|
Mattias G wrote: you could try modifing the style in the resource editor instead of in your code
Thanks.
I wonder which style I should modify in the resource editor.
|
|
|
|
|
Does your rich edit have the multiline style?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Code-o-mat wrote: Does your rich edit have the multiline style?
I added the multiline style.
|
|
|
|