|
Ultimately, you can't control what the app itself does. If the app forces itself to be shown, there's nothing you can do about it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I don't think thats the case with this, as there is a windowHider app tutorial that will hide it - I may be wrong and the method is different - But I'm pretty sure the right person will know how to either hide it or minimize to tray anything that will remove its Ugly console face from in front of the Primary app.
|
|
|
|
|
Console app? Then you've already done it the correct way.
Process proc = new Process();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.FileName = @"NSLOOKUP.EXE";
proc.Start();
Works perfectly fine for me. No console window shows up.
[EDIT]
Might help if I posted the correct language...
[/EDIT]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 23:13 Sunday 18th December, 2005
|
|
|
|
|
Yeah thats the odd problem I been having.
Seems I can't get it hidden.
|
|
|
|
|
In some computer training institutes, the instructor uses a software whose functions are:
1. when teacher is teaching, whatever he does on his computer appears on the computer of the student as a demo.
2. the student cannot use his keyboard or mouse and all input functions are disabled.
How can these things be managed in C#?
|
|
|
|
|
|
I have a C# problem that I need a solution for. I've pretty much mastered in in VB6, but keep running into brick walls, even with all the tutorials for C#.
Here's the definition of the variables you're about to see...
"ClassStudents" is a class I created to manage an array of students read in from...
"LogReader" This is the name given to the SQL select statement that returns the information I'm trying to use.
"logCount" is simply to keep the array element in check.
while (LogReader.Read())
{
ClassStudents[] Students = new ClassStudents[logCount+1];
Students[logCount].setKnown(LogReader.GetInt32(0), LogReader.GetString(1).....
logCount++;
}
Basically, I need to be able to populate an array of what in VB6 would be a simple 'Type' so I can go back to it for data 'after' the fact.
Everything's fine until I leave the while loop, at which point I seem to lose the ability to reference the "Students" array I created. I tried using Structs as well. I know it must be a fundamental rule I'm breaking, but I just can't find any reference to what is happening in any documentation or help files. I found a post basically outlining the method I'm using, but they stop short of any reason why I wouldn't be able to access the data outside of where it was populated. Kinda defeats the purpose, if you ask me.
|
|
|
|
|
Hope i get this straight....
You want to get an array with ClassStudents, and then fill it using LogReader? Ok, let me try:
ArrayList students = new ArrayList();
int logCount = 0;
while (LogReader.Read()){
ClassStudent student = new ClassStudent(logCount);
student.SetKnown(LogReader.GetInt32(0), LogReader.GetString(1));
students.Add(student);
logCount++;
}
ClassStudent firstStudent = (ClassStudent)students(0);
And structs or classes don't really matter for this, the differences between those are completely different.
HTH!
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Ok. That 'kind of' works...
I was able to declare the ArrayList "students", create a new class object "student", pass the values into the object "student" (as far as compile time goes.. can't really test it because of the following...) and add the object "student" to the ArrayList of "students". Ok so far. Now when I try to use the intellisense for "students." I don't get any of the functions that I need to be able to call from the class object that it is comprised of. Pretty pointless if I can't use the functions the whole class was designed for. Any suggestions?
Here's a summary of what I need to accomplish...
1. read multiple records (with multiple fields of varying data types, of course) from a table in a database into an array of some sort.
2. While reading the rows, populate a listbox with a built sting with some of the information (but not all) // This much I can handle all well and dandy
3. I need to be able to pull up various elements from the 'full' array of data for a given line when a user clicks on one of the corresponding "index number" line in the listbox.
4. I had this licked with a handy-dandy "type" variable array in VB6, but C# is just TOTALLY not going to settle for the same approach. I need some advice on the best way to approach this problem. I've wasted over 8 hours already, trying to find a means for something that took me a whopping 20 minutes in VB6, and I feel no closer now than when I started.
|
|
|
|
|
As an ArrayList contains reference to the type Object, you have to type cast the item to use it:
((student)students[42]).MyMethod();
---
b { font-weight: normal; }
|
|
|
|
|
Great. That worked (with a minor edit... needed to replace student with ClassStudent).
A recap for any that browse for a solution of this nature...
// This, I actually placed after the "System Generated Object Declarations" for increased scope.
ArrayList students = new ArrayList();
// The while loop...
while (LogReader.Read())
{
// Make a new student
ClassStudent student = new ClassStudent();
// Fill it with data (Added some nullchecking since original post.. not shown)
student.SetKnown(LogReader.GetInt32(0), LogReader.GetString(1));
// Now add the new student to the students arraylist
students.Add(student);
// Now students is filled with each student (duh), and you can still reference it
// Now you can get a student like this:
// With ArrayList you have to cast from object to a ClassStudent
(my apologies for not catching this... thanks for pointing it out in more detail, Guffa )
// Can use this anywhere you like..
((ClassStudent)students[indexNum]).MyMethod();
Thanks a "metric buttload" to both of you.
|
|
|
|
|
You are making three errors in that loop:
:: You are creating the array inside the loop. That means that the scope of the array is the loop, so you can't use it outside the loop.
:: You are creating a new array for each iteration. That means that the previous array is discarded along with the previos item. After the loop you will have an array where every item is null except the last one.
:: You are not creating any ClassStudents objects. That means that you can't call the setKnown method as the reference that you try to use to make the call (the item in the array) is null.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: :: You are not creating any ClassStudents objects. That means that you can't call the setKnown method as the reference that you try to use to make the call (the item in the array) is null.
I think that's why he tried structs instead .
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
HI All
I need to add timer to do some "job" every X second.
I know that i can do it in class that divided from Form class , but i need to do it from class that is not divided from Form class ...
How can i do it in C# ?
[I'm using IDE v.s 2005]
Thanks
|
|
|
|
|
Look at System.Timers.Timer. You can use one of those timers to do what you need.
|
|
|
|
|
I have another problem, errr, challenge now. I am using an SQL database to save the info the person chooses on one form (pedbone.cs).
Here's the code to the Combobox I've got on the "main" form (pedbone.cs):
m_cTypes = new ArrayList();<br />
m_cTypes.Add("Unknown"); <br />
m_cTypes.Add("Male");<br />
m_cTypes.Add("Female");<br />
TypeCombo.DataSource = m_cTypes;
These are listed in a ListView
SqlCeCommand sqlLoadEvents = m_cConn.CreateCommand();<br />
sqlLoadEvents.CommandText = szSQL;<br />
SqlCeDataReader rReader = sqlLoadEvents.ExecuteReader();<br />
<br />
while ( rReader.Read() )<br />
{<br />
lvItem.SubItems.Add(GetTypeFromNumber ((int)rReader.GetValue(rReader.GetOrdinal("MovieType"))));
CollectionList.Items.Add( lvItem );<br />
}<br />
}
And here I got the Combobox text to show in the ListView, by using this code
private string GetTypeFromNumber(int nTypeID)<br />
{<br />
return (m_cTypes[nTypeID].ToString());<br />
}
Now, when you click on the listview item, a new form opens up (AddEditMovieForm.cs) to view the file in more detail. And here's where I'm running into a bit of a bind.
public AddEditMovieForm(SqlCeConnection cConn, int nMovieID)<br />
{<br />
InitializeComponent();<br />
<br />
m_cConn = cConn;<br />
m_nMovieID = nMovieID;<br />
m_cTypes = new ArrayList();<br />
<br />
if ( m_nMovieID != -1 )<br />
{<br />
SqlCeCommand sqlCommand = m_cConn.CreateCommand();<br />
sqlCommand.CommandText = "SELECT * FROM MOVIE_MNGR_TABLE where MovieID = "+m_nMovieID.ToString();<br />
<br />
<br />
SqlCeDataReader rReader = sqlCommand.ExecuteReader();<br />
if ( rReader.Read() )<br />
{<br />
<br />
}<br />
<br />
{<br />
<br />
GenderLabel.Text = rReader.GetValue(rReader.GetOrdinal("MovieType")).ToString();
<br />
{<br />
}<br />
}<br />
<br />
<br />
}<br />
}
Any help would be appreciated. I would like to add "male" or "female" into the GenderLabel.Text field. If I neglected to add any important code, please let me know.
Thanks guys,
M.
|
|
|
|
|
Class DateTime have read-only property Now for get current system time. But I can't find any method to set system time.
- - -
|
|
|
|
|
Andrey_Mark wrote: But I can't find any method to set system time.
Probably because the designers of the .NET Framework didn't think it would be useful. Setting the System time is an Administrator function (if I remember correctly) and many people now syncronise their PCs with an atomic clock over the internet or it is set via a central server in the enterprise.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
I use following solution in this case:
public struct SYSTEMTIME {<br />
public short wYear;<br />
public short wMonth;<br />
public short wDayOfWeek;<br />
public short wDay;<br />
public short wHour;<br />
public short wMinute;<br />
public short wSecond;<br />
public short wMilliseconds;<br />
};<br />
<br />
public sealed class SetSystemTimeUnsafe<br />
{<br />
<br />
[DllImport("kernel32", SetLastError = false)]<br />
private static extern unsafe bool SetSystemTime(SYSTEMTIME* st);<br />
<br />
public static void Set(DateTime dt)<br />
{<br />
unsafe<br />
{<br />
SYSTEMTIME st;<br />
st.wDay = (short)dt.Day;<br />
st.wDayOfWeek = 0;<br />
st.wHour = (short)dt.Hour;<br />
st.wMilliseconds = (short)dt.Millisecond;<br />
st.wMinute = (short)dt.Minute;<br />
st.wMonth = (short)dt.Month;<br />
st.wSecond = (short)dt.Second;<br />
st.wYear = (short)dt.Year;<br />
SetSystemTime(&st);<br />
}<br />
}<br />
<br />
}
- - -
|
|
|
|
|
Hello. Can you tell me how can I make my C# application interact with other C# or win32 applications. Thank you. I want for example to be able to get the data from a notepad or a cmd window. Thank you.
|
|
|
|
|
The other application has to be designed for such interaction. You can force interaction, but there is no consitent way to do that because you have to trick the application into interacting with your application.
There are ways of getting properties of windows (e.g. controls), for example, the Text property of the TextBox control that Notepad (I assume) is using. However, it has been a few years since I did any C++ and I don't enough to be able to work out how it might be done any more.
The Command window might be easier to deal with as the application is just interacting with StdIn, StdOut and StdErr and these can be redirected. See the System.Diagnostics.Process[^] class
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
I was thinking of something in Diagnostics.Process thanks
|
|
|
|
|
Hello,
I am stuck with an error: An object reference is required for the nonstatic field, method, or property
the code that is causing the problem:
-class Form1
private static DiscoveryProcess DPform;
public static bool DiscoveryProcessInstance = false;
public static void DiscoveryProcess()
{
if (DiscoveryProcessInstance == false)
{
DPform = new DiscoveryProcess();
DPform.Show();
DiscoveryProcessInstance = true;
-ERROR- toolStripStatusLabel1.Visible = true; // System.Windows.Forms.ToolStripStatusLabel
}
else
DPform.WindowState = FormWindowState.Normal;
}
situation:
Form1 is the mainform, from there I start a new Windows form, Form2. When the operation are done on that Form2, I call the following code to start another Windows form DPform
-class Form2
Form1.DiscoveryProcess(); //starts DPform
this.Close(); // closes Form2
Now what I want to accomplish with that is that i can close the form Form2 (I don't need it anymore) without closing DPform and that only one single window form can be created. But what i want to do is set a toolStripStatusLabel on Form1 to visible.
Can someone point me into a direction of how to manipulate the toolStripStatusLabel on another form? Or is my approach of calling new window forms from Form1 not correct?
Thanks in advance.
-- modified at 8:06 Sunday 18th December, 2005
|
|
|
|
|
Did you try running the code under a debugger? Assuming you're using VS .NET, hit F5 and then try the operation that caused the exception. The debugger should point you to the exact line that resulted in the problem.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Sorry, something missed out:
the error occures on this line:
toolStripStatusLabel1.Visible = true; // System.Windows.Forms.ToolStripStatusLabel
|
|
|
|