|
Hi,
How could I change the CMFCPropertyGridCtrl Property Column or Value column width?
a sample code would be more useful
|
|
|
|
|
How do you do a extern type declaration for this. At link time I get unresolved external symbol "public: static void__cdecl etc. etc.
I'm trying to expand my use of C++ to envelop static functions inside of classes as a way to help organize the code a bit better.
|
|
|
|
|
this worked for me:
class A
{
public:
static void g(int)
{
int i = 0;
}
};
typedef void (*fp)(int);
int _tmain(int argc, _TCHAR* argv[])
{
fp p = A::g;
p(1);
return 0;
}
|
|
|
|
|
class MyClass
{
static INT m_i;
};
__declspec(selectany) INT MyClass::m_i;
or
INT MyClass::m_i;
cheers,
ARWhen the wise person points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Static member functions usage:
MyClass.h:
class MyClass
{
public:
static int fcn( int param );
static int inlineFcn( int param) )
{
};
};
MyClass.cpp:
#include "Myclass.h"
int MyClass::fcn( int param )
{
}
Client.cpp:
#include "Myclass.h"
void clientFcn( int a, int b )
{
int c = MyClass::fcn( a );
int d = MyClass::inlineFcn( b );
}
It sounds to me that another approach might be more suitable for your purposes. I'll post that next.Please do not read this signature.
|
|
|
|
|
Alan Kurlansky wrote: a way to help organize the code a bit better
It sounds to me like you want the organization, but what you are doing is not truly about classes and object orientation. There is another facility in C++, namespaces, that may be more appropriate for your current use. It organizes things in groups and helps avoid naming conflicts, but does not raise the "object" expectations of someone reading your code.
In some ways using namespaces looks a lot like what I posted for static member functions.
This is how you might use namespaces:
Group.h:
namespace Group
{
int fcn( int param );
inline int inlineFcn( int param) )
{
};
}
Group.cpp:
#include "Group.h"
namespace Group
{
int fcn( int param )
{
}
}
Client.cpp:
#include "Group.h"
void clientFcn( int a, int b )
{
int c = Group::fcn( a );
int d = Group::inlineFcn( b );
}
AlternateClient.cpp:
#include "Group.h"
using namespace Group;
void altClientFcn( int a, int b )
{
int c = fcn( a );
int d = inlineFcn( b );
} Please do not read this signature.
|
|
|
|
|
Yes, organization is what I'm looking to do in this case. This looks good. I'll give this a try. Thanks
|
|
|
|
|
Good luck. I hope it works well for you.
I will add a note about style. My example showed indenting a level inside the namespace definitions, just like you would do for any other pair of {}'s. There are style guidelines that recommend not doing so for namespaces. I'm undecided about this myself.Please do not read this signature.
|
|
|
|
|
Thanks. This looks good. I'll give it a try.
|
|
|
|
|
I was reading http://www.cplusplus.com/doc/tutorial/pointers/
I understood most of what they were saying, so I chose to write my own code and comment what I have done to remember it in the future, but then its starts getting confusing near "Pointers and arrays" can anyone point out some simpler code for me to understand, so far this is the last thing I created::
#include "stdafx.h"
#include < conio.h >
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int fI = 3, sI = 2, tI = 1;
int * p1, * p2, * p3;
p1 = &fI;
cout << p1 << ": ";
*p1 = fI;
cout << *p1 << endl;
p2 = &sI;
cout << p2 << ": ";
*p2 = sI;
cout << *p2 << endl;
p3 = &tI;
cout << p3 << ": ";
*p3 = tI;
cout << *p3 << endl;
_getch();
return 0;
}
|
|
|
|
|
|
Herboren wrote: ...can anyone point out some simpler code for me to understand...
See here."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
|
|
|
|
|
Hi,
Does anyone know what settings I have to change in vc++, for it to allow for the use of the "Decimal" data type as opposed to float or double?
Thanks
|
|
|
|
|
C++ doesn't have a "Decimal" data type.
there are plenty of decimal classes out there on the net, though. google...[^]
|
|
|
|
|
There is no such setting - decimal floating points are not supported natively by C++ compilers.
Having said that, there are library solutions. Intel® Decimal Floating-Point Math Library[^] deserves taking a look at.
|
|
|
|
|
I was interested in checking this out but I keep hitting a brick wall when I try to download it. Did you get this to download from the intel website? What is the trick to getting it to do anything after you accept the license agreement?
*Update*
Never mind, I figured it out.
thanksmodified on Thursday, March 18, 2010 9:09 AM
|
|
|
|
|
DECIMAL is a struct defined in Wtypes.h, the (commented out) simple definition is:
typedef struct tagDEC
{
USHORT wReserved;
BYTE scale;
BYTE sign;
ULONG Hi32;
ULONGLONG Lo64;
} DECIMAL;
So it can represent a signed 96 bits integer with fixed decimal point.
OleAuto.h provides methods to transfer values from C++ numeric types to/from decimal structs such as WINOLEAUTAPI VarR8FromDec( const DECIMAL *pdecIn, DOUBLE *pdblOut); (converts a DECIMAL to DOUBLE) and WINOLEAUTAPI VarDecFromR8(DOUBLE dblIn, DECIMAL *pdecOut); (converts a DOUBLE to DECIMAL);
To use it include Wtypes.h and OleAuto.h, for arithmetic on DECIMAL use the VarDecXXX() functions described at http://msdn.microsoft.com/en-us/library/ms221612.aspx[^].
cheers,
ARWhen the wise person points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Hi
How to convert CString to char#sanroop#
|
|
|
|
|
char a = myString.GetAt(0);
|
|
|
|
|
CString may have more than one character stored in its internal string array. How do you expect to "convert" it to a char ?!
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
hello
i want to define a vector with three or more parameter in space and as i know vector of stl only gets one parameter ,is there any header in stl or other library to solve this?
also i have an array of points and i want to sort them on one axis ,how i can sort it with sort() of stl without any change to points?
for example i used map for 2 dimension :map<int,int> but when i set for example 11,12 11,13 it is false.
thanks in advance.
|
|
|
|
|
struct point3D
{
double x;
double y;
double z;
};
std::vector<point3D> my_vector_of_points;
?
bool sortOnX(const point3D& a, const point3D& b)
{
return a.x < b.x;
}
std::sort(my_vector_of_points.begin(), my_vector_of_points.end(), sortOnX)
|
|
|
|
|
|
Hi,
How could I change the
CMFCPropertyGridCtrl Property or Value column width?
a sample code would be more useful
|
|
|
|
|
somehow late, but here you are:
class CMyPropertyGridCtrl : public CMFCPropertyGridCtrl
{
public:
int SetFirstColumn(int iwidth){ m_nLeftColumnWidth = iwidth;
AdjustLayout();return 0;};
};
...
{
...
CMyPropertyGridCtrl blah;
int iwidth;
blah.SetFirstColumn(iwidth);
...
}
...
|
|
|
|