
coldfusion244
Avatar/Signature-
Posts
269 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by coldfusion244
-
when close button is pressed, stop program from ending?
coldfusion244 replied to Getox's topic in Windows Forms
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing e.Cancel = True End Sub Using the Cancel = true, stops the program from ending, after that you want to add any code for the systemtray icon. I believe you'll want to look at NotifyIcon class. -Sean -
I code in C++/C# , but I believe this should work. Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress If e.KeyChar = Chr(Keys.A) Then textbox1.Text = Integer.Parse(textbox1.text) + 1 End If End Sub If you wanted it for all keys then: Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress textbox1.Text = Integer.Parse(textbox1.text) + 1 End Sub Hope this helps. -Sean
-
In a different control, or on the form itself again?
-
getting filename of OpenFileDialog
coldfusion244 replied to ganders's topic in Directory / File IO / Registry
The only way I know (using C#) is to find the last slash and then get all characters after that. [CS] string strFile = OpenDialog1.FileName; strFile = strFile.Substring(strFile.LastIndexOf("\")); [/CS] Using LastIndexOf("\") we find the last place the slash is used, this denotes the last directory. Everything after that is the filename and extension. So we use substring to obtain everything after that point. -
I guess that's what I'll do. Thanks for all the help guys! I guess the transistion from C++ to .net is going to be harder than I thought. :( :o Special thanks for putting up with my unique stupidity ;)
-
wow, thanks HJB! I guess my last question then, would be (unless I didn't totally understand you HJB) how I could access objects from their memory location. Since my problem is that I'm creating a new clsWin everytime I add it to the collection class, I was thinking that I should just use memory locations to access them. Store the memory locations in the collections and use a regular object. I don't think this will work but something to the effect of: [CS] clsWin MyWin = new clsWin(); //default object MyWin = m_cColletion.Address(hWnd); //set object = object in memory [/CS] Where Address would return a reference to the memory location. Then when I added items to the colleciton I would ad their memory reference as the value and their hWnd as the key.
-
If you are looking to have users browse their hard drive for a file and upload it, this control is already in visual studeio, go into your toolbox and under html controls choose the file input.
-
Hi guys, I am unsure of how to accomplish what it is I am trying to attain. I want to have a webpage made in ASP.NET (using C# code) which I have done (without networking code programmed in). The user then chooses from 3 dropdown combo boxes. The first loads the servers, the second loads all the players on the chosen server. The third gives reasons why an Administrator should get into the game to reprimand the player. This can be found at http://cold.gotdns.com/asptest/WebApplication1/WebForm1.aspx . What I want is to have a program running on every admins computer. When someone submits a complaint form I want it to go to every admin's program which will then popup and tell them about the complaint, etc. I then want the admins to respond by clicking a button to stop the alert and send to the rest of the admin who is going to take care fo the problem. (I guess I'm going to have usernames too [no password's needed, trusted network]). Once the admin clicks the button the request goes away and the program goes back down into the system tray on every other admins computer. The admin that takes it stays up so that he can get the information from the complaint to which server and person, etc. I am wondering what is the best way to tackle this. I am open to any suggestions. I have never done programming like this before, it all has been non-internet based. I was thinking maybe an XML file that the client constantly reads or a server program that the webpage talks to, I don't know guys, any and all help is appreciated. Thanks! -Sean
-
Ok, I think what's going on is that I'm creating a new object everytime I add it to the collection. So in essence I believe I am making 2 objects for every 1 that I actually have. I think the program is confusing the objects that it has. Ok, new question then. How could I put an object (onto the heap I presume) in memory so that C#'s garbage collector doesn't touch it, but this way I could add it's memory location to the collection. Then I want to go through the collection and use a pointer(s) to use the methods in my objects in memory. I don't know if that makes sense. I guess what I am asking is, how would I just put all my new clsWin's in memory and access then with pointers. in C++ I could say clsWin MyCreatedObject = new clsWin(Hwnd); clsWin* pclsWin = &MyCreatedObject; pclsWin->MyMtehod(); But I can't do that in C# or can I. I might just be confusing myself :confused: C# kept complaining to me that it could use pointers with primitives. I'm so confused with C#.
-
The clsWin code is huge, a few hundred lines of code. I think though the error lies somewhere in my clsEnum. I use this to enumerate all of the open windows to find the ones I want. I'll post it here: [CS] using System; using System.Runtime.InteropServices; using System.Text; namespace cAIM { /// <summary> /// Enumerates all instances of Windows and ands them to an instianted /// clsCollection class. Must set Collections before using. /// </summary> public class clsEnum { public static clsCollection m_cCollection; [DllImport("user32.dll")] private static extern int EnumWindows(EnumWindowsProc ewp, int lParam); [DllImport("user32.dll", CharSet=CharSet.Auto)] private static extern int GetWindowText(IntPtr hWnd, StringBuilder ClassName, int nMaxCount); [DllImport("User32.Dll", CharSet=CharSet.Auto)] private static extern void GetClassName(IntPtr h, StringBuilder s, int nMaxCount); private delegate bool EnumWindowsProc(IntPtr hwnd, int lParam); public clsEnum() { } public void StartEnum() { EnumWindowsProc callbackProc = new EnumWindowsProc(EnumWin); EnumWindows(callbackProc,0); callbackProc = null; ForceUpdate();//Force to check for validity } public void Setup(clsCollection cCollection) { m_cCollection = cCollection; } private static bool EnumWin(IntPtr Hwnd, int lParam) { string tcl = "WindowClass"; string gcl = GetClass(Hwnd); string strWin = WindowText(Hwnd); if (gcl == tcl) { if (strWin == "caption") { } else { AddWin(Hwnd); } } return true; } private static string WindowText(IntPtr Hwnd) { StringBuilder mtitle = new StringBuilder(256); IntPtr mywin = Hwnd; GetWindowText(mywin,mtitle,256); return mtitle.ToString(); } private static string GetClass(IntPtr Hwnd) { StringBuilder mclass = new StringBuilder(256); GetClassName(Hwnd,mclass,256); return mclass.ToString(); } private static void AddWin(IntPtr hWnd) { clsWin nWin = new clsWin(hWnd); int counter = 0; bool bflag = false; for(counter = 0; counter < m_cCollection.Count; counter++) { if (m_cCollection.Item(counter).m_hWnd == hWnd) { bflag = true; nWin = m_cCollection.Item(counter); break; } } if (bflag == true) { //do nothing it's in there, it will be force updated } else { m_cCollection.Add(nWin); } nWin = null; } private void ForceUpdate() { int counter = 0; bool btest = false; for(counter = 0; counter < m_cCollection.Count; counter++) { btest = false; btest = m_cCollection.Item(counter).Update(); if (btest == false) { m_cCollection.Remove(counter); } } } }//end class }//end namespace [/CS]
-
Nerseus, you're the best! Worked perfectly. Why would it not say something about this in any of the books that I own :confused: . Thanks again Nerseus :D Here is my new code to find the ip address: public void ReadXML(string strDocument) { XmlTextReader xtr = new XmlTextReader(strDocument); Console.WriteLine("Inside"); XmlDocument xd = new XmlDocument(); Console.WriteLine("Document Loading..."); xd.Load(xtr); Console.WriteLine("Loaded!"); XmlNode node = xd.SelectSingleNode("/STATUS/SERVERINFO/VARIABLE[@name='ipaddress']/VALUE"); Console.WriteLine(node.InnerText); }
-
I was searching around and read a few books, to parse XML using C#. Unfortunately, none of them gave a very good explaination of how to parse it. What I want to do is parse the following XML file http://www.goamericasarmy.com/manager/status/xml.asp?server={A2D18978-64EE-41F9-B274-6BB127ABA593} with C#, but only pull out the values that I need. For example, I want to extract the IP address, the hostname, and all of the current players names. I have a good idea on how the elements work, but not the data inside them. For example I had used the Xml object in C# and could get the IP address, but after that I had no such luck. It seems as though you can't just search under a specific element for a piece of data with the tag "blah". For example Getting the data in VALUE in the element ipaddress (so that I would get the IP Address). If anyone has idea or knows of some sample code, that would be great.
-
Sorry for the sloppy code posting, I tried using the Code tags and IE crashed on me everytime!
-
here is the code: using System; namespace cWindows { /// <summary> /// clsCollection is the derrived collection class /// for holding all of the handles for all Correct open windows. /// </summary> public class clsCollection:System.Collections.CollectionBase { public void Add(clsWin aWin) { List.Add(aWin); } public void Remove(int index) { if (index > Count-1 || index <0 ) { } else { List.RemoveAt(index); } } public void Remove(clsWin aWin) { int counter; IntPtr dWin = IntPtr.Zero; for(counter = 0; counter <= Count - 1; counter++) { dWin = Item(counter).m_hWnd; if (dWin == aWin.m_hWnd) { Remove(counter); } } } public clsWin Item(int index) { return (clsWin) List[index]; } } }
-
Approximately how big is the excel file? I ask because you can easily use an Access database(by importing the excel data) or you can run a MySQL server. This of course only if you would need people from the guest house to add/edit/maintain any data with the file. If you just need to look at the file then yes, stick with the web browser, it will be read only (although you may want to put restrictions on the file [example would be under windows, only allowing certain usergroups to access the file].)
-
I am making the transition from vc++ to c#, and i'm having some problems with objects and pointers. I have a class that scans the system for certain windows, if it finds one, it creates a new object of a class that I created. This works great, except for when I need to access them again. I tried using a derived collection class, but it seems that once put into the collection class it calls upon the objects destructor. This is bad, since I am checking those windows for updating, as well as holding other window specific data. So I turned to pointers (which in C# I am unfamiliar with). What I decided to do was have a collection of type IntPtr (derived) and just pass it handles to my objects in memory as it would ideally be faster. However I can not create a pointer of a user defined type, at least I searched MSDN all over and found only primitives. If someone has a better idea or can help me with customer object pointers that would be greatly appreciated :) . Be honest, if I should just stick with VC++ then tell me :rolleyes: this way I can start porting my code over, thanks guys.