The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘WinForms’ Category

Automated testing Windows applications using Katalon and WinAppDriver

Posted by jpluimers on 2020/10/21

[WayBack] Top 45 Best Automation Testing Tools Ultimate List • Test Automation Made Easy: Tools, Tips & Training Awesomeness A few notes, partially related to Enable your device for development – UWP app developer | Microsoft Docs.

One research project I had a while ago, was to see how it was possible to use a generic testing tool like Katalon Studio (that can test many platforms), for testing Windows applications.

Katalon uses a Selenium interface that normally is used for web applications through the [WayBack] WebDriver protocol (formerly [WayBack] JsonWireProtocol) that continues to be updated: [WayBack] draft upcoming WebDriver protocol, which is more generic than just web applications:

Read the rest of this entry »

Posted in .NET, Conference Topics, Conferences, Delphi, Development, Event, Software Development, Windows Development, WinForms, WPF | Leave a Comment »

Full Duplex Asynchronous Read/Write with Named Pipes – CodeProject

Posted by jpluimers on 2018/08/21

When you run on Windows: [WayBackFull Duplex Asynchronous Read/Write with Named Pipes – CodeProject

via:

–jeroen

Posted in .NET, C#, Development, Software Development, WinForms | Leave a Comment »

.NET/C#: Chaning the ForeColor of a ReadOnly/Disabled TextBox (via: Stack Overflow)

Posted by jpluimers on 2014/12/24

Once every while you still do WinForms work, and bump into something you hadn’t bumped into before.

This time it was trying to set ForeColor = Color.Red on a ReadOnly TextBox for displaying error messages:

  • Using a TextBox means the user can still copy the text to the clipboard.
  • Using a Red foreground draws enough attention (it’s was an app with a really busy user interface).

When setting a TextBox from ReadOnly = false to true sets the BackColor from SystemColors.Window (usually white) to SystemColors.Control (usually light grey), and leaves the ForeColor to SystemColors.WindowText (usually black).

Setting ForeColor = Color.Red (funny there is a plural in SystemColors but not in Color) it doesn’t display it as such:

To my surprise, the TextBox had ReadOnly text (you could copy, but not modify it), which showed with a a grey (SystemColors.Control) BackColor and a black (SystemColors.WindowText) ForeColor: the defaults for a ReadOnly TextBox, not using my ForeColor = Color.Red;

I vaguely remembered there was some odd way of solving this, but since I hadn’t written a blog article about it back then (somewhere around .NET 1.x or 2.0 I didn’t have a blog yet), I was glad that Cheetah posted this answer on StackOverflow: Read the rest of this entry »

Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Color (software development), Development, Software Development, VB.NET, VB.NET 10.0, VB.NET 11.0, VB.NET 7.0, VB.NET 7.1, VB.NET 8.0, VB.NET 9.0, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, WinForms | Leave a Comment »

WinForms Container Controls 5: FlowLayoutPanel

Posted by jpluimers on 2014/03/24

When using a FlowLauyoutPanel, I always forget on which control the FlowBreak design time property / SetFlowBreak run time method operates.

Then I always end up writing a short demo program like Container Controls 5: FlowLayoutPanel.

It operates after the control on which you set it.

It is like text in a Word Processor: it breaks after the place where you set the break. Read the rest of this entry »

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, WinForms | Leave a Comment »

Samples Environment for Microsoft Chart Controls – Release: Samples for Chart Control – .NET Framework 4

Posted by jpluimers on 2013/06/19

I hadn’t done Charting for a while, but these got going very quickly:

Samples Environment for Microsoft Chart Controls – Release: Samples for Chart Control – .NET Framework 4.

There are example downloads for ASP.NET and WinForms requiring .NET 4 or higher.

In addition, these starting points also proved to be really helpful:

Since my objective was adding charts to an existing WinForms business app, this was the namespace at hand: System.Windows.Forms.DataVisualization.Charting Namespace ().

If you are at .NET 3.5, then start at DataVisualization.Charting.Chart simple example – C# – Snipplr Social Snippet Repository.

–jeroen

Posted in .NET, .NET 4.0, .NET 4.5, ASP.NET, C#, C# 3.0, C# 4.0, Development, Software Development, VB.NET, Visual Studio 2010, WinForms | Leave a Comment »

excel “not enough storage is available to complete this operation (exception from hresult: 0x8007000e (e_outofmemory))” – Google Search

Posted by jpluimers on 2013/04/16

So I won’t forget to research this:

excel “not enough storage is available to complete this operation (exception from hresult: 0x8007000e (e_outofmemory))” – Google Search.

Somehow this occurs with Excel and the .NET app only having a few dozen megabytes of memory in use, so the cause must be something a lot more simple than “out of memory”.

It is a complex export, but I might just be able to get this going using ADO.NET, and make sure it is not a 60+k rows or 60+k characters issue.

–jeroen

Posted in .NET, .NET 4.0, C#, C# 4.0, Development, Excel, Office, Power User, Software Development, Visual Studio 2010, WinForms | Leave a Comment »

Reminder to self: you cannot repeatedly draw anti-aliased text without damaging the background

Posted by jpluimers on 2013/04/11

A small duh moment when I found this out myself the hard way: when repeatedly drawing anti-aliased text, it will alter the background on each draw.

So you cannot do that. Not in Delphi, not in .NET, not in Cocoa, nowhere (:

–jeroen

via: delphi – “Additive” text rendering on TCanvas? – Stack Overflow.

Posted in .NET, Delphi, Development, FireMonkey, Software Development, User Experience (ux), WinForms, WPF, XNA | 7 Comments »

Converting Visual Studio 2003 WinForms to Visual Studio 2005/2008/2010/2012 partial classes (via: Duncan Smart’s Weblog)

Posted by jpluimers on 2013/01/10

In the .NET 1.x past, the WinForms designers in Visual Studio .NET and Visual Studio 2003 would put the C# or VB.NET code containing the form code as the InitializeComponent method of the top most class monolithic C# and VB.NET files that also contain the user code (for events and such).

As of Visual Studio 2005 (actually: Whidbey and higher), this code is based on partial classes. For each form (actually designable entity, but lets limit this to WinForms forms) you get a MyForm.cs and MyForm.Designer.cs

As a side note, with a bit of effort, you can generate the Windows Form Designer generated code yourself as this answer shows. This is for instance convenient when you have form definitions in a different technology and want to convert it to WinForms, WPF or another form of designer based .NET code.

I long time ago I wrote a short manual for co-workers on converting the monolithic files (for people interested, it is below).

Since then I found a couple of very interesting links: Read the rest of this entry »

Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, WinForms | 1 Comment »

.net – WinForms Load vs. Shown events – Stack Overflow

Posted by jpluimers on 2012/10/31

The order of events and what you can do in events is very important in Windows applications.

This includes the WinForms applications – still popular for business applications – the first .NET framework that supported building Windows applications.

WinForms has two important event/method combo’s:

In descendants, you override the methods. In the form designer, you use the events.

Both the methods and events rely on Windows messages to get fired. This means they depends on which message loop is active. And this limits in what you can do during them.

One of the things you should not do in Load or Show is perform a MessageBox, ShowDialog or any other form of message pumping (like in COM).

Hans Passant explains it this way:

Avoid using MessageBox.Show() to debug this [ed: debug Shown/Load behaviour]. It pumps a message loop, disturbing the normal flow of events. The Load event is triggered by Windows sending the WM_SHOWWINDOW message, just before the window becomes visible. There is no Windows notification for “your window is now fully shown”, so the WF designers came up with a trick to generate the Shown event. They use Control.BeginInvoke(), ensuring the OnShown() method gets called as soon as the program goes idle again and re-enters the message loop.

This trick has lots of other uses, particularly when you have to delay the execution of code started by an event. However, in your case it falls apart because you use MessageBox.Show(). Its message loop dispatches the delegate registered with BeginInvoke(), causing the Shown event to run before the window is shown.

Krishnan Sriram explains that if you use proper debug logging (see what Hans wrote), you get this order of events:

  1. Form – Client Size Changed : 8/14/2010 10:40:28 AM
  2. Form – Control Added – button1 : 8/14/2010 10:40:29 AM
  3. Form – Constructor : 8/14/2010 10:40:29 AM
  4. Form – Handle Created : 8/14/2010 10:40:29 AM
  5. Form – Invalidated : 8/14/2010 10:40:29 AM
  6. Form – Form Load event : 8/14/2010 10:40:29 AM
  7. Form – Loaded : 8/14/2010 10:40:29 AM
  8. Form – Create Control : 8/14/2010 10:40:29 AM
  9. Form – OnActivated : 8/14/2010 10:40:29 AM
  10. Form – Shown : 8/14/2010 10:40:29 AM
  11. Form – OnPaint : 8/14/2010 10:40:29 AM
  12. Form – Invalidated : 8/14/2010 10:40:29 AM
  13. Form – OnPaint : 8/14/2010 10:40:29 AM

Finally, Ahmed Said indicates that there can be form size differences in the Load and Shown state:

The Shown event occured after the load event, the main difference is not in the visibility but in state of the form (width,hieght,..etc). I will give you an example to clarify if we create a form with default size 100,200 and set the windowstate = Maximized in the load event the size will be 100,200 but in shown event the size will be your screen size

–jeroen

via: .net – WinForms Load vs. Shown events – Stack Overflow.

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, WinForms | Leave a Comment »

Great session on how to prevent SQL Injection Myths and Fallacies

Posted by jpluimers on 2012/08/15

A few weeks ago, Bill Karwin did a must watch webinar on the prevention SQL Injection titled  “SQL Injection Myths and Fallacies“.

Bill Karwin (twitter, new blog, old blog, Amazon) is famous for much work in the SQL database community, including InterBase/Firebird, mySQL, Oracle and many more.

He also:

Anyway, his webinar is awesome. Be sure to get the slides, watch the replay, and read the questions follow up.

Watching it you’ll get a better understanding of defending against SQL injection.

A few very valuable points he made: Read the rest of this entry »

Posted in .NET, .NET 3.5, .NET 4.5, .NET ORM, ASP.NET, Batch-Files, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C++, Cloud Development, COBOL, CommandLine, Database Development, Delphi, Delphi for PHP, Delphi x64, Delphi XE2, Development, EF Entity Framework, F#, Firebird, FireMonkey, History, InterBase, iSeries, Java, JavaScript/ECMAScript, Jet OLE DB, LINQ, LLBLGen, MEF, Microsoft Surface, Mobile Development, PHP, PowerShell, Prism, Scripting, SharePoint, SilverLight, Software Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7, VB.NET, VBS, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, Web Development, Windows Azure, WinForms, WPF, XAML, xCode/Mac/iPad/iPhone/iOS/cocoa | 1 Comment »