
joe_pool_is
Avatar/Signature-
Posts
512 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by joe_pool_is
-
If you truely want to run the DOS app in the background while the page is loading, try using a BackgroundWorker Thread. Using an anonymous method: using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += delegate { System.Diagnostics.Process.Start("yourCommandLine.exe /arg /arg /arg"); }; worker.RunWorkerCompleted += delegate { // do whatever you need to do with the values returned from the // command line exe. Cursor = Cursors.Default; }; worker.RunWorkerAsync(); if (worker.IsBusy == true) { Cursor = Cursors.AppStarting; } }
-
How would I load a file from a resource? We have a 'PDF-like' file that is formatted for printing the our label forms (it isn't quite like a PDF, but pretty close. It lets us enter text that comes out as a barcode). Anyway, the file often gets lost or deleted by someone fooling around with the PC when they should not be. To resolve this problem, I inserted the file under Project Properties > Resources > Files section. I'm trying to do something like this: File.Open(global::Project2.Properties.Resources.File1); Obviously, this will not compile. Can I use the Resource object to store files that I can access in my application? If so, how?
-
Thanks Nate. That takes care of my problem.
-
That part is fine. Notice the VB code calls each field as an object from the document then reads the field's name and sets the field's value. In C# (or even if I updated them to VB.NET), I don't know how to parse the object fields or their object information in the fields. .NET does not like working on objects. I've contacted the manufacturer, but they did not know. They are still only supporting VB6, and apparently that is enough to keep their product selling just fine.
-
I've got some old VB code that I am trying to convert to C#. The old VB code uses CreateObject, which is not supported in C#. I've been doing some reading on how to get information, but I just can't seem to get everything I need to get the C# application to compile. Maybe someone here can see what I'm missing. Here is the old VB code: Sub CreateLabel() Dim objDoc As Object = CreateObject("Lblvw.Document") objDoc.Open("C:\Temp\LabelView.dat", True) Dim LastError As String = objDoc.LastError For Each FLD As Object In objDoc.LabelFields Dim str1 As String Select Case (FLD.Name) Case "CustPartNum" FLD.Value = FLD.Name Case "Qty" FLD.Value = FLD.Name Case "Date" FLD.value = FLD.Name Case "Customer" FLD.value = "Customer" End Select Console.WriteLine("{0}: {1}", FLD.Name, FLD.Value) Next objDoc.Close() End Sub Below is as far as I can seem to get using C#. It fails at the "foreach" loop because it can not do a foreach loop on an object. I could change that, but next it can't access the individual item's properties in the objects either. Could someone offer me some guidance? public void CreateLabel() { System.Type objDocType = System.Type.GetTypeFromProgID("Lblvw.Document"); object objDoc = System.Activator.CreateInstance(objDocType); objDocType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, objDoc, new object[] {"C:\\Temp\\LabelView.dat", true}); string LastError = objDocType.InvokeMember("LastError", System.Reflection.BindingFlags.GetProperty, null, objDoc, null); foreach (object FLD in objDocType.InvokeMember("LabelFields", System.Reflection.BindingFlags.GetProperty, null, objDoc, null)) { string str1 = null; switch (FLD.Name) { case "CustPartNum": FLD.Value = FLD.Name; break; case "Qty": FLD.Value = FLD.Name; break; case "Date": FLD.Value = FLD.Name; break; case "Customer": FLD.Value = "Customer"; break; } Console.WriteLine("{0}: {1}", FLD.Name, FLD.Value); } objDocType.InvokeMember("Close", System.Reflection.BindingFlags.InvokeMethod, null, objDoc, null); }
-
Hi Plausibly. The code works ...but it doesn't. The value of 'bool visible' is set to False while both of the menu items' Visible Property is True. I can hole my mouse over the Visible property of one of the menu items and it says 'False' while the 'bool visible' value says 'True.' I press F10 to step to the next line of execution and... Nothing! It just doesn't take. All that being said, I found a way around it by accessing the individual members of the Context Menu by their item number instead of using the Menu Items directly: bVisible = (((TextBox)mi_EasterEggs.SourceControl).Name == TextBox1.Name); mi_EasterEggs.Items[0].Visible = bVisible; mi_EasterEggs.Items[1].Visible = bVisible; mi_EasterEggs.Items[2].Visible = false;Why would this work when accessing the Menu Items by name does not? Also (while I have your attention and now that I have the context menu working), is there a way that you know of to override the default Context Menu that comes with a TextBox so that I can just add to it? I'd like to keep the default 'copy, cut & paste' Context Menu and just add a few lines.
-
Ok, I've got this working, and it does great: private void mi_EasterEggs_Opening(object sender, CancelEventArgs e) { if (sender.Equals(mi_EasterEggs) == true) { if (mi_EasterEggs.SourceControl is ListView) { mi_RawView.Visible = (0 < ListView1.Data.Count); } else if (mi_EasterEggs.SourceControl is TextBox) { bool visible = (((TextBox)mi_EasterEggs.SourceControl).Name == TextBox1.Name); mi_FontArial.Visible = visible; mi_FontCourier.Visible = visible; mi_RawView.Visible = false; } } }...except the Menu Items do *not* become visible. The 'visible' variable can be True, but as I step over the two Font Items, they remain False. If anyone knows what is up with this, please chime in! I'm going to attempt accessing the Menu Items fromt the Context Menu instead of directly to see if this works. Also, I still don't know the best way to impliment the default Context Menu...
-
I've got one Context Menu named mi_EasterEggs with three (3) menu items: * mi_FontArial * mi_FontCourier * mi_RawData All menu items have their Visible properties set to False. This context menu is included in 1 ListView control and 1 TextBox control. When one of these controls is right-clicked (to bring up the Context Menu), I want to make menu items viisble depending on what item was right-clicked. I tried this code, but the sender is always the mi_EasterEggs Menu Item: private void mi_EasterEggs_Opening(object sender, CancelEventArgs e) { if (sender.Equals(ListView1) == true) { mi_RawView.Visible = (0 < ListView1.Items.Count); } else { mi_FontArial.Visible = sender.Equals(TextBox1); mi_FontCourier.Visible = sender.Equals(TextBox1); mi_RawView.Visible = false; } } I searched some posts here on Context Menus and saw where Plausibly said to look at the .SourceControl field, so I modified my listing to this: private void mi_EasterEggs_Opening(object sender, CancelEventArgs e) { if (mi_EasterEggs.SourceControl == ListView1) { mi_RawView.Visible = (0 < ListView1.Items.Count); } else { mi_FontArial.Visible = (mi_EasterEggs.SourceControl == TextBox1); mi_FontCourier.Visible = (mi_EasterEggs.SourceControl == TextBox1); mi_RawView.Visible = false; } }It still doesn't work, though. What am I doing wrong? Also, I'd like to still have the default Context Menu for the TextBox Control, but this is a bonus and is not necessary. First thing is first, right?
-
Thanks! I'll put the "IsDbNull" version to work on Monday morning!
-
Re: Nullable types Thanks, MrPaul. I'd seen variables declared using a Question Mark (?) before, but I had no idea what they were called, so there was no way to look them up. Now, I know how to set a DateTime to a null value, and I know what the Question Mark means! I got a 2-for-1!
-
I like using store procedures because it allows me to specify what the format of my values are going to be ahead of time however, the SQL command SELECT GetDate does not have this option. Below is how I solved it, and I am looking for advice as to whether or not it is a good technique or if there is something more elegant: Particularly of interest: Do I need to cast the CurrentDateTime to a DateTime object, or should the SqlDataReader already be returning it in this format? DateTime sqlTime; try { m_db.Open; using (SqlCommand cmd = new SqlCommand("SELECT GetDate AS [CurrentDateTime]", m_db)) { SqlDataReader r = cmd.ExecuteReader(); while (r.Read() == true) { sqlTime = (DateTime)r["CurrentDateTime"]; } } } catch (InvalidOperationException e) { Console.WriteLine(e.StackTrace); sqlTime = DateTime.Now; } catch (SqlException e) { Console.WriteLine(e.StackTrace); sqlTime = DateTime.Now; } finally { m_db.Close(); }
-
Some of you may be wondering, "Why would you want a null DateTime?" Here's an example of somewhere that I have to initialize the DateTime object with data that is *not* what I want: /// <summary> /// Synchronize the Time on the SQL Server with the time on the device /// </summary> private void SyncWithSqlTime(DateTime sqlTime) // pass in or query for time to set on device { SYSTEMTIME st = new SYSTEMTIME(); sqlTime = DateTime.Now; // checking to see if sqlTime has been set doesn't seem possible m_lastError = string.Empty; try { m_db.Open(); // Sql Connection object using (SqlCommand cmd = new SqlCommand("SELECT GetDate() AS [CurrentDateTime]", m_db)) { SqlDataReader r = cmd.ExecuteReader(); while (r.Read() == true) { sqlTime = (DateTime)r["CurrentDateTime"]; } } } catch (InvalidOperationException e) { Console.WriteLine(e.StackTrace); } catch (SqlException e) { Console.WriteLine(e.StackTrace); } finally { m_db.Close(); } st.FromDateTime(sqlTime); // Convert to SYSTEMTIME SetLocalTime(ref st); // PInvoke Win32 API to set time }
-
How do I check for an uninitialized DateTime? If I start my code by simply declaring a DateTime value: DateTime time1; Then the compiler gives me the error that the field was uninitialized. Seting the DateTime value to null is not legal though, it seems: DateTime time1 = null; How am I supposed to be initializing a DateTime value?
-
Plausibly:That's a neat idea, and I've expanded on the concept in a custom form with a progress bar for a worker thread.public static ProgressForm Instance { get { if ((_instance == null) || (_instance.IsDisposed == true) || (_instance.Cancelled == true)) { _instance = new ProgressForm(); //} else { // _instance.BringToFront(); // this is used for Mdi Children // _instance.Focus(); // this is used for Mdi Children } return _instance; } } Notice I had to include a check for _instance.Cancelled. This is because I call my progress form modally: // ...Initialize, etc. bgWorker.RunWorkerAsync(); if (bgWorker.IsBusy == true) { m_frmProgress = ProgressForm.Instance; try { m_frmProgress.ShowDialog(); m_frmProgress.Dispose(); } catch (Exception err) { Console.WriteLine(err.Message); } finally { m_frmProgress = null; } } Both above (in the creation) and below (when the thread completes) I have coded a way to close the modal progress form: private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (m_frmProgress != null) { try { m_frmProgress.Close(); } catch (Exception err) { Console.WriteLine(err.Message); } finally { m_frmProgress = null; } } } The part about Closing the Progress Form and distroying it in both places seems redundant, but I don't know where the best place is for ensuring the form goes away after the thread has stopped. Any suggestions?
-
In my Mdi Form with more than one Mdi Child open: If the active, Maximized form is disabled during a lengthy call, it is sent to the back. If I then bring the form back to the front after the call (BringToFront), the child form's WindowState is no longer Maximized. Is this a bug, or is this by design? I would typically set a form's Enabled state to false while making any SQL call, then reset it to true afterwards. This technique looks and works nice; also, our employees have no problems using it. Now that I have moved the form into an Mdi Container, I get these issues. Should I simply not disable a form if it is an Mdi Child in an Mdi Container?
-
Sounds like the form you are showing should *not* be an MDI Child. Just call it like you would a regular form, the use ShowDialog() like you always would. Again, do not set the MdiParent on this particular form, because it sounds like you are not wanting this to be an MDI Child form. I realize this is coming years after you posted the question, but I just happened across it and understood what you were asking. It looks like others might have missed it.
-
Wow! All that knowledge, and SQL power too! You must get paid the big bucks! :) Ok, I'll have to wait until Monday morning to give that a shot. Darned company closes on Saturday. {sigh} On a personal note: We're over by Dallas, TX and Ike will be visiting us in an hour or so. How exciting!
-
We have two tables that I need to write a query for. I am a Software Developer, and we do not have any Database Admins here. TableA: |_varchar(50)_|_char(15)_|_char(10)_|_varchar(99)_|_DateTime_| |_Employee____|_ModelNum_|_Station__|_Status______|_TestDay__| TableB: |_char(15)_|_varchar(50)_| |_ModelNum_|_ModelName___| Though no primary key exists for the two tables, TableA's ModelNum *does* map to TableB's ModelNum. How would I get: TableA.Status, TableA.ModelNum, and TableB.ModelName WHERE (TableA.Station='Testing') AND (TableA.TestDay between (Date1 and Date2)) AND (TableA.Employee from TableA.Station='Building') Here is the scenario: Employee 'John' assembles units at the 'Building' Station. Sometime later, these uints arrive at the 'Testing' Station where they are tested by others. For a given date range at the 'Testing' Station, we need the ModelNum, ModelName, and Status at the 'Testing' Station for all coils that 'John' built at any time in the 'Building' Station. How would I write such a query? I am interested in seeing ways to write this query - simple or elegant! Bonus points if I can get this query to return a count of the distinct ModelNames! (though I can do this manually in my software)
-
Nate - your query of Active Directory worked! Cool. I've never made a query to Active Directory before. Thanks!
-
Thanks Plausibly, but we are stuck in the middle ages (.Net Framework 2.0, VS2005, and XP). I suppose I'll have to wait before I get to learn LinQ. At least we are moving out of the stone age! (VB6) Nate: We do have AD here, though I've never done anything with it. Let me give your code a quick test and I'll get back with you!
-
Some of our apps need passwords to access parts that should only be available to management. We could develop our own and require management to remember yet another password that we would have to take care of resetting whenever they forget, lock themselves out, or whatever... But, what if we could tap into the Windows Login? Can that be done? Here's what I'm thinking: Call a login box (ours or Windows') and have them enter their username and password. If the username/password combination matches, we activate features if they are in management. I don't really need to know how the Windows Login works - I would just like to call it and get the results. Can that be done? If so, how? If not, what is another solution (besides reinventing the wheel)?
-
Ads are causing squashed posts
joe_pool_is replied to MrPaul's topic in Suggestions, Bugs, and Comments
I was just know wondering where I could find me some good bailing cord, too! Thanks Nate! -
Ads are causing squashed posts
joe_pool_is replied to MrPaul's topic in Suggestions, Bugs, and Comments
Thanks for saying something about that, MrPaul. I've noticed them for a while and just assumed it was something we had to live with to get the message board. I'm ok with the ads - sometimes they are even helpful! But I don't like having to work around them quite that much. -
I've just recently learned about the Installer class in Visual Studio. There are several websites that talk about how to set different parts of the Installer class and how to get it to do different things, but nothing has really shown me how to start an Installer project. Does anyone know of a tutorial on this? Is there a website that steps through the process? Is there some other keyword that I should be searching on? Thanks for any feedback - even if you stumble upon this years from now. I'm open to more input!
-
Ajeesh, After reading your post, I started Googling and looking through the MSDN help. There is a lot of information on how to set different aspects of this Installer class, but nothing seems to say, "Here is where to start if you want to use the Installer class." Since I've never heard of this Installer class, I think I will post a new thread asking about it.