Jump to content
Xtreme .Net Talk

joe_pool_is

Avatar/Signature
  • Posts

    512
  • Joined

  • Last visited

Everything posted by joe_pool_is

  1. Solved it. The control I needed, the DataGridView control, is not inheritable. Apparently, there are some controls that Microsoft has decided not to allow one to inherit.
  2. I don't see a sample project, Jamie, but here's one idea: Are you building just the project that you are working on? You might want to check and make sure you are building the project that contains your custom control as well. I'm more of a C# guy myself, and I've never figured out how to add another project to a solution using VB (looked into it once because someone here liked VB - I wound up giving up and saying, "That's why I use C#.")
  3. I've created a base form with (among other commonly used controls) a DataGridView control. It's Design Modifiers Property is set to Public so that I can position the control to where it is needed on my various inherited forms. However, on all of the Inherited Forms, all of the properties of the DataGridView control are grayed out. Other "base form controls" (a custom control, a picture box, and a status bar) are all able to be modified on the inherited forms. How do I get them enabled?
  4. I'm trying to pull some data from a Microsoft Word XML Document, but the code I have generates sloppy output (see streamLog.txt). I am trying to write each row of tab delimited data on its own line, but I never appends a carriage return. My code consists of 2 methods: readDocument and getXmlTables. The readDocument routine works - it is just to show you how I open the file (if anyone needs it). The problem comes from getXmlTables not putting rows on separate lines: private void readDocument() { XmlDocument myXMLDocument = new XmlDocument("myDoc.xml"); const string wordDocXml = "/word/document.xml"; string pkgNs = myXMLDocument.DocumentElement.Attributes["xmlns:pkg"].Value; XPathNavigator nav = myXMLDocument.CreateNavigator(); if ((nav.MoveToFollowing("part", pkgNs)) && (nav.MoveToAttribute("name", pkgNs))) while (nav.Value != wordDocXml) if (!(nav.MoveToParent()) || !(nav.MoveToFollowing("part", pkgNs)) || !(nav.MoveToAttribute("name", pkgNs))) throw new InvalidOperationException("Unexpected file format. Missing [pkg] namespace."); if (nav.Value == wordDocXml) { string path = @"C:\Temp"; if (Directory.Exists(path)) { FileInfo file = new FileInfo(Path.Combine(path, "streamLog.txt")); using (StreamWriter sw = new StreamWriter(file.FullName, false, Encoding.UTF8)) { getXmlTables(nav, sw); sw.Close(); } } } } void getXmlTables(XPathNavigator nav, StreamWriter stream) { string wNs = "[url]http://schemas.openxmlformats.org/wordprocessingml/2006/main[/url]"; while (nav.MoveToFollowing("tbl", wNs)) { while (nav.MoveToFollowing("tr", wNs)) { while (nav.MoveToFollowing("t", wNs)) { stream.Write(string.Format("{0}\t", nav.Value)); } stream.WriteLine(); } stream.WriteLine(); } stream.WriteLine(); } Forgive this question that seems simple, but I can't find an answer. The attached zip file contains an XML document exported by Microsoft Word that I am trying to parse along with the log that it creates. I've looked at several examples on how to use XPathNavigator, but there does not seem to be detailed information that I can grasp the concepts of. Is anyone on here good at using XPathNavigator? I'd really like some advice from someone that is good at using XPathNavigator. Regards, Joe myDoc.zip
  5. I posted this question a couple of days ago on http://social.msdn.microsoft.com, but I didn't get any responses. Maybe someone here has an idea. Here is the situation: In our company's internally controlled application, we check at startup to see if a newer version is available. We do NOT use and we do not want to use ClickOnce (it is problematic with terminal servers and our IT department does not like the way it installs Windows Forms, etc. - basically, we just avoid it). Anyway, once an update is found, how can I install it under a limited user account (aside from turning to ClickOnce)? The basic command currently does this: public void InstallUpdate() { if (_update != null) // FileInfo _update declared global to this class { Process installer = Process.Start(_update.FileName); if (installer != null) { Application.Exit(); } } } The version above works for Administrators and Power Users, but a Restricted User receives the following message box: (Programming style) Thanks, ~Joe Pool
  6. @karthizen: You will need to ensure the "ProductName" property in your Deployment project is the same. Do not change it from "MyApp 1.1" to "MyApp 1.2".
  7. My guess is a quick read on TcpListener.AcceptTcpClient() will point you where you want to go. Microsoft has plenty on this here: (VS2005) http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.accepttcpclient(VS.80).aspx Google will give you other examples and tutorials. Once you have a specific question, come on back and ask! :)
  8. I have traced the problem down as far as Event Viewer, where the error shows up under the local System tab, and I do not know how to resolve this. Here is a screen shot of the error: http://sites.google.com/site/jp2code/home/list/wmiprvse-Event.gif The description of the error is as follows (if the image is ever deleted): The link, however, is broken on my machine. Any help in troubleshooting this problem is greatly appreciated. Regards, ~Joe
  9. I recently had to open a project because someone on our production floor did not know how to navigate the menus. When I tried to run it, I got an Unauthorized Access Exception for code that I had not modified. This query worked before installing VS2008, but now it will not run in a test application under VS2005 either. My code fails in the foreach loop when the printer is assigned at this line: public static void GetPrintersCollection() { try { string sql = "SELECT * FROM Win32_Printer"; using (ManagementObjectSearcher query = new ManagementObjectSearcher(sql)) { ManagementObjectCollection Printers = query.Get(); foreach (ManagementObject printer in Printers) { Console.WriteLine(printer.Properties["Name"].Value.ToString()); } } } catch (UnauthorizedAccessException err) { // err.Message is empty Console.WriteLine("You do not have authorization to access this printer."); } catch (Exception err) { Console.WriteLine(err.Message); } } Any ideas why? Help! Please, and Thank You!
  10. Nevermind - it is a TrackBar. Apparently, it is not categorized into any of VS's presorted groups. To find it, you have to expand the "All Windows Forms" tree. I hope others get some use from my post.
  11. A Slider Bar: Is this available in Visual Studio? There could be a toolbar I have not loaded, it could be called something different, or maybe I need to make it using a list of existing components. Thanks, Joe
  12. I was skeptical about running RootKitRevealer, because I'd never heard of it. A quick search told me it was a Microsoft tool, and that satisfied my concerns (I guess I'm one of the few out there that places my trust in Microsoft). Thanks for the tool! It did not find any issues on my machine, but I'm definitely keeping this tool in my "Bag-O-Tricks"!
  13. Good info. I hope others find it useful, too. Thanks! ~Joe
  14. Thanks Plausibly, The CD is called The Backyardigans. My son loves them, and watching their shows all the time is getting me hooked on the songs. Mark certainly did a lot of work in the link you gave. I'm not comfortable hacking my systems like that, and I'm not even sure I'd feel safe reproducing his steps. It turns out that the Backyardigans CD is also a Sony product, so I'm sure their malware is now polluting my PC. I was eventually able to get into it using some cracking tool called "cdex 1.51", so I've got the MP3s. I am still interested in how my old CD players are able to extract the information using this executable.
  15. I'm writing a Roster class for our company's training program, and I'd like the class to implement the ICollection interface using our Employee class as a template: public class Roster : ICollection<Employee> When I punched this into VS2008, Intellisense gave me the options under ICollection to Implement Interface 'ICollection<Employee>' and Explicitly Implement Interface 'ICollection<Employee>'. Poo-doo! The ICollection interface is something I've never gotten a chance to work with, so I don't really know what the difference is. I just picked the simpler looking one, Implement Interface 'ICollection<Employee>'. VS constructed several of the required abstract class signitures (is there a term for that?) for me filled with the default "throw new NotImplementedException();" line in each routine, and I proceeded to fill these values using my private List<Employee> empList object. Later, I noticed that Intellisense still gave me the option to Explicitly Implement Interface 'ICollection<Employee>'. Since I can't seem to find any articles either in my C# books or online that tell me what the differences are, I went ahead and picked that one too. Now in my code, I've got what looks like duplicates: public void Add(Employee item) { // Implement interface 'ICollection<Employee>' empList.Add(item); } // And now I have a new private member that I don't know // what to do with below: void ICollection<Employee>.Add(Employee item) { // Explicitly Implement interface 'ICollection<Employee>' throw new NotImplementedException(); } Help! Where can I find something that shows me how to implement all of these methods? If a base class to implement from would help, here's what I have: [serializable()] public class Roster { List<Employee> empList; public Roster() { empList = new List<Employee>(); } } [serializable()] public class Employee { public Employee() { IdNumber = 0; } public Employee(int idNumber) { IdNumber = idNumber; } // Number that links to the Employee's ID Number in the database public int IdNumber { get; set; } } With this simple stub, could someone show me how to implement ICollection on the Roster class? Thanks, Joe
  16. I recently got a new CD. It plays in the car's CD player fine; plays in the home theater fine. I brought it to work to play on my PC. It autoloads an interface to view a video (that required Quicktime) and a button to play the music. I clicked to play the music, my Windows Media player loaded up, but nothing happened. I navigated to the CD and found that it contains a large executable (about 300 MB), but no soundtracks. OK, obviously, someone has found a way to prevent others from copying their music. My questions are: How is this done? To my knowledge, my old CD players do not have the ability to run executables. Next, I'm a software developer, so ...How is this done? (again, I know, but I'd like to also know how to do this from a software development standpoint - my main reason for posting this question here) Does anyone have any thoughts on how get these tracks off of the CD and onto my PC? I'd rather not listen to the whole CD when there are only 2 songs I like. I guess I'm spoiled to the digital age! Thanks for the time, Joe
  17. Just for completeness and to aid others (and myself if I ever have to revisit this), I was able to streamline the process somewhat using the guidance shown above into two small overrides that require "no wiring" to the form: protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (((Keys)(int)msg.WParam) == Keys.PrintScreen) { ScreenCapture(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); } return base.ProcessCmdKey(ref msg, keyData); } protected override bool ProcessKeyEventArgs(ref Message msg) { if (((Keys)(int)msg.WParam) == Keys.PrintScreen) { ScreenCapture(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); } return base.ProcessKeyEventArgs(ref msg); }Notice that the base process is not blocked! If I want to continue on to MS Paint and manually paste my screen capture, I can still do that, too. Further, for those interested in how I handle the Screen Capture, here is my very generic ScreenCapture routine (open source for anyone to use) which drops the screen shot on the desktop using a simple BackgroundWorker that tries to display the screen capture after it has completed: public void ScreenCapture(string initialDirectory) { using (BackgroundWorker worker = new BackgroundWorker()) { Thread.Sleep(0); this.Refresh(); worker.DoWork += delegate(object sender, DoWorkEventArgs e) { BackgroundWorker wkr = sender as BackgroundWorker; Rectangle bounds = new Rectangle(Location, Size); Thread.Sleep(300); Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height); using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Location, Point.Empty, bounds.Size); } e.Result = bitmap; }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { Exception err = e.Error; while (err.InnerException != null) { err = err.InnerException; } MessageBox.Show(err.Message, "Screen Capture", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else if (e.Cancelled == true) { } else if (e.Result != null) { if (e.Result is Bitmap) { Bitmap bitmap = (Bitmap)e.Result; using (SaveFileDialog dlg = new SaveFileDialog()) { dlg.Title = "Image Capture: Image Name, File Format, and Destination"; dlg.FileName = "Screenshot"; dlg.InitialDirectory = initialDirectory; dlg.DefaultExt = "jpg"; dlg.AddExtension = true; dlg.Filter = "Jpeg Image (JPG)|*.jpg|PNG Image|*.png|GIF Image (GIF)|*.gif|Bitmap (BMP)|*.bmp" + "|EWM Image|*.emf|TIFF Image|*.tiff|Windows Metafile (WMF)|*.wmf|Exchangable image file|*.exif"; dlg.FilterIndex = 1; if (dlg.ShowDialog(this) == DialogResult.OK) { ImageFormat fmtStyle; switch (dlg.FilterIndex) { case 2: fmtStyle = ImageFormat.Jpeg; break; case 3: fmtStyle = ImageFormat.Gif; break; case 4: fmtStyle = ImageFormat.Bmp; break; case 5: fmtStyle = ImageFormat.Emf; break; case 6: fmtStyle = ImageFormat.Tiff; break; case 7: fmtStyle = ImageFormat.Wmf; break; case 8: fmtStyle = ImageFormat.Exif; break; default: fmtStyle = ImageFormat.Png; break; } bitmap.Save(dlg.FileName, fmtStyle); try { Process.Start(dlg.FileName); } catch (Exception) { try { // try IE Process.Start("iexplore.exe", dlg.FileName); } catch (Exception) { } } } } } } }; worker.RunWorkerAsync(); } }Happy Trails! The End
  18. Thanks. void Form1(object sender, EventArgs e) { Console.WriteLine("P.S. What do you use for your C# code formatter?"); Console.WriteLine("This ('CS') works unless code contains brackets (i.e. arrays)."); }
  19. Thanks. I understood about the values being OR'ed together. The easiest implementation was just using your ToString() suggestion. It seems to filter great! Now I have this segment: void MdiForm_KeyDown(object sender, KeyEventArgs e) { string val = e.KeyCode.ToString(); if (val == "PrintScreen") { //if ((e.KeyCode == Keys.PrintScreen) || ((e.KeyData & Keys.PrintScreen) == Keys.PrintScreen)) { ScreenCapture(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); e.Handled = true; } } Note, however, that the Print Screen button will still not cause the event to fire. Maybe Microsoft is "protecting us" in the Framework. I hate that!
  20. I have created some code to try to capture the Print Screen key, but I never have been able to get it to fire for either my MDI form nor any of the Child forms. Here's what I have written: void MdiForm_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyCode == Keys.PrintScreen) || ((e.KeyData & Keys.PrintScreen) == Keys.PrintScreen)) { ScreenCapture(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); e.Handled = true; } }Anyway, other fires needed attention, and I forgot about it. I left a breakpoint on the Screen Capture line. Today, while inputting some text in one of the Child forms, I had to insert an underscore ("_"). Imagine my shock when I hit that breakpoint! I did a little debugging, and found that the Key Code contains the following: e.KeyCode = LButton | MButton | Back | ShiftKey | Space | F17 The Key Data displays this whenever I mouse over it: e.KeyData = LButton | MButton | Back | ShiftKey | Space | F17 | Shift The Print Screen identifier contains this: Keys.PrintScreen = MButton | Back | Space From System.Windows.Forms.Keys (Using VS2008): LButton = 1 RButton = 4 Back = 8 ShiftKey = 16 Space = 32 PrintScreen = 44 F17 = 128 I have coded some formatting fixes for lazy people and my program inserts and/or deletes some text, so I initially wasn't surprised by the Space and Back character being in the mix. It turns out, however, that my formatting is not what happens first. Could someone tell me why I get this strange data instead of a Print Screen keypress? At the least, whenever I press the Print Screen button, I would expect the MButton, Back, and Space values to all be included in the Key Code or Key Data - and certainly not whenever I call underscore (Shift + Hyphen).
  21. If there is no Internet connection, your visitors won't be able to get to your site. So, my guess is, you want to know how to inform people in your company when the connection to the Internet is down. Does that sum it up? If so, you might need to look into going through a proxy or a 3rd Party firewall, which would host the Internet connection and allow you to configure pages to respond to 408 (timeout) or 503 (unavailable) messages. See http://en.wikipedia.org/wiki/List_of_HTTP_status_codes for a larger list of these codes.
  22. You'd have to create an interface for the user to select from a radio button or something. Based on their selection, you'd have to write something to read from your two classes and compare the values.
  23. I suspected as much - I've just never taken the time to learn IL.
  24. Isn't Hide() the same as Visible = false? (I don't use it, so I'm just asking)
  25. I just set the MDI form's KeyPreview property to true. The event handlers for KeyDown and KeyPress now catch *regular* keys, but I still can't catch that Print Screen button!
×
×
  • Create New...