|
There are some articles here on cp which show you how to invoke function from a native dll without pinvoke code in the source.
|
|
|
|
|
hi, i am dealing with a stock market app, which is developing in c#.......... for trade purpose i want to use the QuickFix Protocol........ i was searching for sample codes for the same.... if any one have any idea pls contribute.............
My small attempt...
|
|
|
|
|
|
I had write code on text_change event of richText box in C#.net for wordwrap.
When i created the project and tested it its working fine, so i copy it make exe. Now problem is its showing some problem. so i check this code with oroginal code. In original code its working fine, but in copied code it showing problem.
The problem is like, after 3-4 line, at end of line its giving space in 2 letter like "Him" as "H i m", and adding "/n"at end of text.
Here maxLength is variable for no. of chracter like 65,66 etc per line, And if there is somthing wrong with code then plz help me.(not mismatch of { })
I want to know:
1. Code is for text_changed event & exact same in both, So why it like this?
2. Its only for text_change event and I dont think it has any relation with any other project part, i m using the text but after it has been put by the user.
The code for event is:
<br />
private void txtBody_TextChanged(object sender, eventArgs e)<br />
{<br />
<pre>if(tbWordwrap.Pushed)
{
string[] tempArray = new string(txtBody.Lines.length);
tempArray = txtBody.Lines;
int Prevsel = txtBody.SelectionStart;
string Op = "";
int maxLength = cINI.dbUtils.Pref.DefaultEditorWidth;
bool change= false;
for(int cou = 0; cou < tempArray.Length ; cou++)
{
if (tempArray[cou].length > maxLength)
{
string words = tempArray[cou].split(' ');
int currentLine Length = 0;
string currentLine = "";
foreach(string currentWords in words)
{
if(currentWord.Length > 0)
{
if(currentword.Length >= maxLength)
{
Op += currentword.Insert(maxLength, "\r\n");
break;
}
if(currentLineLength + currentword.Length + 1 < maxLength)
{
currentLine += currentword + " ";
currentLineLength += currentword.Length +1;
}
else
{
Op +=currentLine.Insert(currentLineLength, "\r\n");
currentLine = currentWord;
currentLineLength = currentWord.Length;
}
}
}
if(currentLine !="")
Op += currentLine;
PrevSel++;
change = true;
}
else
{
Op += tempArray[cou] + "\r\n";
}
if(change)
{
txtBody.Text = Op;
txtBody.SelectionStart = prevSel;
}
}
}</pre><br />
<br />
<br />
-- modified at 1:11 Wednesday 22nd August, 2007
|
|
|
|
|
best guess, the control is different sizes on the two forms, and so one version is showing up bugs in your code that are not evident in the other version.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi techies,
m working on the student management project (School) on C# 2005 and sql 2005 (windows application), i completed 80% , it can
create class , add section , edit student seats in particular section, add subject, add subject to the
particular section, registration of the student acccording to the class and section also display vacant
seat while registration, create first term result , second term result and final term, it can give
grace if student flunking( max 20 marks) , all result are in datagridview , but now i stuk while
printing it , i want to print the datagridview with form control(text box and label) coz it contains the
student information. so any one gimmme favour. (it shud b include print preview , page setting, and
print dialog) .
<<tech-prog>>
|
|
|
|
|
I think here[^] is the thing at CP that you want.
Mujtaba
"If both of us are having one one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
|
|
|
|
|
HI,
I am trying to write an SQL update query with c# code.
This is my situation.
I have a number of winforms and a sql server database. On one form I have drop down lists which are populated with the database rows by table adaptors.
This is what I need to do.
User selects a name from the drop down and clicks update which opens up a new form (class). In this new class I need to write an update statement to say update employees where '" + empNamecomboBox.Text.ToString() + "'. Basically to make sure we only update the selected employee, I want to say where the previously selection has been made. The only thing is I can't reference empNamecomboBox.Text because it belongs to another class.
Can you please helpe me? I've only got a few days to complete this.
Siann
|
|
|
|
|
So, basically you want to pass the string in question into the constructor of the new form, so that it knows where to look.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Well I was told to use empID which is the primary key to pass to the constructor like this. But then I tried the same update statement to no evail. I have only been programming for 2 months. Do I use empID somewhere in the update query?
public UpdateEmployee(int employeeID)
{
this.employeeID = employeeID;
InitializeComponent();
}
public int employeeID;
|
|
|
|
|
falles01 wrote: public int employeeID;
Why on earth is this public ? If you've been given this code to work on, the people you work with are no better skilled than you, which does not bode well for your future.
Yes, you should be using this variable, instead of blindly copying code that relies on a control that's in another form. And, if you can't work that out, then you have some learning to do which excludes you from being able to write code that anyone should be expected to pay for.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
string sql = "UPDATE employees SET Firstname = '" + employeeTextBox.Text + "' Where EmployeeID = '" + employeeID + "'";
I am assuming the textbox is on the second form, therefore that control is correct ? Also, employeeId is an int, why is it stored as a string in the database ? If it's not, then change to this:
string sql = "UPDATE employees SET Firstname = '" + employeeTextBox.Text + "' Where EmployeeID = " + employeeID;
Note, I made a typing error, and so I lost the name of the textbox, and just made something up, you may need to fix that, to make it all work. The brackets are superfluous in either case.
And again, this is open to injection attacks. That means, someone can enter an employee name which erases your entire database.
Is this an assignment, or is it paid work ? If it's an assignment, I apologise for being a bit harsh previously, but if you've been given this code and told to work on it, that sounds like a job task. And, if that's true, you need to make the code more secure ( an assignment obviously is not as important, at this stage of your learning curve )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
This is a project that I am doing to help me learn but will also be used by our department if it is good enough. Please note I get paid the worst wage in the world so don't worry about that! The guy next to me has been told to help me out but he doesn't really like helping out so he quickly showed me the overloaded constructor and when I told him it doesn't work he didn't really continue helping. he has had 10 years coding experience. I thought it was a little harsh considering I never liked programming and I'm really trying to give myself the confidence that I'm good enough, so that definitely shot me right back down again. I also read on the forum for that people aren't supposed to write abusive things like that to you people, but it was the other way around.
rEgardless, thanks for your help.
|
|
|
|
|
OK - two things disturb me in the industry right now
1 - people in places like India, who can't realy code, but come here for help when they take jobs at $2 an hour
2 - people who are not trained to code, being pushed into doing it by their bosses.
My responses were based in part on my assuming that you were in category 1. Again, I apologise. In the second case, it's the bosses who I am mad at, not the people who are stuck with the job.
falles01 wrote: The guy next to me has been told to help me out but he doesn't really like helping out so he quickly showed me the overloaded constructor and when I told him it doesn't work he didn't really continue helping.
Talk to your boss. If you're being expected to learn to code on the job, and they told someone to teach you, then they will hold *you* accountable if you don't complain now, while they expect that you're working on it quite happily.
falles01 wrote: I'm really trying to give myself the confidence that I'm good enough
Programming isn't that hard, I'm sure you are 'good enough', it's just a question of learning, and, more correctly, you would ideally learn without being under pressure to create a product that was going to be used. My first two years of programming, looking back at anything I had written 3 months prior would make me cringe. But, if this is what you're stuck with, we're certainly here to help. Just make sure the guy who is assigned to helping you is also doing what he's paid to do, instead of relying on a bunch of unpaid help, which, by definition, is less likely to be there absolutely when you need it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks. NO I am a good looking girl from Australia who has not got a personality for programming . ha ha, but I want to become a Business Analyst as I have an IT degree but I am a people person, so this will help me in the long run.
I also don't want to dop the guy in because he helps me sometimes, but my bosses also told me to work things out on my own. They don't like many questions here which is why I am seeking for other help. It took me 8 hrs to work out a problem yesterday that should've been so easy.
Thanks
|
|
|
|
|
falles01 wrote: They don't like many questions here which is why I am seeking for other help.
It sounds to me like they are not good people to work for. There's NOTHING wrong with asking questions, and everything wrong with NOT asking, when people around you are assuming you're doing fine.
falles01 wrote: It took me 8 hrs to work out a problem yesterday that should've been so easy.
Yeah, I've spent three nights on a problem like that ( learning WPF, a new framework ). It happens. I am in Australia too, so there's always at least one person on the boards who can help you, when you're at work.
The world needs more BAs who have some idea how to code, I hope it works out for you.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Also, I wrote all the code myself from scratch. It has taken me 4 weeks so far. They gave me no code. The guy next to me just told me to use that small portion I gave you in order to reference the other class.
|
|
|
|
|
I am using this
string sql = "UPDATE employees SET (Firstname) = ('" + newempTextBox.Text.ToString() + "') Where EmployeeID = ('" + empNamecomboBox.Text.ToString() + "')";
that could be completely incorrect.
So basically I want to set the firstname to the users entered text in the new form, where they have selected a name from the drop down in the previous form (class).
Thank you for such a quick response.
Sianny
|
|
|
|
|
Yes, this is a disaster.
First of all, if you're in another method, then the string you want is going to be what you passed in, not the exact same code which references a control that doesn't exist on this page.
Second, your code is completely insecure, and your database is compromised. You need to read up on SQL injections. Except, you say you've been programming for 2 months, so unless this is a class assignment ( which doesn't sound likely ), you should not be working on this at all.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
One way of doing .
Make a property in your combobox class and access your selecteditem through that property
|
|
|
|
|
But, the combobox is in another form....
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
private DataSet GetLoginDataSetXML()
{
string ConnectionString=GetConnectionString();
OleDbConnection OleDbconSource = new OleDbConnection(ConnectionString);
OleDbCommand OleDbcmdSource = new OleDbCommand();
OleDbcmdSource.Connection = OleDbconSource;
OleDbcmdSource.CommandType = CommandType.Text;
OleDbcmdSource.CommandText = "SELECT * FROM [Contacts$]";
OleDbadpSource.SelectCommand = OleDbcmdSource;
OleDbadpSource.UpdateCommand = OleDbcmdSource;
DataSet dsSource = new DataSet();
OleDbadpSource .Fill(dsSource);
//code to modify data in dataset here
OleDbadpSource.Update(dsSource);
dsSource.Tables[0].Rows[2].ItemArray[0] = "ns1:sinkName";
dsSource.Tables[0].Rows[2].ItemArray[0] = "CRRHistoricalForecast:sinkName";
TRYING TO CHANGE "ns1:sinkName" to "CRRHistorical:sinkName" BUT NOTHING IS HAPPENING
return dsSource;
|
|
|
|
|
Hi.
I have 2 webcams connected, they are from different providers, (a Genius NB and another cam).
My application must be able to capure both cams, so, I have 2 picture box and I'm using the API function capGetDriverDescription to get the descripions of the cams as the following code shows:
public static Device[] GetAllDevices()<br />
{<br />
String dName = "".PadRight(100);<br />
String dVersion = "".PadRight(100);<br />
<br />
for (short i = 0; i < 10; i++)<br />
{<br />
if (capGetDriverDescriptionA(i, ref dName, 100, ref dVersion, 100))<br />
{<br />
Device d = new Device(i);<br />
d.Name = dName.Trim();<br />
d.Version = dVersion.Trim();<br />
<br />
devices.Add(d); <br />
}<br />
<br />
dName = "".PadRight(100);<br />
dVersion = "".PadRight(100);<br />
}<br />
<br />
return (Device[])devices.ToArray(typeof(Device));<br />
}
This is code is from an article from here, CP.
The problem is, that this code only get the description of 1 cam, I don't know why but capGetDriverDescriptionA always return true one time.
Both cams works well, even there's a program called SKIN distributed by my Genius cam that can shows both devices and you can select which one to use. I don't how this program does that.
But I need to show the video of 2 web cams at the same time. Which API could help me?
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Hi guys,
In my programme, I have a scenario where I have a particular image displayed through a picturebox. When I try to delete the picture through the code, it gives an exception saying that it is accessed by another programme.
I tried using the PictureBox.Dispose() method and PictureBox.Image=null methods before the deletion code runs, to solve this.
But, neither worked.
What's wrong here?
Regards,
A
|
|
|
|
|
The file is still being held open from when you opened the file. How did you open it ? Do you call Dispose on the image itself ? Disposing of the picturebox doesn't help, and setting the image to null does not call Dispose on it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|