|
|
I have minimize(-) button and close(x) button in caption bar. Here i have overidden those default button and created new one. Clicking on minimize,close button my application working fine. Even doing well on system menu also. when i click on task bar button it is not minimizing.
|
|
|
|
|
Hello,
I declared a function in C++ "palloc":
void *palloc(long sz, long no)
{
long size;
void *p;
size = sz * no;
if (size == 0) size = 1;
p = (void *) malloc(size);
if (p == NULL) error("no memory size %ld", size);
return p;
}
and in another function I call this function like:
void initfirst(allinfo *a, stype ps, stype ws)
{
state *k;
a->d.set1 = palloc(MAXSTATES, sizeof(state));.......}
but I don't know why it give me an error:
Error 9 error C2440: '=' : cannot convert from 'void *' to 'state *'
Can you help me.... ?
lavinia
|
|
|
|
|
In C, it's legal to assign a void* to another pointer type without a cast, but in C++ you must use a cast.
|
|
|
|
|
can you give me an example... please because I don't know how to do it....
lavi
|
|
|
|
|
palloc() returns void* , so you need to add a cast to the type of the variable that you're assigning to. In this case, you need a cast to state*
|
|
|
|
|
a->d.set1 = (state *) palloc(MAXSTATES, sizeof(state));
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks a lot...it's working
lavi
|
|
|
|
|
Hi
How can I declare static variables in visual c++.Because when I declared as public it gave linking errors.When I declared as "private static int x" and use it in a method like "public int func(){return (x);}" again it gave linking errors(error LNK2019 and fatal error LNK1120).Is there someone who knows the answer?
Thanks
|
|
|
|
|
iayd wrote: Because when I declared as public it gave linking errors.
Was it declared in a .h or a .cpp file?
iayd wrote: When I declared as "private static int x"...
But did you also define it?
iayd wrote: ...again it gave linking errors(error LNK2019...
It might help to specifiy that you are using VS2003 or VS2005.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
It's not a problem with public or private. You need to define the static variable again in the implementation file (.cpp)
Eg:
yourclass.h:
class yourclass
{
static bool test;
}
yourclass.cpp
bool youclass::test;
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
VuNic wrote: You need to declare the static variable again...
Technically, that's called defining.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
OOPs!
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Thanks
you are right .
|
|
|
|
|
Dear friends, i am currently working on a module which lists the IP address of all the active systems in a LAN. The process continuously runs and updates the IP addresses(in case logged in or log out). I have used timer to update it. Now i need to check if a remote system is logged in or not. So if you know please do tell me what should be done to check if a remote system is logged in.
Thank you(in anticipation)
Shalumalu
|
|
|
|
|
ShaluMalu wrote: So if you know please do tell me what should be done to check if a remote system is logged in.
Is NetServerEnum() of any help?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
client=accept(serv,(struct sockaddr*)&frm,&frmlen);
This line gets the client that connects from a remote machine.
Now how do we know from which machine did that connect? How do we get the machine name or IP address. Is there any function that gets in the SOCKET as input and returns IP address or Name?
----------------------------
286? WOWW!
|
|
|
|
|
_8086 wrote: Now how do we know from which machine did that connect?
client = accept(serv, (struct sockaddr *) &frm, &frmlen);
char *clienthost = inet_ntoa(frm.sin_addr);
int port = ntohs(frm.sin_port);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks David.
----------------------------
286? WOWW!
|
|
|
|
|
Hello All,
I read strings from file and want to convert that String to int (enum value)
Example:
CString str = "ABCD";
I want output to be:
int i = ABCD;
Is it a valid conversion?? Can it be done? If yes, could you please provide me an example?
Thanks.
|
|
|
|
|
are you serious ???
since when ABCD is an integer ?
unless you have an hexadecimal value maybe ?
please explain your question more, because it is not clear enough to get valuable help
|
|
|
|
|
when I read the file, i get CString token returns "ABCD" with myfile.NextArgument()
I want to convert that CString token to enum value ABCD.
|
|
|
|
|
can you show the definition of your enum please ?
also, show some lines of the file you read
|
|
|
|
|
typedef enum PROP_VALUES
{
PROPULSION,
ENGINES,
MOTORS
DIESEL
};
struct ENG_Data
{
CString name;
int eng_num;
PROP_VALUES mode;
};
ENG_Data eng[10];
File has entries like the following:
CTRL: 1, Vehicle, 23456, PROPULSION
CTRL: 2, Bikes, 12222, MOTORS
etc.
myfile.OpenTextFile(m_File);
while (myfile.GetNextCommandLine())
{
cmd= myfile.Command();
if (cmd== "CTRL")
{
int i = atoi(myfile.NextArgument());
eng[i].name = (myfile.NextArgument());
eng[i].eng_num = atoi(myfile.NextArgument());
eng[i].mode = (myfile.NextArgument())); <-------- This is one I want to convert to integer(enum value)
}
myfile.CloseTextFile(m_File);
|
|
|
|
|
Maximilien gave you the right answer. you cannot do like you asked. you must check using a if/else if series
|
|
|
|