( Index )
Month

 

Brief Information about the February 2016 CSIG Meeting

Debugging and Troubleshooting ......    by B. Arnold

NEWS:   http:// www.techsupportalert.com /content/microsoft- visual-studio- now-free-non- commercial-use.htm

(General Csig Info)   

                             

Welcome to the CSIG, a Special Interest Group of the ACGNJ. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

This month's topic will be "Troubleshooting and Debugging of Visual Studio programs with emphasis on C# and C++.  We will discuss a program that I presented in November and how it has evolved do to problem solving.  Over the years I have found that a significant amount of project time is often spent on debugging.  It's quite common for debugging to take 50 percent of a project's estimated development time.  Since managers seldom allow more that 10 percent on project estimates, this can be a source of extreme frustration.  An excellent book on the subject is "The Mythical Man-Month" by Frederick Brooks, Jr.  Check it out on Wikipedia along with Murphy's Law. Although the presentation will include some real-life issues on multi-thread code, attendees are incouraged to bring in examples of their own trouble shooting experiences and history.


This is a CLI DOT NET program is coded using C-sharp (C#) and is very similar to C++.  It also still uses the same DOT NET libraries.

The program uses a number of DOT NET Library functions including the following:
DragDrop Windows Forms CLASSES Buttons
DialogResult GetDataPresent Image Close
Show Dispose C# Format
String Button_Click DOT NET Rectangle
Height Width MouseDown DragEnter
GetProperty PropertyInfo GetValue Graphics
Drawing2d SaveFileDialog MessageBox Visible
IntersectsWith Rectangle Intersect Stack
Stack.Push Stack.Pop Stack.Count Timer

There are a number of ways to refer to Microsoft's latest compilers and code. Here's what Wikipedia says: The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework. The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.

Microsoft .Net Framework 4.5
C++ 9.0, etc.
.Net 4.5, etc.
CLI
Common Language Infrastructure



Troubleshooting



Sample Code from Previous Meetings

namespace Crop { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //////////////////////////// ////////////////////////// // // Suffix _SC = Screen Coordinates // Suffix _CC = Client Coordinates // Rectangle cropRectangle_CC; Point startPoint_CC; bool isDrag = false; bool fileChanged = false; //////////////////////////// ////////////////////////// // // Drag and Drop step 3 of 3. The users releases the mouse to drop the image. // private void Form1_DragDrop(object sender, DragEventArgs e) { if (fileChanged) // Prompt user. { // Title = Bad Result // Default Button = No // Message = Caution System.Windows.Forms.DialogResult Result; Result = MessageBox.Show(this, "Cropped Image will be Disregarded! Continue?", "Drop New File", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (Result != System.Windows.Forms.DialogResult.Yes) return; } if (e.Data.GetDataPresent(DataFormats.FileDrop)) { if (this.pictureBox1.Image != null) this.pictureBox1.Image.Dispose(); // Get a list of filenames but use only the 1st name. string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files.Length > 0) { files[0] = files[0].ToLower(); if (files[0].EndsWith(".jpg")) { try { this.pictureBox1.Image = Image.FromFile(files[0]); imageData.Text = String.Format("{0} x {1}", pictureBox1.Image.Width, pictureBox1.Image.Height); fileChanged = false; this.pictureBox1.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "E R R O R"); return; } } } } this.Activate(); } // Drag and Drop step 2 of 3. The users drags the image into the program's GUI. // Note: Step 1 is Form1 AllowDrop property has been set to true. // private void Form1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; }

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page