|
im getting a bit confused now!
to further exlpain. i have a basic MFC dialog app that was created using the wizard. i want to connect to a database and execute querys, i am using a wrapper for this (mysqlwrapp). to make an object of the dbconnection class i use the following in a method that is invoked by a click of a button.
CSQLConnection m_conn; //create object
m_conn.Open(_T("localhost"), _T("salaries"), _T("root"), _T("root")); //connect
then in another method i want to execute the following, but it cant see the m_conn object. this new object allows querys to database
CSQLResult res(m_conn);
res.Query(_T("SELECT Name FROM house"));
to create these objects the "MySQLWrapp.h" is included in the dialog where the objects are created and used.
so what is the best way to make the m_conn object global. could you please give example code on where and how as most of this is new to me. thanks
|
|
|
|
|
The "m_" wart is normally used to denote a class member variable and not a local variable as you’re using it. Follow these steps:
1. Remove the CSQLConnection m_conn; from the function.
2. Add it to your class definition. i.e.
class CYourDialog : public CDialog
{
public:
protected:
private:
CSQLConnection m_conn;
};
Notice I added the member variable as private , this is good form - As a rule of thumb always apply the most restrictive access permissions possible. You can always relax them later if need be.
Now you can access the variable "m_conn" anywhere in that class. It's not a global however as it can't be accessed from other classes or global functions.
Only use the "m_" wart on member variables (variables declared in the class definition) or else you'll confuse people.
Steve
|
|
|
|
|
|
hello,
how can i detect a hyperlink in word file?
thanks for any help
|
|
|
|
|
I'm trying to use the shell function SHGetPathFromIDList but not having luck constructing the first parameter properly. It requires an item identifier list and in my case, I'm needing the path to just the 'My Documents' folder. If someone can post an example or a link to an example that explains how to create this list with just that entry in it and how it's to be freed, if necessary, that would help me out. Thanks.
Chris Meech
I am Canadian. [heard in a local bar]
When I want privacy, I'll close the bathroom door. [Stan Shannon]
BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
|
Thanks Mike. That's going to work much better.
Chris Meech
I am Canadian. [heard in a local bar]
When I want privacy, I'll close the bathroom door. [Stan Shannon]
BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
Looks like Michael's answered your immediate question, but for future reference, here's some code that gets the Application Data folder - just change the CSIDL_COMMON_APPDATA to whatever you want.
CString strCommonDataStorageFolder;
LPITEMIDLIST pidl;
if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_APPDATA, &pidl)))
{
LPMALLOC lpMalloc;
if (::SHGetMalloc(&lpMalloc) == NOERROR)
{
TCHAR szPath[MAX_PATH];
if (SHGetPathFromIDList(pidl, szPath))
strCommonDataStorageFolder = szPath;
lpMalloc->Free(pidl);
lpMalloc->Release();
}
}
|
|
|
|
|
Thanks very much, Graham. The example you provided is exactly what I was after, but I'm also going to look into Mike's suggestion too. Appreciate the help.
Chris Meech
I am Canadian. [heard in a local bar]
When I want privacy, I'll close the bathroom door. [Stan Shannon]
BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
For some reason, when I compare two identical double values, its failing.
double val = func->GetValue() // returns a double
double val1 = func2->GetOldVal() // returns a double
if (val != val1)
doFooA()
else
doFooB().
In my case, val == val1, but its passing and calling doFooA(). I've tried 'if ( (double) val != (double) val1) )' and 'if ((float) val != (float) val1)'. Although I know the latter will lose precision, I"m trying anything.
Any ideas why this is happening?
TIA
-C
|
|
|
|
|
this is normal.
in short, a computer cannot store exact floating point numbers in memory; and will rely on an approximation.
That's why you'll see things like 10.00000001 or 9.9999999999
to compare 2 double ( or float ) numbers you need to check if the difference between them is smaller than a small value.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Is there an easy way to do this without subtracting one from the other? Maybe some fancy math function already built?
|
|
|
|
|
|
Not that I know of. I have a function called
bool DoublesAreEqual(d1, d2, tol)
{
if (fabs(d1 - d2) < tol)
return true;
return false;
}
which does the job. It has the added advantage of allowing you to test to the tolerance you want so if you only need to compare to 2 decimal places you can.
This is a holdover from ancient C days so there may be a better way to do it with operator overloading.
Any one else have a suggestion?
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Dave
|
|
|
|
|
Hi,
I am working on a project in win32 that involves multiple monitors.
Usually as soon we connect a new monitor, we would go the desktop properties, settings to extend the window desktop to the new monitor...
I want to do this through my program. My scenario is, the users connect and disconnect monitors on fly while executing my app. I dont want the users to go and manually extend the desktop for the monitors they plugin.
Any ideas...
Thanks in advance.
|
|
|
|
|
i have a shared directory with 40000 files and 11G. When using AutoCad to open a sigle file, it takes very long to open and sometimes it freeze.
OS => XP, win2000.
Win. Index service is on.
thanks.
|
|
|
|
|
|
how can i speed up when loading files? it's no sense that it takes so much times.
|
|
|
|
|
is it a C++/MFC programming question ? or an Operating System question ? or a General question ?
what takes a long time ? showing the file dialog or loading the file itself ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
open the file itself. it's not a programming issus
|
|
|
|
|
|
Wich are your machine specs? And AuctoCAD version? Besides, is it Windows XP or Windows 2000? =$
If you don't have much RAM memory, then having all those files on the same directory is not a good idea.. That's probably why it is crashing.
Also notice this is a Visual C++ / MFC forum.. Next time choose the appropriate forum for your posts.
regards [[]]
hint_54
|
|
|
|
|
i have a shared directory with 40000 files and 11G. When using AutoCad to open a sigle file, it takes very long to open and sometimes it freeze.
OS => XP, win2000
thanks.
|
|
|
|
|
|
I write a programm with C# and it's ok. But with Visual c++, I have the error: "include 'ATLComTime.h' not found. I add it in my project, but ich get new errors like the first one.
Why can i do to eliminate these errors?
Thank you.
Rick
|
|
|
|