|
very good article Nemanja Trifunovic
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Does anyone know a free C++ .NET complete tutorial in English or Italian? Note that I already develop with the other .NET languages...
Thanks for sugestions.
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
|
The website doesn't work!!!
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
Now it works! Thanks
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
I'm writing a project and in that project I have a class named user_info that represent
information about users. I have another class named user_list, that represent a list of
users, and use CObLis. The information that I place in the list I want to save on disk,
so i use for that serialization. The problem is that when I want to save the information,
than the program crash.
This is the header of user_info:
#include <iostream.h>
// replace with #define _CONSOLE when compiling for Windows NT
#define _DOS
#include <afx.h>
class user_info : public CObject
{
DECLARE_SERIAL(user_info)
public:
user_info();
user_info(CString suser_name,CString spassword,int suser_id,CString sname,CString sfamily_name,int suser_type,int scity_id,int sarea_id,int sonline=0);
virtual ~user_info();
// user_info() {}
user_info( const user_info &s ) // copy ctor
{ user_name = s.user_name;
password = s.password;
user_id = s.user_id;
family_name = s.family_name;
user_type = s.user_type;
city_id = s.city_id;
area_id = s.area_id;
online = s.online;
}
user_info& operator=( const user_info &s ) // assignment operator
{ user_name = s.user_name;
password = s.password;
user_id = s.user_id;
family_name = s.family_name;
user_type = s.user_type;
city_id = s.city_id;
area_id = s.area_id;
online = s.online;
return *this;
}
CString get_user_name();
CString get_password();
int get_user_id();
CString get_name();
CString get_family_name();
int get_user_type();
int get_city_id();
int get_area_id();
int get_statuse();
void test_list();
void Serialize (CArchive& ar);
private:
CString user_name;
CString password;
int user_id;
CString name;
CString family_name;
int user_type;
int city_id;
int area_id;
int online;
};
This is the implication of the Serialize method in the user_indo.cpp file:
IMPLEMENT_SERIAL(user_info, CObject, 0)
void user_info::Serialize(CArchive& ar)
{
CObject::Serialize (ar);
if (ar.IsStoring())
ar << user_name << password << user_id << name << family_name << user_type << city_id << area_id << online;
else
ar >> user_name >> password >> user_id >> name >> family_name >> user_type >> city_id >> area_id >> online;
}
This is the implication of the constructor of user_list:
user_list::user_list()
{
char* FileName="user_list.dat";
user_list::numOfUsers =0;
if (users_file.Open (FileName, CFile::modeRead))
{
CArchive ar (&users_file, CArchive::load); // construct
users.Serialize (ar);
ar.Close(); // destruct
users_file.Close();
}
}
This is the method that save the information to the disk:
void user_list::saveUsers()
{
char* FileName="user_list.dat";
user_info* user;
if (users_file.Open (FileName,
CFile::modeCreate | CFile::modeWrite))
{
CArchive ar (&users_file, CArchive::store); // constr
users.Serialize (ar);
ar.Close();
users_file.Close();
}
pos = users.GetHeadPosition();
do
{
if (pos == NULL) break;
user = (user_info*)users.GetNext(pos);
delete user;
} while (true);
users.RemoveAll();
}
The program crash at this method at the line ' users.Serialize (ar);'.
Can any one tell me what could be the problem?
Thanks in advance,
Chen
|
|
|
|
|
Hi All:
This is a newb question for OpenGl but I don't see an OpenGl section so I did what was closest. I have OpenGl ES that I am going to be running on a PocketPc. I'm writing it in C++ and I am sure it has a lot of similarites to the normal OpenGl. Does anyone know how to import models (i.e people, cars, etc.) into an OpenGl environment? Also, how does one do large terrains in an openGl environment?
Sincere regards,
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
Hello all,
i've a problem to calling this SIMD(in c++) instruction from the VB6,i've upgrade my visual studio from to SP5.when i'll try to calling this function from vb, the application is shutdown and when i debug this message appear :
" unhandled exception in VB6.EXE(f.dll): 0XC0000005 : Access Violation".
is it the way i call the dll is wrong or i must use another method to calling this function from vb. thanks.
void _stdcall ssetest(float *arr1,float *arr2,float *result,int size)
{
int i;
int loop;
loop=size/4; //long number= 32bit
__m128* Rslt = (__m128*) result;
__m128* a1= (__m128*) arr1;
__m128* a2= (__m128*) arr2;
for(i=0;i
|
|
|
|
|
Hello,
How can I convert const char* to LPCTSTR?
I tried to use WideCharToMultiByte so that I could have a LPCWSTR then convert to LPCTSTR but
the value of LPCWSTR(pdbfilename) on watch during breakpoint at line 9 is "???". (see code below)
1 HANDLE
2 fCreate(const char *fname, UInt32 access, UInt32 shared, UInt32 create, UInt32 attrib, Err *r_)
3 {
4 Err r = errNone;
5 HANDLE handle = NULL;
6 LPSTR holder=(LPSTR)fname;
7 LPCWSTR pdbfilename;
8 WideCharToMultiByte(CP_OEMCP, WC_DEFAULTCHAR,pdbfilename, -1,holder,strlen(fname),NULL, NULL);
9 handle = CreateFile(pdbfilename, access, shared, NULL, create, attrib, NULL);
10 if(handle == INVALID_HANDLE_VALUE)
r = ERR_FILE_CREATEOPENFAILED;
11 if(r_ != NULL)
12 *r_ = r;
13 return handle;
14 }
Is there something wrong with my WideCharToMultiByte API call?
Is there other way to convert const char* to LPCTSTR?
Thanks and more power.
|
|
|
|
|
I thought LPCTSTR WAS a char * ? Anyhow, the easiest way to convert is to use the _bstr_t class, which is a string class that returns wide and narrow strings automagically.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian,
Actually, the function belongs to a library and so the library is restricted to plain C so that it will be portable because I'am developing under Pocket PC environment.
Let me rephrase the question, on EVC4 LPCTSTR is unsigned short*, my first parameter (fname) is const char*, so how can i convert const char* to unsigned short*?
Thanks a lot Christian,
Fjlv2005
|
|
|
|
|
OK, if you want to do it in C, _bstr_t won't help, it's a class. However, it just calls the API function that you're trying to call now, anyhow. You could check it's source to see if it differs from your syntax.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ok I'll just check the API.
Thanks and Have a nice day.
|
|
|
|
|
Have a look at the macros like A2CT, use MSDN "String Conversion Macros".
That was VC6, with VC7 their name has changed a bit (to A2CTEX or something).
----------------------
~hamster1
|
|
|
|
|
Hi everybody,
Since I have no experience in C++ I request your help. I created a C# app that will be installed from a CD-ROM; I used the .NET bootstrapper plug in to install the framework if it hasn't been installed yet.
I need to provide an autorun for the CD-ROM; but... the CD will not only be used for the installation of the program, but also for the normal use of the program. So I need the autorun to check whether the application has been installed, if not than run setup.exe; if yes, don't do any autorun.
Can somebody point me to some freeware program that does this for me, or to some other good resources (keeping in mind that I don't really know C++).
Thanks a lot.
Gidon
|
|
|
|
|
|
You can add to cd a file autorun.inf
file looks like:
[autorun]
open=edgeofchaos.exe
icon=edgeofchaos.exe,0
You can change, and you can try to write your ouwn program, to check if it is installed, if not then run setup.exe
or just use this autorun maker
http://www.indigorose.com/ams/index.php[^]
ps: Managed c++ has a little difrance than C#, if you program MC++ you can easly turn to C#
|
|
|
|
|
let's say i have a class like this:
class a
{
private:
char name[10];
.
.
.
}
how do i give 'name' a value in the constructor?
chen.
|
|
|
|
|
name = {"10 chars long"};
OR
name = new char[10];
::strcpy(&name[0], "value"); // going from memory, args could be the wrong way around
If you use the second method, don't forget to release memory in the destructor. If you use the first, don't change the value of the string, which means it should be const. Overall, you'd do better to use a string class to hold the value, if practical.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If you get the name from the outside, go with this:
<br />
class a( const char* a_name) {<br />
strcpy(name,a_name);
}<br />
However, if you know the name at compile time already, simply hard-code it - gives more speed and security.
<br />
class a {<br />
const char* get_name() const { return "blabla"; }<br />
}<br />
----------------------
~hamster1
|
|
|
|
|
Instead of using a char array, consider a string class:
class a
{
private:
std::string name;
.
.
.
};
And then a constructor may look like:
a::a(const char* yourName) : name(yourName)
{}
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
-- modified at 8:32 Tuesday 30th August, 2005
|
|
|
|
|
There is a possible memory leak
<pre>private: System::Void btnButton_Click(System::Object *sender, System::EventArgs *e)
{
frmTest *frm = new frmTest(); // Create new Form
frm->ShowDialog(this); // Show
}</pre>
and i have defined destructor of that form
<pre>~frmTest
{
MessageBox::Show(S"Destructor Called");
}</pre>
When i run this app, i click button many times, and no destructor called. when i close main form, destructor is called only once.
so i have add:
<pre>delete frm; // To be safe.</pre>
is this a memory leak?
thanks in advance.
|
|
|
|
|
No, frm is created on managed heap, which is controlled by GC. In general, with managed code, you should worry more about leaking non-memory resources.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Hai
In my applcation i want to list all machines in the network.
So i used the WNetOpenEnum API .
My code looks like,
[DllImport("Mpr.dll", EntryPoint="WNetOpenEnumA", CallingConvention=CallingConvention::Winapi)]
static ErrorCodes WNetOpenEnum(ResourceScope dwScope, ResourceType dwType, ResourceUsage dwUsage, NETRESOURCE* p, IntPtr &lphEnum);
NETRESOURCE* pRsrc = new NETRESOURCE(); //A managed class
IntPtr handle = IntPtr::Zero;
result = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, RESOURCEUSAGE_ALL, pRsrc, handle);
But when i run the application got an error
" Can not marshal parameter #4: The type definition of this type has no layout information. "
Whats is the problem.
Plz help
|
|
|
|
|
Hello...
I believe you forget to define the StructLayoutAttribute for the paramater NETRESOURCE* p...
In general it'S Sequential...
|
|
|
|
|