|
I have some directories/Folders that I placed on a zip drive to transport to another computer. When they are copied to the other computer they are "Read Only" I right-clicked on the folder, went to the properties iteem and selected it. It was set to Read Only. I changed that setting and selected sub-folders also and the progress bar began activity showing it was changing from read Only. after everything was complete I selected the "OK" buttons on all dialogs. I reselected that folder and openned the properties selection and it WAS SET TO READ ONLY again. How do you change this setting?
I also repeated all this under "Run as Administrator" but to no avail.
Help!(I'm running Vista OS on both machines)
A C++ programming language novice, but striving to learn
|
|
|
|
|
|
I have created the following class:
class variable {
public:
// The core data for a variable is an array of values
// Variable 0 will always be the error variable and
// variable 1 will always be the dependent variable.
string name;
bool isStochastic;
bool isDependent;
bool used;
bool isSeasDummy;
bool isKeeper;
double firstValue;
date firstDate;
double *values;
date *dates;
int time0;
int numTimes;
int fillRule;
bool hasLowerBound;
double lowerBound;
bool hasUpperBound;
double upperBound;
bool hasLeads;
int leads;
int lags;
bool keepAtStart;
variable() {
numTimes = -1;
used = false;
isStochastic = true;
isKeeper = false;
hasLeads = true;
};
// This constructor sets up a variable dynamically
// allocating the value and date arrays.
variable(int inTimes) {
values = new double [inTimes + 20];
dates = new date [inTimes + 20];
numTimes = inTimes;
isSeasDummy = false;
used = false;
isStochastic = true;
isKeeper = false;
keepAtStart = false;
hasLowerBound = false;
lowerBound = smallNumber;
hasUpperBound = false;
upperBound = bigNumber;
leads = 0;
lags = 0;
isDependent = false;
};
void insert(int inTime0, date inDate) {
for (time0 = numTimes; time0 > inTime0; time0--) {
values[time0] = values[time0 - 1];
dates[time0] = dates[time0 - 1];
};
dates[inTime0] = inDate;
if (fillRule == 0) {
values[time0] = 0;
};
if (fillRule == 1) {
values[time0] = values[time0 - 1];
};
if (fillRule == 2) {
values[time0] = values[time0 + 1];
};
if (fillRule == 3) {
values[time0] = (values[time0 - 1] + values[time0 + 1])/2;
};
if (fillRule == 4) {
if (values[time0 + 1] > values[time0 - 1]) {
values[time0] = values[time0 + 1];
}
else {
values[time0] = values[time0 - 1];
};
};
if (fillRule == 5) {
if (values[time0 + 1] > values[time0 - 1]) {
values[time0] = values[time0 - 1];
}
else {
values[time0] = values[time0 + 1];
};
};
numTimes++;
};
~variable() {
delete [] values;
delete [] dates;
cout << "got into variable destructor" << '\n';
};
};
Then I use the following code to create an array of variables:
variable *vars;
vars = new variable [numVars + maxInterventions + 1];
for (var0 = 0; var0 < numVars + maxInterventions + 1; var0++) {
vars[var0] = variable(completeTimes);
vars[var0].numTimes = numTimes;
};
Before I added the destructor, this code worked fine. However, now when the vars[var0] = variable(completeTimes);
statement is executed, it calls the destructor and destroys my array. Is there a way I can inhibit the use of the destructor? Or is there a way I can use the second constructor at the same time that I allocate the array?
|
|
|
|
|
Please, read the posting guidelines before posting (use the 'pre' or 'code' tags to format your code).
For your question: the problem is that when you copy your variable (by doing this: vars[var0] = variable(completeTimes); ), you create a copy of the first variable (which is a temporary one). The default behavior is that it will copy all the members as they are, so for pointers it will simply copy the address instead of allocating a new array. Thus, when the execution goes to the next line, your temporary variable (variable(completeTimes) ) gets destroyed and will delete its arrays. And as your other variable (vars[var0] ) only copied the address and not the content, these arrays are destroyed too.
In order to fix that, you have to provide a copy operator so that you can make a deep copy: you have to allocate new arrays instead of copying the address (don't forget to copy the other members too).
|
|
|
|
|
|
With all of the extraneous stuff removed, do you have something akin to the following?
class variable
{
public:
variable( void )
{
values = NULL;
}
variable(int inTimes)
{
values = new double [inTimes + 20];
}
~variable()
{
delete [] values;
}
variable &operator=( const variable &var )
{
return *this;
}
double *values;
int numTimes;
};
void main( void )
{
variable *vars;
int numVars = 5,
maxInterventions = 3,
completeTimes = 16,
numTimes = 7;
vars = new variable [numVars + maxInterventions + 1];
for (int var0 = 0; var0 < numVars + maxInterventions + 1; var0++)
{
vars[var0] = variable(completeTimes);
vars[var0].numTimes = numTimes;
}
}
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
|
Format your code using the <pre></pre> tags.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi guys,
I trying to extract blocks of a grayscale image. I have to divide my image into 64 blocks(think of it like placing a 8x8 grid on top of it, therefore each block size is image width/8 and image height/8.) Can someone show me a sample code about this?
modified on Thursday, November 20, 2008 10:15 AM
|
|
|
|
|
berko3000 wrote: Can somebody explain me what I'm doing wrong ?
Not following the posting guidelines
1/ No meaningful subject. *EVERYONE'S* posting wanting help.
2/ not using the formatting (pre) tag, to make your code readable.
Also, your code seems to have a bunch of } 's, but no } 's... This may well be a formatting issue (see #2 above. It's for your own good too)
Iain.
|
|
|
|
|
You also deleted the post with the code that Iain responded to or else edited your initial post. Makes it hard for anyone else following along later to figure what you needed or what Iain was referring to.
Dave.
|
|
|
|
|
Member 4194593 wrote: You also deleted the post
No I didn't! I am insulted sir!
Iain.
|
|
|
|
|
Iain,
Please forgive me, I accidentally attached the answer to your post, but the "you" was referring to the original poster. I was just heaping more scorn on the OP because the first post no longer contained the info on which you commented.
Dave.
|
|
|
|
|
Hi, I need to find the port of a printer (not the parallel port). I have code which uses GetProfileString, but I don't think this is how it's supposed to be done. Is there any API call which will do what this does?
The code I have:
#define MyAppPrinterName "MyAppPrinterName"
void CWordAddin::AppendPrinterPort( char* szOurPrinter )
{
char szPort[150]; GetProfileString("PrinterPorts", MyAppPrinterName, "", szPort, 150);
int i, j;
for (i=0; szPort[i] != '\0' && szPort[i] != ','; i++); i++;
for (j=0; szPort[i] != '\0' && szPort[i] != ','; i++, j++)
szPort[j] = szPort[i];
szPort[j] = 0;
strcat(szOurPrinter, szPort);
}
CComQIPtr <<Word::_Application>> app = button->GetApplication();
char printer_name[150] = MyAppPrinterName " on "; AppendPrinterPort(printer_name);
app->PutActivePrinter(printer_name);
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Thursday, November 20, 2008 7:52 AM
|
|
|
|
|
You can use EnumPrinters[^] to retrieve information about available printers. The GetProfileString [^]call you were making is an old function that was used to read the Win.ini file. In modern Microsoft operating systems this function actually reads/writes to the registry. Although the function has not been officially deprecated I would not personally use it.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hello,
I want my button to be clicked only once and not twice.
What to do.
Thanks In Advance.
Dhiraj
|
|
|
|
|
How about disabling the button after the first click?
|
|
|
|
|
actually what i want is that the user can only fire single click event and not double click.
That is my meaning of disabling actually the button is not disabled but double click should not do any thing. It should not change its state.
|
|
|
|
|
As far as i know -and please correct me anyone if i am wrong- if the user doubleclicks your button you will get a click event at first. So at the first click you won't be able to know if the user will doubleclick or just singleclick. To be more clear on this, when the user doubleclicks your button, you get 2 command messages from the button and you either want only one of these or if a doubleclick was done you don't want any command messages at all?
|
|
|
|
|
u can use PreTranslateMessage(MSG* pMsg) like this
BOOL [ur class name]::PreTranslateMessage(MSG* pMsg)
{
switch (pMsg->message)
{
case WM_LBUTTONDBLCLK:
pMsg->message = WM_LBUTTONDOWN;
break;
}
return 0;
}
|
|
|
|
|
Just add both a single-click handler and a double-click handler to the button, and do nothing for a double click.
|
|
|
|
|
or simply call the single-click handler from the double-click handler
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
He said he wants it to do nothing on a double click.
|
|
|
|
|
That is fine if that is what he wants. But I was thinking of the user who will start rapidly clicking the button only to find that every other click does not work as expected.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|