|
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.
|
|
|
|
|
Did it help?
> 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. <
|
|
|
|
|
Hi all,
Does anyone know how to (programmatically) dock two CDockablePane (or possibly CControlbar ) on top of each other at the right side of the client window? I've tried just about every combination of alignment and CRect in calls to CFrameWndEx::DockPane , but to no avail.
This is what I get:
|-------------------------------------------|
| |-----| |-----| |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| |-----| |-----| |
---------------------------------------------
This is what I want:
|-------------------------------------------|
| ------- |
| | | |
| | | |
| | | |
| ------- |
| ------- |
| | | |
| | | |
| | | |
| ------- |
---------------------------------------------
I would be really thankful for any input on this.
Thanks
/M
(And, yes, I've searched the forums here but didn't find anything, I'm aware of the website www.google.com, and, yes, I know the location of the documentation for MFC and the Feature Pack, and, yes, I've tried just about everything I could come up with.)
|
|
|
|
|
Haha! Solved it seconds after posting:
DockPane(&m_wndTop, AFX_IDW_DOCKBAR_RIGHT);
m_wndBottom.DockToWindow(&m_wndTop, CBRS_ALIGN_BOTTOM);
Might help someone else ...
/M
|
|
|
|
|
I've done that a few times - and I appreciate people posting answers too.
Good on ya!
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
I have a question i want to create a plugin manager, and i have a small example test-bed written. It has abstract classes.
The function CreatePluginClass will the main function to control a set of mini classes that will use the same Interface IPlugin and create a Pointer stored into memory for the new class that will eventually have to be released, so i made a auto/release type template class to do that for me CPluginObject as you can see in the example entry main function
Will this be reliable, because i kinda want to go through this type of approach and if something wrong with this can someone help me point out what it could be?, so far everything is fine that i can see but im not sure that later on that it will cause me problems, if anyone has done anything like this before. I would appreciate the helpful tips
when i tested it i get the results im looking for i guess in the console output shows
TestPlugin2::Function1
TestPlugin2::Function1
#include <stdio.h>
class IPlugin {
public:
virtual void Function1() = 0;
virtual void Function2() = 0;
};
class TestPlugin1 : public IPlugin {
public:
virtual void Function1() {
printf("TestPlugin1::Function1\n");
}
virtual void Function2() {
printf("TestPlugin1::Function1\n");
}
};
class TestPlugin2 : public IPlugin {
public:
virtual void Function1() {
printf("TestPlugin2::Function1\n");
}
virtual void Function2() {
printf("TestPlugin2::Function1\n");
}
};
#define PLUGIN_CLASS_1 100
#define PLUGIN_CLASS_2 100
void CreatePluginClass(int iid, IPlugin **pObj)
{
*pObj = NULL;
if (iid == PLUGIN_CLASS_1)
*pObj = new TestPlugin1();
if (iid == PLUGIN_CLASS_2)
*pObj = new TestPlugin2();
}
template<int N>
class CPluginObject {
public:
CPluginObject() {
CreatePluginClass(N, &pPluginObj);
}
~CPluginObject() {
if (pPluginObj != NULL)
delete pPluginObj;
pPluginObj = NULL;
}
IPlugin *GrabObject() const {
return pPluginObj;
}
protected:
IPlugin *pPluginObj;
};
void main(void)
{
CPluginObject<PLUGIN_CLASS_1> plugin;
IPlugin *pObj = plugin.GrabObject();
pObj->Function1();
pObj->Function2();
}
modified on Sunday, August 1, 2010 5:36 AM
|
|
|
|
|
Hi, I suggest to simplify.
There is no need to mix templates, virtual methods and a global factory function. Wouldn't it be simpler to let polymorphism do the work, inherit from the plugin interface and that's it. This works because virtual methods Function1() /Function2() will be called in the specific implementation (even when called via base class pointer IPlugin ).
The problem with plugins is typically memory handling, at least that is the first thing that comes in my mind. You need to make sure that dynamic memory allocation/deallocation happens in the same heap (STL strings and containers can't be used out-of-the-box). Of course, you can use allocators to get better control of memory allocation/deallocation over library boundaries. There is also a nice book called Imperfect C++ which describes these kind of problems and possible solutions.
Not sure if I answered your questions, but I hope I could give some help.
/M
PS: There is a typo TestPlugin1::Function2() and TestPlugin2::Function2() in the printf text string, that's why the debug output is other than expected.
|
|
|
|
|
I shall take a look at the Polymorphism, i had planned on eventually making a large class factory. I wanted to implement a hash library.
example
class IHashAlgo {
public:
virtual void Init() = 0;
virtual void Update(PBYTE pData, INT nLength) = 0;
virtual void Final() = 0;
virtual void GetResults(PBYTE pData) = 0;
};
Abstract Class 1, would be MD5, the results would be the digest
Abstract Class 2, would be SHA1 ..... etc
I wanted to make a cleaner class library because it got really ugly when i was doing this
I hope you understand what i am trying to describe at least
class CHashAlgo {
public:
void Init(INT nType) {
m_Type = nType;
switch (nType) {
case HASHTYPE_MD5:
MD5Init(&m_md5);
break;
case HASHTYPE_SHA1:
SHA1Init(&m_sha1);
break;
default:
break;
}
}
void Update(PBYTE pData, INT nLength) {
switch (nType) {
case HASHTYPE_MD5:
MD5Update(&m_md5, pData, nLength);
break;
case HASHTYPE_SHA1:
SHA1Update(&m_sha1, pData, nLength);
break;
default:
break;
}
}
void Final() {
switch (nType) {
case HASHTYPE_MD5:
MD5Final(&m_md5);
break;
case HASHTYPE_SHA1:
SHA1Final(&m_sha1);
break;
default:
break;
}
}
void GetResults(PBYTE pData) {
switch (nType) {
case HASHTYPE_MD5:
memcpy(pData, m_md5.digest, MD5_DIGEST_SIZE);
break;
case HASHTYPE_SHA1:
memcpy(pData, m_sha1.digest, SHA1_DIGEST_SIZE);
break;
default:
break;
}
}
int m_Type;
MD5_CONTEXT m_md5;
SHA1_CONTEXT m_sha1;
};
|
|
|
|
|
Hi,
I think most experienced C++ programmers would get what you're trying to do. You're trying to handle hashing without worrying which algorithm for hashing is bound to higher level functions.
So for composing a digital signature you need a digest (hashing) algorithm and a public key signing algorithm. So to create a digital signature you'd compose a hash and a signer :
class digest_generator
{
public:
signer( hasher &h, signer &s ) : h_( h ), s_( s )
{
}
std::string create_digest_for_stream( std::istream &str )
{
return s_.signature_of_string( h_.hash_of_stream( str ) );
}
private:
hasher &h_;
signer &s_;
};
where hasher and signer are interfaces implemented by things like MD5_hasher, SHA1_hasher and RSA_signer.
The question is why you need a plugin for this sort of thing. While it may sound cool to have an externally implementable interface to do security stuff you open yourself up for attack by giving attackers a way of replacing or modifying parts of your code.
Anyway, think very carefully before letting other people modify the way your code works in a security context. It can bite you very hard and cause a lot of damage to your reputation.
Cheers,
Ash
|
|
|
|