|
The advice that has been given to you ( using extern for a global variable/using AfxGetApp() to get a pointer to your app object to access variables stored there) has been good, and correct. If you are incapable of making it work, then there is a problem with your ability to apply the information provided. Therefore, what you can do is post some of your code here, so that someone here ( I'm more than happy, and I'm sure others are the same ) to cast our eye over your code so we can show you what you are doing wrong.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
Did you try what I posted ? It is not clear that you did since you did not reply to my post. I have written thousands of lines of code that use this very convention and I know for a fact that it works.
|
|
|
|
|
Hello, the codegurus around the world.;)
I agreed with you partly because I admitted that the global variable isn't bad
in C++ project.
However, in Java and C#, we can't use the global variable at all.
Global variable is always called even though we don't need this.
However, the member vairable of class is alive as long as the class object is alive.
If someone overwrites the value of the global vairable, we sometimes don't notice this.
However, the member variable of class only overwrites the value by its class object.
(If we declare the member variable by private.)
I guess that the global varibales exists in MFC library, so we can't neglect the global at all.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
As you may know from reading my other post, I'm developing a client\server app. Well I am stuck on how to manage a database of users. I don't know whether each server should have each server have an embedded database engine and allow them to connect to each other to query each other for user authentication or to make a database server which will manage the list of users. The servers will be in diffrent geographic locations.
Thanx in advance.
Stephen Caldwell
Desick Information Technologies
|
|
|
|
|
when we did something similar we had a central authentication server (can have fall-over backups too) that would the username & password thing ... if a user was verified this server would respond with an access token as well as an ip address and port number for the client to connect to for the actual service ... the server they log on to gets sent the access token from the client which it then tries to verify with the authentication server
hope thats clear enough (was at a party last night) ... not saying its the best way to do things but it worked
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Hello, the codegurus around the world.;)
Hum, this question sounds like IM Messenger.
Actually, I used to make Client\Server application on my school project for a long time ago.
And I enhanced Server can access Access Database. (but, not thread safe. )
That is, the client types user id and password, and server queris these from Access database.
So, now I have an idea to enhance this application to IM Messenger.
So, Central Server gets the dynamic IP address and port number if the user login Internet.
And these data goes to SQL Server.
So, acutally, the user's client application includes the server program to commnicate to
the other client machine.
This sounds like COOL.
I guess that Napster uses the same concept.
However, Gulant(?) uses the multicase approaches to find the client.
This is more cool, isn't this. More .
This is mainly because Culant doesn't need the central server.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
the reason we had a central server was for authentication services ... it allowed us to keep all authentication databases on a single safe server ... the load wasn't much as it only authenticated and then handed off to another server / port
we also used port switching if we detected an unauthorised connection ... we assumed it was an attack and instructed all clients to switch to other ports
worked quite well
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I'm trying to add MySql connectivity to my application, but i don't want to have to use ODBC. When i ad the mysql++ header file to my application i get these errors:
d:\development\sources\mysql++\mysql\include\mysql_com.h(115) : error C2146: syntax error : missing ';' before identifier 'fd'
d:\development\sources\mysql++\mysql\include\mysql_com.h(115) : error C2501: 'SOCKET' : missing storage-class or type specifiers
d:\development\sources\mysql++\mysql\include\mysql_com.h(115) : error C2501: 'fd' : missing storage-class or type specifiers
I include winsock2.h but all that ends up doing is causing redefiniton errors in the rest of the app. I was able to find a way to get it to compile, but whenever I try to use a certain class i get this:
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char=""> >::~basic_ios<char,struct std::char_traits<char=""> >(void)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined
in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: virtual __thiscall std::basic_iostream<char,struct std::char_traits<char=""> >::~basic_iostream<char,struct std::char_traits<char=""> >(void)" (??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ) a
lready defined in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_iostream<char,struct std::char_traits<char=""> >::basic_iostream<char,struct std::char_traits<char=""> >(class basic_iostream<char,struct std::char_traits<char=""> >::basic_streambuf<
char,struct std::char_traits<char> > *)" (??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z) already defined in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char=""> >::~basic_streambuf<char,struct std::char_traits<char=""> >(void)" (??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ
) already defined in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >(void)" (??1?$basic_strin
g@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in mysql++.lib(connection.obj)
libcp.lib(locale.obj) : error LNK2005: "public: __thiscall std::_Locinfo::_Locinfo(char const *)" (??0_Locinfo@std@@QAE@PBD@Z) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(locale.obj) : error LNK2005: "public: __thiscall std::_Locinfo::~_Locinfo(void)" (??1_Locinfo@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(locale0.obj) : error LNK2005: "public: class std::locale::facet const * __thiscall std::locale::_Getfacet(unsigned int,bool)const " (?_Getfacet@locale@std@@QBEPBVfacet@12@I_N@Z) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(locale0.obj) : error LNK2005: "public: bool __thiscall std::locale::_Iscloc(void)const " (?_Iscloc@locale@std@@QBE_NXZ) already defined in msvcprtd.lib(MSVCP60D.dll)
etc...
Has anyone found a way around this bug(?)?. Could suggest a better way to manage a database without using
mySql. I can't use Access so don't suggest it. Thanx in advance.
Stephen Caldwell
Desick Information Technologies
|
|
|
|
|
use msde
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Hello, the codegurus around the world.;)
What is MSDE?
Just kidding.
As far as I know, MSDE only works for the test on Client machine.
So, I guess that we can't use MSDE as SQL Server does on Window NT Server.
One more thing.
Don't update to the beta of SQL 2000 from MSDE CD
This overwrites ADO library, so we must rewrite the code.
If we have VC++, we can get this free MSDE CD.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
As far as I know, MSDE only works for the test on Client machine. So, I guess that we can't use MSDE as SQL Server does on Window NT Server
MSDE runs on both Win NT workstation and Server, and is 100% compatible with Sql Server 7.0...
Is is a Sql Server 7.0, just with some performance limitations.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hello, the codegurus around the world.;)
You're right partly.
I mean that the client can't access MSDE through the network, can it?
If MSDE works as SQL Server, we don't need to buy SQL Server at all.
MSDE is only the test Database server if the developer makes a test for his or her code to
the client enviornment. (127.0.0.1).
So, MSDE works on Window NT server, but this is only for the local host enviornment.
If i am wrong, I'm happy since I don't need SQL Server at all.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
You are wrong...
MSDE is not for test... On the MSDE CD there is a Sql Server 7.0 Developer Edition, that you can use for test. MSDE is for production.
It works perfectly over network, just as the "real" SQL Server.
But, when more than 10 clients is connecting to MSDE at the same time, it starts to get way slower than the "real" Sql Server.
If you only are 5 persons in a business, there is NO difference in the use of MSDE and Sql Server... (except that there are no admin tools installed when you install MSDE)
Trust me, I know MSDE as we use it on some of our solutions...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
hey anders
where did you get the info about slow-down after 10 users? we use msde in production too (thats how come i knew masaaki was in error too) ... and i would like to know some definitive source of info (if there is one) thats states the 10 user issue so i can give reasons for some of our clients to foot the upgrade bill if required
thanks
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
|
I have a CHtmlView based app. How can I detect when the app creates a download file dialog? I would also like to get the url of the file it is trying to download.
Thanks in Advance
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Hello,
I was wondering if someone could point me to the documentation that describes what DATA specific MESSAGES pass to there call back functions.
Example:
A ListCtrl has the message of NM_CLICK. It gets mapped to a fucntion like this
CMyDialog::OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
Now How in the hell am I supposed to know what type of data pNMHDR is pointing to?
I guesse it is pointing to a LPNMITEMACTIVATE, but the only reason I know this is becuase i found it in someones code, not in any documentation.
This question is not focused on a CListCtrl. Im talking about any MFC contro;. What are the are there passed arguments pointing to??
Is there documentation on this? Am i just blind and its right in front of me?
Any Help would be appreciated.
Thanks.
|
|
|
|
|
How in the hell am I supposed to know what type of data pNMHDR is pointing to?
You just read the docs on the message in question. Enter "NM_CLICK" into the MSDN Index page, and you'll see a few entries. Select "NM_CLICK (list view)".
As for how the parameters get passed to the OnClickList() function, MFC handles the raw WM_NOTIFY message, unpacks the parameters (from wParam and lParam), looks up your handler in the class's message map, and calls the handler.
--Mike--
http://home.inreach.com/mdunn/
Tables, ladders, chairs, OH MY!
|
|
|
|
|
I have a problem with ExitWindowsEx. AFAIK, using EWX_SHUTDOWN with that API function causes the system to shut down, right? Well, what happens is that the system logs off!!!!!!!!
My computer shuts down normally when I choose shut down from the start menu and restarted normally by setup programs.
What is going on???
Thanx
|
|
|
|
|
I was able to solve my own problem. Thanx anyway.
*Obsolete*
I'm creating a multithreaded server application using winsock. So far everything works well except when i try to send data to the client. I get a WSAEINVAL(10022) error on the Send() function. Here's the code:
UINT PASCAL CLJFileServer::ListenProc(LPVOID *pParam)
{
CLJFileServer *pThis;
pThis = (CLJFileServer*)pParam;
if (!pThis)
return 1;
CTimeoutSocket* pClient = NULL;
CTimeoutSocket* pListen = new CTimeoutSocket();
int nLoopCount;
while (!pListen->Create(pThis->m_uPort))
{
Sleep(LJFS_TIMEOUT);
nLoopCount++;
if (nLoopCount > LJFS_SOCKET_RETRY)
{
pThis->m_hListen = NULL;
pThis->StartListening();
return 1;
}
}
pListen->Listen();
while(pThis->m_bStop != true)
{
if (pClient)
delete pClient;
pClient = new CTimeoutSocket;
pListen->SetTimeout(LJFS_TIMEOUT);
int bAccepted = pListen->Accept(*pClient);
if (bAccepted)
{
pThis->SendAck(pClient);
if (pThis->m_uServerType == LJFS_LISTEN)
pThis->Login(pClient);
else
pThis->ForwardConnection(pClient);
}
}
if (pClient)
delete pClient;
pListen->Close();
delete pListen;
pThis->m_hListen = NULL;
return 0;
}
void CLJFileServer::SendAck(CTimeoutSocket *pClient)
{
//pClient->Bind(LJ_FSPORT);
TRACE("Error No: %d", GetLastError());
if(m_uServerType = LJFS_LISTEN)
{
pClient->Send((void*)LJ_LOGINACK,sizeof(LJ_LOGINACK));
TRACE("Error No: %d", GetLastError());
}
else
pClient->Send((void*)LJ_METASERVER,sizeof(int));
}
Thanx for your help in advance.
Stephen Caldwell
Desick Information Technologies
|
|
|
|
|
Bonjour! when i try to define a CArray as a static class member i get a link error. what's the problem, and how can i solve it? thx
derhackler
|
|
|
|
|
Please provide error description (or source of your class) to give us the idea of your problem.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
this is the code of the header file:
#include <afxtempl.h>
class CPropertyList
{
public:
CPropertyList();
virtual ~CPropertyList();
public:
static CString fnGetADsProperty(int intArg);
static CString fnGetADsProperty(CString cstrArg);
static int fnGetIntProperty(CString cstrArg);
static CString fnGetProperty(int intArg);
static CString fnGetProperty(CString cstrArg);
//Statische members
static CArray<cstring,cstring&> cstraProperty;
static CArray<cstring,cstring&> cstraADsProperty;
static CArray<int,int> intaProperty;
};
this ist the error i get (for each CArray)
PropertyList.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: static class CArray<class cstring,class="" cstring="" &=""> CPropertyList::cstraProperty" (?cstraProperty@CPropertyList@@2V?$CArray@VCString@@AAV1@@@A)
any ideas?
derhackler
es ist wie es ist und es ist und es ist fürchterlich
|
|
|
|
|
CArray is the template class - so you need to provide template parameters!
Like that:
class CPropertyList
{
...
static CArray<cyourclass, cyourclass&=""> cstraProperty;
static CArray<cyourclass, cyourclass&=""> cstraADsProperty;
static CArray<cyourclass, cyourclass&=""> intaProperty;
};
and your always must define static variables (the code above is the declaration only!):
this code your should place out of class declaration! (most of us placing this in CPP file :
CArray<cyourclass, cyourclass&=""> CPropertyList::cstraProperty;
.. the same for others static members.
Hope it'll help.
#include
class CPropertyList
{
public:
CPropertyList();
virtual ~CPropertyList();
public:
static CString fnGetADsProperty(int intArg);
static CString fnGetADsProperty(CString cstrArg);
static int fnGetIntProperty(CString cstrArg);
static CString fnGetProperty(int intArg);
static CString fnGetProperty(CString cstrArg);
//Statische members
static CArray cstraProperty;
static CArray cstraADsProperty;
static CArray intaProperty;
};
this ist the error i get (for each CArray)
PropertyList.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: static class CArray CPropertyList::cstraProperty" (?cstraProperty@CPropertyList@@2V?$CArray@VCString@@AAV1@@@A)
any ideas?
derhackler
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
CArray is the template class - so you need to provide template parameters!
Like that:
class CPropertyList
{
...
static CArray<cyourclass, cyourclass&=""> cstraProperty;
static CArray<cyourclass, cyourclass&=""> cstraADsProperty;
static CArray<cyourclass, cyourclass&=""> intaProperty;
};
and your always must define static variables (the code above is the declaration only!):
this code your should place out of class declaration! (most of us placing this in CPP file :
CArray<cyourclass, cyourclass&=""> CPropertyList::cstraProperty;
.. the same for others static members.
Hope it'll help.
ps: just've seen your post on codeguru
#include
class CPropertyList
{
public:
CPropertyList();
virtual ~CPropertyList();
public:
static CString fnGetADsProperty(int intArg);
static CString fnGetADsProperty(CString cstrArg);
static int fnGetIntProperty(CString cstrArg);
static CString fnGetProperty(int intArg);
static CString fnGetProperty(CString cstrArg);
//Statische members
static CArray cstraProperty;
static CArray cstraADsProperty;
static CArray intaProperty;
};
this ist the error i get (for each CArray)
PropertyList.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: static class CArray CPropertyList::cstraProperty" (?cstraProperty@CPropertyList@@2V?$CArray@VCString@@AAV1@@@A)
any ideas?
derhackler
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|