DdoubleD 315 Posting Shark

thanks worked great. I think it also had something to do with how i was trying to change the image size of each image.

Is there a way to set a different ImageSize for every image?

The ImageList.ImageSize property pertains to all images in the list and I don't believe you can individually set each image's size.

DdoubleD 315 Posting Shark

I know this is a kind of broad question, but I have been having a hard time in general knowing when to put what call parameters into what functions. Does anybody have any good tips on when to know when to use a void function verses a bool or int or other type of function. Also how to know what to call into the Function?

Well, you bring up to different topics really when mention both parameters and the "void function verses....", which would indicate return type.

Return type really depends on what you want. If it makes sense that your function should return an integer, then you would make it an int myFunc() declaration.

Parameters also depend on type, but if you pass by address/reference, then they can also return a changed value via the parameter...hmmmm...

So, when should I use a parameter verses a return value...hmmm...

Well, when you pass in a parameter, you might expect the contents of a parameter to be modified, or even allocated and then assigned. However, you can do the same thing with the return value of a function....hmmmm...

I think it just boils down to user preference and adhering to coding practices already in place for consistency--for the most part. But, you really can achieve similar/same results doing it either way except that you can only return one item, but you can pass several as parameters....

At this point, I will let someone else take over …

DdoubleD 315 Posting Shark

Maybe my brain is just fried...:yawn: I see you have uploaded your project and appx what it should do (haven't look yet), but can you just indicate what it is exactly that isn't working?.... Or, are we supposed to download and test it to see that it does what you are saying? :confused:

DdoubleD 315 Posting Shark

I trust you will know what to do with this:

DateTime arrival = new DateTime();
            DateTime departure = new DateTime();
            TimeSpan ts = arrival - departure;
            if (ts.Days > 5 * 365)
                MessageBox.Show("Houston, we have a problem....");
DdoubleD 315 Posting Shark

I'm confused a little. I understand if you cannot use the date picker control... Can you explain with a briefer section of code that shows exactly what you are trying to but cannot achieve?

DdoubleD 315 Posting Shark

It's based on C, so I believe the answer is absolutely and the same.... perhaps someone will have more to add to this...

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

system expects an executable command. You cannot simply place the name of a text file as the argument. If you want it to launch notepad or something to view your file, you could do that. Here is what I suggest, but have not tested or used this functionality for quite some time:

system ("notepad.exe " + file2.c_str());

If that gives you a compiler error, it will probably be on the string operation, which you can simply concatenate properly (I haven't done this in cpp since string library was introduced--LOL). Hope this helps.

DdoubleD 315 Posting Shark

I've been catching up on this thread and I am only on page 34, but haven't seen this one yet and thought you might enjoy it. It's supposedly from an actual support conversation with Word Perfect years ago, which is when I ran into it too--man I feel old--LOL. Here it is:

Customer Support Employee (CSE): May I help you?

Customer: Yes, well, I'm having trouble with WordPerfect.

CSE: What sort of trouble?

Customer: Well, I was just typing along, and all of a sudden the words went away.

CSE: Hmm. So what does your screen look like now?

Customer: Nothing.

CSE: Are you still in WordPerfect, or did you get out?

Customer: How do I tell?

CSE: Can you see the C: prompt on the screen?

Customer: What's a sea-prompt?

CSE: Never mind. Can you move the cursor around on the screen?

Customer: There isn't any cursor: I told you, it won't accept anything I type.

CSE: Does your monitor have a power indicator?

Customer: What's a monitor?

CSE: It's the thing with the screen on it that looks like a TV. Does it have a little light that tells you when it's on?

Customer: I don't know.

CSE: Well, then look on the back of the monitor and find where the power cord goes into it. Can you see that?

Customer: Yes, I think so.

CSE: Great! Follow the …

DdoubleD 315 Posting Shark

Try taking a look at this example: WIA in C#

Also, look for heading Video at this link: Video

DdoubleD 315 Posting Shark

Well..yeah.. wasent sure if he ment 5 years ahead of today or 5 years before today! I assumed its checking the date to be withing 5 years ahead of today.

Second set of eyes never hurts--LOL. I went to back to see if I had the comparison operator correct--I was going to blame it on Michelob Brewing Co if not. ;)

Cheers!

DdoubleD 315 Posting Shark

simply use the 'Value Changed' event of the DateTimePicker control.

if (dateTimePicker1.Value > DateTime.Now.AddYears(5))
        MessageBox.Show("Date should be within the next 5 years");

I think it was meant to say < -5 given you want to see if the date is 5 years older than current:

if (dateTimePicker1.Value < DateTime.Now.AddYears(-5))
DdoubleD 315 Posting Shark

Im trying to create a listview showing images with text

so how exactly can i do this? (im using visual studio if it helps)

Heres the code that isn't working now

// adding images ...
        imageList1.Images.Add("Unique key", Image.FromFile("..."));
        listView1.Items.Add("text for image", "Unique key");
        /*
         * more
         * images
         * 
         * */
        listView1.LargeImageList = imageList1;

i also tried inserting listView1.LargeImageList = imageList1; before adding the images.

how can make this listview show images with text the way i want?

I ran a test using your code and no image was drawn as you said. Then, I setup the ListView control to contain the imageList I added to the form and it appeared fine. I am guessing that the imagekey attempts to be associated at the time the new item is added listView1.Items.Add("text for image", "Unique key"); . Try associating the imageList first before you add the new item: listView1.LargeImageList = imageList1; , then add item...

DdoubleD 315 Posting Shark

I went and copied this code a couple of hours ago or so, then I got interrupted by a loooong phone call. Anyway, I can't resolve some definitions and I also forgot what I was thinking... Can you post an example with complete code that will compile?

DdoubleD 315 Posting Shark

By the way this albahari guy and i know each other, i am going to translate one of his tutorials(threading) into Turkish, we already made the deal but he said he is going to renew the tutorial, so i am waiting for him to complete.

It truly is a small world!;)

DdoubleD 315 Posting Shark

DdoubleD you're very active I like your way, keep it up.

Just having fun boss and thanks! I'll look for the raise come review time...

DdoubleD 315 Posting Shark

Hah, now I see it! Never noticed the dropdown menu before.
I definitly need new glasses! :icon_cheesygrin:

Could it be that blue light glaring in your eyes?--LOL Thanks for the link Danny!

DdoubleD 315 Posting Shark

If you set TxtPassword.UseSystemPasswordChar = true;
whenever you type something in your textbox it will be replaced by the bullet character.
If you use TxtPassword.PasswordChar = '$' or '*', all typing in the texbox will be replaced by '$' or '*'.
Put MessageBox.Show(TxtPassword.Text); In your void TxtPassword_TextChanged handler.

I believe this is correct. So, if I want to achieve the same goal of turning it off in my textbox (show actual text at runtime) when using my own defined PasswordChar, what would be the technique for switching it on and off as you can with the UseSystemPasswordChar property?

DdoubleD 315 Posting Shark

Because it is a defined class type and not an instance type.

DdoubleD 315 Posting Shark

To disable the password character ('*') and display the actual text in the same control:

TxtPassword.UseSystemPasswordChar = false;// or true to turn back on
DdoubleD 315 Posting Shark

Following from http://www.albahari.com/nutshell/ch24.aspx

Extracting “name = value” pairs (one per line):

string r = @"(?m)^\s*(?'name'\w+)\s*=\s*(?'value'.*)\s*(?=\r?$)";

string text =
  @"id = 3
    secure = true
    timeout = 30";

foreach (Match m in Regex.Matches (text, r))
  Console.WriteLine (m.Groups["name"] + " is " + m.Groups["value"]);

id is 3
secure is true
timeout is 30

ddanbe commented: What can you do if you are not busy? +13
DdoubleD 315 Posting Shark

Hmm..i am confused LOL..i will google it and try it out. Thanks for u suggestions.
However,
"You might want to add extra code in the read function though:
a) have an extra parameter in the read function definition that indicates edit mode"

this part i don't really understand it..can explain it?

Sure. Currently, read is defined as:

void read( employees record[], int max_1)

To expand it's usage to include update option:

void read( employees record[], int max_1, bool bUpdate=TRUE)

Then, add additional logic to the body. You can just set the max_1 var to 1, but I would recommend actually taking out the loops here and putting them around the call to read, passing in just the record being added/updated. Anyway to do update with separate read routine:

void read2( employees emp, bool bUpdate)
{  
	cout<<"employees no. "<< emp.em_id <<endl;

	char ch = 'Y';

	if (!bUpdate)// don't let them change ID!!!
	{
		cout<<"Enter  employee ID: ";
		cin>>emp.em_id;
		cin.ignore(100,'\n');
	}

	if (bUpdate)
	{
		cout<<"employee name: "<<emp.em_name<<"\n";
		cout<<"Change employee name?";
		cin>>ch;
	}
	if (ch == 'Y')
	{
		cout<<"Enter  employee name: ";
		cin>>emp.em_name;
		cin.ignore(100,'\n');
	}

	// ... etc.
}

This is just an idea of how you can modify the existing code.

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

1 & 2) Extend the menu to have Exit and Update options and just follow same logic already in place

2) when processing the Update option case label, get input for employee number, search the array for that record, then just pass that record to the read function. You might want to add extra code in the read function though:
a) have an extra parameter in the read function definition that indicates edit mode
b) when editing, display current value and ask if they want to change it; if they want to change it ('Y' entered or something), then allow the current code for that field to execute as currently defined; else, skip to the question/input for the next field.

Cheers!

DdoubleD 315 Posting Shark

I don't see any difference except I crammed it all in one header file. I am using VS2008 compiler. Here is the header code I have:

#ifndef POINT3D_H
#define POINT3D_H
 
#ifndef POINT_H
#define POINT_H
 
#include <iostream>
 
template <typename T>
class Point
{
protected:
	T X,Y,Z;
public:
 
	Point(const T x, const T y, const T z) : X(x), Y(y), Z(z) {}
 
	T getX() {return X;};
	T getY() {return Y;};
	T getZ() {return Z;};
 
	void Output();
 
};
 
template< typename T>
void Point<T>::Output()
{ 
	std::cout << "x: " << X << " y: " << Y << " z: " << Z << std::endl;
}
 
#endif
//////////////////////

//////////////////////
template <typename T>
class Point3D : public Point<T>
{
	//T X,Y,Z;
	public:
		Point3D(const T x, const T y, const T z) : Point<T>(x,y,z) {}
 
		void Output3D();
};
 
template< typename T>
void Point3D<T>::Output3D()
{
	std::cout << "3D" << std::endl;
 
	//these both show junk values
	std::cout << "X: " << this->X << std::endl;
	std::cout << "X: " << X << std::endl;
 
	//this says "there are no arguments to 'getX' that depend on a template parameter, so a declaration of 'getX' must be available
	double x = getX();
	std::cout << "X: " << x << std::endl;
}
 
#endif
daviddoria commented: thanks for the response! +5
DdoubleD 315 Posting Shark

I uncommented those two lines after commenting out the unnecessary var declarations, and I run just fine. Did you change something else?

DdoubleD 315 Posting Shark

The junk values are because you declare in both Point and Point3D:

T X,Y,Z;

but, you only initialize those belonging to Point in the construction.

As far as it running as posted, I had no problems running it and the data appeared correctly as coded to me, but maybe it's because you commented out the problems?

DdoubleD 315 Posting Shark

Just put your string inside a class object and pass that to the form. The class object will be passed by reference and will still contain the changed value of your string after the form closes. For example:

public class Credentials
        {
            public string username;
            public Credentials(string username) {this.username = username;}
        }
        public Credentials myUser = new Credentials("DonaldDuck");
        Form2 form2 = new Form2(myUser);
        // when form2 returns below, myUser will have any changes that were made in form2
        Form2.ShowDialog();
DdoubleD 315 Posting Shark

Consider using TextBox.Validating and/or TextBox.Validated methods to update other control's text. These are called before the TextBox.Leave and/or TextBox.Focus events are fired. The problems with the latter events is that there is not control over which will get fired first, which may not be an issue for you right now, but you will run into it one day if you haven't already.

The Validating event allows you to validate data and abort leaving the control if the data does not meet your criteria.

The Validated event occurs after validation above, indicating the TextBox.Text has passed whatever validation that may have been needed.

DdoubleD 315 Posting Shark

x functions is this :

monthlyWorks(infoTB.Text, thisMounth);

public DataSet monthlyWorks(string IsyeriId, string month)
        {
            Service();
            string str;
            str = string.Format("SELECT Kartno,IsyeriId,Tarih,Tutar,IslemTipi,KazandirilanPuan,HarcattirilanPuan FROM IslemTablosu WHERE IsyeriId='{0}' and MONTH(Tarih)='{1}' ", IsyeriId, ay);
            SqlDataAdapter adapter = new SqlDataAdapter(str, connection);
            DataSet dataset = new DataSet();
            adapter.Fill(dataset);
            return dataset;
        }

y function is also same but it does not get IsyeriId, it gets CardNo...

My problem is form1 sends IsyeriId to form3 whenever push a Islem button in form1. form2 sends CardNo to form3 whenever push a Islem button in form2.

I'm not sure I understand the problem as stated. I see you are trying to communicate between forms, but what exactly is not working?

DdoubleD 315 Posting Shark

I have two form.

Form 1 and Form 2

In form 1, i have a few textbox and and combo box. and BTNOk [to save] and BTNCancel[when BTNCancel is click, user are prompt whether to save file if there is changes in entry]

Form 2 is the file where BTNCancel is clicked.
Display:
Do you want to save changes to your setting?
BTNYES,BTNNO, BTNCANCEL.

QUESTION

When I clicked BTNYES in form 2 how can I call BTNOK in form 1 so that it can run the event handler in form 1 BTNOK

another question. any idea of how to do password encryption/decryption

Try this, and create a new thread for question about password encryption/decryption.

// in form1 where calling form2
            Form form2 = new Form();
            DialogResult result = form2.ShowDialog();
            if (result == DialogResult.OK) // or whatever result you want to return
            {
                //call your handler to save or whatever
            }

            // inside form2's button handler:
            this.DialogResult = DialogResult.OK; // will be returned from form2.ShowDialog()
DdoubleD 315 Posting Shark

Have you tried Form.Activate ?

DdoubleD 315 Posting Shark

STEP 1: Place several comments in your OperateCell method (aka operation1 method). Place the comments above:
* every loop
* every logical comparison
* every method called within the nested loop

When doing this, provide a good explanation of what the statement's purpose is--what is it supposed to do exactly.

By doing this, you will:
* have a better chance of discovering what is wrong yourself
* give others a much better chance of helping you to figure it out
* help to understand the program later on when it may not still be fresh in yours and/or someone else's mind

STEP 2 (can be done in conjunction with STEP 1): Refer to the rules/logic of program stated at the beginning your program:
* Compare it to the descriptive comments you just made in OperateCell
* update these rules to reflect any detail not already defined.
* update comments in OperateCell too if a detail already defined in the rules is not explained in the statement comments in OperateCell

Cheers!

DdoubleD 315 Posting Shark

Well, I don't know what a vehicle intialization code is, but it is probably something that both automobile (car) and truck have, and something that definitely belongs in a base like vehicle and you probably don't need it defined in auto. However, you can override methods to provide different information depending on the usage....

DdoubleD 315 Posting Shark

That will work, but I was hoping for something a bit cleaner. Like being able to call the constructor from the Vehicle class directly somehow

Gosh, now that I've been programming in C# for a little while, I want to ask why, but I remember wanting to do something similar some time ago....elaborate why you want to do this.

DdoubleD 315 Posting Shark

On the surface, it would appear you are referencing GetItemText.Substring(0, GetLength) in your loop, but GetLength might not be related to the length in GetItemText because your GetString above the loop is not directly tied. However, you didn't give what line produced the error, so can't be sure...

DdoubleD 315 Posting Shark

Post the new code with your changes and I will see what you've done.

DdoubleD 315 Posting Shark

Put the common methods in the vehicle class that are common to both truck and auto (car?).

Also, just FYI, you named class Automobile with constructor auto...

DdoubleD 315 Posting Shark

You need something like this:

///////
// ORIGINAL CODE
///////
node *start_ptr = NULL;
node *temp;
temp = new node;
 
fin.open ("tfile.data");
while (fin >> temp -> name)
{
  fin >> temp -> age;
  fin >> temp -> height;
  temp -> nxt = NULL;
}
 
if (start_ptr == NULL)
    start_ptr = temp;
while (temp != NULL)

//////////
// CHANGE TO SOMETHING LIKE:
/////////
node *temp;
node *start_ptr = temp = null;

string s; // you may want to use a char[] instead

fin.open ("tfile.data");
while (fin >> s)
{
  if (temp == null)
  {
    start_ptr = temp = new node();
  }
  else
  {
    temp = temp->nxt = new node();
  }
  temp->name = s; // won't work like this with a string: FYI
  fin >> temp -> age;
  fin >> temp -> height;
}

temp = start_ptr; 
while (temp != NULL)
   ....

I wrote that on the fly, but I think it is correct logic for using your definition. You will not be able to compile this, because I used a string and simplified it including leaving out a string copy you need to get the string into your char[]. I think if you look at this though, you will see what you are doing wrong in your original code.

Cheers.

DdoubleD 315 Posting Shark

Because you allocate only one node and you continue to overwrite it in each of your reads in your while loop. Therefore, when you set the start_ptr to the node, following the read loop, you are setting it to the end, which is actually (also) the beginning of your linked list because you have only one node in your linked list.

DdoubleD 315 Posting Shark

Whew :confused:, for a minute there I thought you were making this up as we went along. Anyway, glad you are comfortable with where you are with this project.

Cheers! ;)

DdoubleD 315 Posting Shark

I am so glad you marked this thread as solved, because most people never bother to that even once they have a complete answer...:D and ;)

Do you just want to do the checks from left to right one time, and do you need to make the changes based only on the original data, and not any of the changed data?

It is important to know this, because if this is true, then you do need a temporary or separate array to perform all checks on the original array, and without performing checks against previous cells that may have already been changed.

Let me know.

DdoubleD 315 Posting Shark

hm.. i just tried it.
maybe it sounds lame.
but i really am not good in C#, and it didn't work.

i tried to change one of the Cells.ChangeState() to Cell.NextCellState(Cells) and it doesn't work


if (i < ARRAYSIZE - 1 && Cell.NextCellState(Cells[i]) == Cells[i + 1].DefaultCell)
{
Cell.NextCellState(Cells[i]);
bHasChanged = true;
}

No, change the ChangeState method is what I meant:

public void ChangeState()
            {
                this.defaultCell = NextCellState(this);
#if false
                if (defaultCell == CellState.SPACE)
                    defaultCell = CellState.DOT;
                else if (defaultCell == CellState.DOT)
                    defaultCell = CellState.PLUS;
                else if (defaultCell == CellState.PLUS)
                    defaultCell = CellState.HASH;
                else
                    defaultCell = CellState.SPACE;
#endif
              }
DdoubleD 315 Posting Shark

You need to size your cannon_ball array before using it:

cannon_ball = new GameObject[max_cannon_balls];
Ramy Mahrous commented: Good +10
DdoubleD 315 Posting Shark

:sweat:....Kewl!!!!:)

I'd like to recommend combining the functionality in the ChangeState method to incorporate the NextChangedState method's return value instead of having two identical sets of logic.

Cheers!

DdoubleD 315 Posting Shark

Don't know what "print them in CM " is. Take into account that dpi(dots per inch) on the screen almost always differs from the dpi on a printer.

I think he/she is referring to centimeters, but I suppose it could mean color monitor. AcronymFinder.com didn't have either of those for CM in InfoTech related definitions (26 possibilities), so I wanted to see what someone else would say--;).

DdoubleD 315 Posting Shark

Not sure that you need to change the clip region, but it could be related to the tab order of the form's controls because leave and focus events do not fire off always in that order, sometimes producing undesirable affects. Just mentioning it to be aware of because I ran into a similar issue with a floating textbox on a treeview control that would sometimes be hidden underneath the treeview caused by this.

DdoubleD 315 Posting Shark

Ooooh... Try this:

// In class Cell:
            public static CellState NextCellState(Cell cell)
            {
                if (cell.DefaultCell == CellState.SPACE)
                    return CellState.DOT;
                else if (cell.DefaultCell == CellState.DOT)
                    return CellState.PLUS;
                else if (cell.DefaultCell == CellState.PLUS)
                    return CellState.HASH;
                else
                    return CellState.SPACE;
            }

// then in operation1 method; you might need to rearrange
            public void operation1()
            {
                // NOTE: if you only need to evaluate from left to right one time,
                // then you can omit this loop. Otherwise, this loop will continue
                // changing the cell states until the conditions are not longer true.
                    for (int i = 0; i < ARRAYSIZE; i++)
                    {
                        bool bHasChanged = true;
                        while (bHasChanged)
                        {
                            bHasChanged = false;


                            // ** check next cell
                            if (i < ARRAYSIZE - 1 && Cell.NextCellState(Cells[i]) == Cells[i + 1].DefaultCell)
                            {
                                Cells[i].ChangeState();
                                bHasChanged = true;
                            }
                            // ** check previous cell
                            else if (i > 0 && Cell.NextCellState(Cells[i]) == Cells[i - 1].DefaultCell)
                            {
                                Cells[i].ChangeState();
                                bHasChanged = true;
                            }

                        }
                }
#if false
                // NOTE: if you only need to evaluate from left to right one time,
                // then you can omit this loop. Otherwise, this loop will continue
                // changing the cell states until the conditions are not longer true.
                bool bHasChanged = true;
                while (bHasChanged)
                {
                    bHasChanged = false;

                    for (int i = 0; i < ARRAYSIZE; i++)
                    {
                        // ** check previous cell
                        if (i > 0 && Cell.NextCellState(Cells[i]) == Cells[i - 1].DefaultCell)
                        {
                            Cells[i].ChangeState();
                            //bHasChanged = true;
                        }
                        
                        // ** check next cell
                        if (i < ARRAYSIZE - 1 && …
DdoubleD 315 Posting Shark

lets change the space to "_"
so --> "_" "." "+" "#" (this is the order)
i will make another example

input: ##+._+_#.#+.#
output will be: ###+.+_ _.##+#

each cell is compared to the left and right of the original cell (the input)
Now, there is no mistake in it.

This doesn't make sense to me, because you said:

This is the rules, if either one of the neighbouring cells has a state equal to the next state of the cell, then the cell is changed to the next state.

but, the input, and the output you say it should be both begins with "##", which is equal to the next state--is it not? How can your output be correct?

DdoubleD 315 Posting Shark

ya actualy following the mose pointer,but the image must be visible only when mouse is @ hover mode.

I think this (above answer) is confusing. If the image follows the mouse pointer, then the mouse pointer is always hovering over it, right? So I am guessing that the image does not move, but becomes visible only when the mouse enters it's region, right?