|
char str[256];
is an array of characters (actually unsigned integers)
char *str = new char[256];
is a pointer to an array of characters stored in memory
this is mostly used in functions that take an output parameter.
|
|
|
|
|
In all the examples i have come across they use SystemParameterInfo() to set the wallpaper
but apparently that just doesnt work on my OS (Win M.E.)
i know how to set it in the registry but i just need a way to update it. anyone one know how?
|
|
|
|
|
Did you try setting the "fWinIni" parameter of SystemParametersInfo() to SPIF_SENDCHANGE ?
Bikram Singh
|
|
|
|
|
I wist to initialise some items in a structure, but the only way I can see to do it is as follows:-
typedef struct <br />
{<br />
char fieldDesc [100];<br />
char detailsDesc [20];<br />
char unitsStr [10];<br />
}GENERAL_DATA;<br />
<br />
typedef struct <br />
{<br />
unsigned short data;
GENERAL_DATA details;
}ITEM_DATA;<br />
<br />
ITEM_DATA thisItem;<br />
<br />
strcpy(thisItem.details.fieldDesc,"The field description");<br />
strcpy(thisItem.details.detailsDesc,"This is the details..");<br />
etc
Are they any way I can set the char data up in ITEM_DATA, or could I set the constant data up in a new structure:-
typedef struct <br />
{<br />
unsigned short data; <br />
char fieldDesc [100] = "This is a description";<br />
char detailsDesc [20] = "The details....";<br />
char unitsStr [10] = "$";<br />
}ITEM_DATA_01;
etc
The above does not work, but thats what I am after!
I know what data should go into the char fields in advance, but the only way I can see to load this constant data in is via a statement like
strcpy(thisItem.details.fieldDesc,"The field description");
Are they any other ways to load this constant data?
Graham.
grahamfff
|
|
|
|
|
Well you can always do
<br />
typedef struct yadda<br />
{<br />
yadda()<br />
{<br />
strcpy(fieldDesc,"This is a description");<br />
strcpy(detailsDesc ,"This is a description");<br />
strcpy(unitsStr ,"This is a description");<br />
<br />
}<br />
char fieldDesc [100];<br />
char detailsDesc [20];<br />
char unitsStr [10];<br />
}GENERAL_DATA;<br />
Then every new GENERAL_DATA variable will be initialized.
|
|
|
|
|
Thanks for the info, that solves the first problem.
But can you advise on how to use a union or other overlay method.
I just want to deal with a buffer when sending out the data, but deal with the structure itmes in the program; i.e. two names for the same item of data; see listing below
typedef struct yadda<br />
{<br />
yadda()<br />
{<br />
strcpy(fieldDesc,"This is a description");<br />
strcpy(detailsDesc ,"This is a description");<br />
strcpy(unitsStr ,"This is a description");<br />
<br />
}<br />
char fieldDesc [100];<br />
char detailsDesc [20];<br />
char unitsStr [10];<br />
}GENERAL_DATA;<br />
<br />
typedef struct <br />
{<br />
unsigned short data; <br />
GENERAL_DATA details;<br />
}ITEM_DATA;<br />
<br />
union DATA01<br />
{<br />
ITEM_DATA thisSignal;<br />
unsigned int buffer[512];<br />
}data01;
I get the error c:\Overlays\OverlaysDlg.cpp(48): error C2620: member 'SIGNAL1::thisSignal' of union 'SIGNAL1' has user-defined constructor or non-trivial default constructor.
Are they another method of overlaying the data.
grahamfff
|
|
|
|
|
If this is C++, you should add constructors to both struct 's to handle the initialization. If this is 'plain old' C (which I guessed might be the case, from your use of typedef ), you can try the following:
typedef struct
{
char fieldDesc [100];
char detailsDesc [20];
char unitsStr [10];
} GENERAL_DATA;
typedef struct
{
unsigned short data;
GENERAL_DATA details;
}ITEM_DATA;
static ITEM_DATA InitialItemData = {
1234,
{
"field description",
"detail",
"units"
}
}; Anywhere you need to initialize an ITEM_DATA , just assign it:
ITEM_DATA current_item;
current_item = InitialItemData;
Software Zen: delete this;
|
|
|
|
|
Thanks for the info and yes was for C code. Just two points, how would you do it for C++ and can you overlay the structure via union;
union DATA01<br />
{<br />
ITEM_DATA thisSignal;<br />
unsigned int buffer[512];<br />
}data01;
i.e. same data by two different names.
grahamfff
|
|
|
|
|
For C++, I would add a constructor. In C++, class and struct are the same except for one point. With struct , members have public access by default, while with class , the access is private by default. This means that a struct can have a constructor, and that's the place you should initialize the values.
You can initialize the union as follows:
data01.thisSignal = ItemDataInitial; where ItemDataInitial is an initialized ITEM_DATA as I described in the previous post. If you use a constant initializer for the union , it must correspond to the first field in it.
Software Zen: delete this;
|
|
|
|
|
Thanks for the info. I have started to use your scheme, or a varient of it.
Will use the union as follows:-
typedef struct
{
unsigned short data1;
}DATA1;
typedef struct
{
unsigned : 4 data2;
}DATA2;
etc
union ALL_DATA_UNION
{
DATA1 data1;
DATA2 data2;
etc
unsigned short buffer[50];
}ALL_DATA;
I need to transmit the buffer, but want all the data items 'overlayed' with the buffer. Dont need to initialise the union as can use memcpy to zero the buffer.
I will have another structure with the details of each item of data and initialise it as per your scheme.
Thanks again, but please point out if this scheme is fault.
Regards,
Graham
grahamfff
|
|
|
|
|
You can use constructor in your structure like this:
struct MyStructure<br />
{<br />
char blablabla[200];<br />
MyStructure()<br />
{<br />
strcpy(this->blablabla,"Testing");<br />
}<br />
}
|
|
|
|
|
Hai,
I'm doing an application in Win32 where I am creating a window dynamically.I want to know how to disable the minimize maximize and close buttons in the title bar of the window dynamically.Can anyone suggest?
Thanks a lot.
|
|
|
|
|
One solution is EnableMenuItem();
GetSystemMenu(FALSE)->EnableMenuItem(SC_SIZE, MF_ENABLED/MF_DISABLED);
Kuphryn
|
|
|
|
|
How can i get the notification in to my application, when the IP address changes..?
mind is everything.
|
|
|
|
|
Look at NotifyAddrChange() in MSDN. Part of the IP HELPER API, its available on Win2000+
Bikram Singh
|
|
|
|
|
Do you know how to set default web-site from C++ for IE and NetScape?
default web-site is called "Home page" also.
thx
includeh10
|
|
|
|
|
i think thats some registry settings..
u just set a URL as homepage in IE and search that string in registry
i hope that will work
mind is everything.
|
|
|
|
|
thx
good suggestion, i will test.
is a doc somewhere for this?
includeh10
|
|
|
|
|
Please give me an example/syntax of:
REFERENCE TO ARRAY OF 10 INTEGERS
Maybe it is very eazy but my super genius stops working for eazy questions... ...
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
int a[10];
void fn(int &a)
{
}
Jaime
|
|
|
|
|
I tried the same myself but i get a bad error WITH THIS....
int fn(int&a)
{
}
int main(int argc, char* argv[])
{
int abb[10];
fn(abb);
return 0;
} ERROR:
C:\Windows\Desktop\a\a.cpp(19) : error C2664: 'fn' : cannot convert parameter 1 from 'int [10]' to 'int &'
A reference that is not to 'const' cannot be bound to a non-lvalue
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
fn(abb[0]); // Get the address of the first cell, must work
Kochise
In Code we trust !
|
|
|
|
|
|
no... this is wrong... i am happy that markuk has given the corect answer. Take a look at his reply. thanx anyway
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
I'm too lazy to look this up from a C++ reference, so I'll let the computer answer:
$ c++decl
Type `help' or `?' for help
c++decl> declare a as reference to array 10 of int
int (&a)[10]
c++decl>
|
|
|
|