This is a preview version of Cyotek's blog and may be missing functionality and/or unstable. Please visit https://www.cyotek.com/blog for the current version of the blog.
If you encounter any problems using this preview site, please contact us with the details.

New option in Visual Studio 2019 keeps console window open after debugging

4 Comments

For as long as I've been writing console applications, I've at the end of Main I've always had a piece of code to require user input before exiting when in debug mode, in order to review any output before the window closes. Not an onerous task, but one I immediately do as soon as creating a new application.

Today I created a new .NET Core console application in Visual Studio 2019 preview and added by code without a second thought.

Read More

Reading cookies from Internet Explorer

c# interop webbrowser InternetGetCookieEx cookie 0 Comments Downloads

In order to work around cases where it wasn't possible automatically authenticate with a website, I wanted the ability to use an embedded Internet Explorer window for manual authentication and then reuse the cookies. This article describes how to read cookies indirectly using InternetGetCookieEx or directly from a WebBrowser control.

The InternetGetCookieEx Win32 API can be used to read cookie name value pairs for a given URI. You can use it to read all cookies or a named cookie. You can also specify which type of cookies to include.

Read More

Using message filters in Windows Forms applications

c# winforms pinvoke IMessageFilter 0 Comments Downloads

For a utility application, I wanted to add an item in the system menu. It's been quite a long time since I last did this (and was in VB6), so I decided to find some ready made source code. This class provides a nice little helper for wrapping the system menu to add new commands to it, but it requires the owner form to hook into its window procedure and forward messages on which I felt was an awkward design.

The code snippets below should illustrate my point - first we initialise the instance of the SystemMenu class, but in order for custom commands to be processed we have to override to override the form's WndProc and pass any messages received into the SystemMenu class.

Read More

Tools we use - 2018 edition

tools 2 Comments

Happy New Year! While once again it's that time for the list of software products and services I personally used throughout the previous year, it's also a birthday of sorts - this year will be the 10th year since Cyotek was reactivated after being shut down and also since I started blogging for the first time.

Very little change from previous years, this may change as I force myself to move to .NET Core.

Read More

Checking if your Windows Forms applications are ready for .NET Core 3.0

windows forms wpf .net core 2 Comments

Since the recent announcement that .NE Core 3.0 would support Windows Forms, I've been cautiously optimistic. Over the last week or so I've finally started experimenting with ASP.NET Core 2.1 and liking what I see (mostly, I haven't made my mind up with Razor Pages yet!).

A couple of days ago Microsoft made another announcement - a tool to scan your existing Windows Forms / WPF applications and see if how much of the API's they use are supported by Core 3.0.

Read More

Upgrading a SVN repository using VisualSVN Server

svn upgrade visualsvn svnadmin 0 Comments

Although I use Git for anything open source we produce, all other code is still in a SVN repository. I use VisualSVN Server for the server side things. When upgrading it last week to the latest version, it mentioned that Apache SVN 1.10 had new compression options and it occurred to me that while I've upgraded working copy formats before, my SVN databases are probably still using whatever format they were created at. This article covers how to upgrade SVN repositories using the VisualSVN Server software.

According to the release notes, the current filesystem format version used by SVN is 8. We can either use the svnadmin info command to view the version, or via a GUI by right clicking a repository in the Visual SVN Server Manager, selecting Properties from the context menu then accessing the Details tab.

Read More

Working with CorelDRAW Palettes part 2, writing .pal files

c# color rgb color palette cmyk coreldraw 0 Comments Downloads

In my previous article, I described how to read an archaic CorelDRAW! 3.0 palette file. This continuation covers how to write files in this format.

Just like reading the file, writing is also a simple enough process.

Read More

Working with CorelDRAW Palettes part 1, reading .pal files

c# color rgb color palette cmyk coreldraw 0 Comments Downloads

I recently picked up a copy of CorelDRAW! 3.0 from eBay which came on two CD's with a different version on each. That gave me two different surprises, the first in that 3.0A wasn't an improved version of 3.0, and secondly instead of the .cpl format I was expecting to find, there were two different .pal formats, one text based (for CorelDRAW!) and one binary (for PHOTO-PAINT! (very shouty this software!)). This first article covers reading the text based palette format.

The palette format itself is simple enough, from the example colours below we can infer that each colour entry is in CMYK format with the range 0-100. Although it looks as if it is a fixed width format, when looking at other palettes using this format this isn't the case and columns can be of differing widths.

Read More

Converting colours between RGB and CMYK in C#

c# color rgb cmyk 2 Comments Downloads

In my previous articles on reading and writing colours from various palette/swatch formats, I left CMYK conversion as an exercise for the reader and only demonstrated RGB aspects. This article demonstrates how to convert colours in CMYK format to RGB and vice versa.

Unlike RGB which generally uses the range 0-255, most examples of CMYK I've seen use percentages instead, e.g. 37% cyan, 18% magenta, no yellow and 31% black. In this article I'm using the range 0-1 to describe the colours. (Just to be awkward, the demonstration front end uses 0-100 to make it more user friendly!)

Read More

Displaying text in an empty ListBox

c# winforms WM_PAINT listbox wm_erasebkgnd 3 Comments Downloads

While looking at ways of improving the UI of a dialog in an application, I wanted to display some status text in a ListBox control that was empty. The default Windows Forms ListBox (which uses the underlying native Win32 control) doesn't support this, but with a little effort we can extend the control.

When a Control receives either the WM_PAINT or WM_ERASEBKGND messages, it will check to see if the ControlStyles.UserPaint style is set. If set then the WM_PAINT message will cause the Paint event to be raised, and for WM_ERASEBKGND the PaintBackground event - but only if the the AllPaintingInWmPaint style is not set.

Read More