Context: So I wanted to implement drag and drop with files the quick and dirty way; specifically,
WM_DROPFILES. (You can also do this with COM, but it’s a bit more involved, especially from raw C. I haven’t written about drag and drop yet, so the comparison is covered elsewhere for now.) My use case is simple, so I didn’t need the benefits or complexity of COM drag and drop. Turns out it’s just marking it as having the extended style in the resource editor or calling
DragAcceptFiles, or so I thought. While I could get my dialog to accept the files, I couldn’t get the list view to do so. It turns out that the list view doesn’t handle these messages, nor does it send a notification back to the parent.
One strategy to deal with this is subclassing, although we aren’t going through the formal channels to do. That’s trickier, because it involves using things like
CreateWindowEx, and might be a pain with dialog resources that already have a list view. Instead, we’ll actually replace the window procedure out from under the already materialized dialog control – basically monkey patching. In fact, Microsoft’s own documentation mentions this (and a better way with caveats). However, it doesn’t provide a concrete example. This article will quickly show you how, and provides an interesting, if brief example of Windows API principles.
If you need the icons for files in a Windows program, the easiest way to do so is with the system image list. This is an image list (a resource containing icons, mapped by index) that caches those system icons. The advantage of being an image list is you can easily associate it with a control (like a ListView) and pick out the images by their index, or draw out of it.
Short post: On Windows, UTF-16 was the dominant locale, and UTF-8 was something only to convert to and from. (Microsoft jumped the gun before Unicode expanded the address space.) While it got better (Windows 10 can use UTF-8 as an MBCS locale with ANSI APIs), it was historically a lot worse.
For converting, you’d use the
MultiByteToWideChar and its opposite
WideCharToMultiByte. On legacy Windows, they have slightly confusing semantics. Specifically, with flags. While Vista on introduced many flags that can be used with the UTF-8 codepage (to deal with the quirks of conversion, like invalid characters), previously only
MB_ERR_INVALID_CHARS was allowed, and only if you were running XP or 2000 SP4. Before that, you can’t have any flags if you’re converting to or from UTF-16 and UTF-8. It’s unfortunately a little dangerous, but that’s the rub.
Hot on the heels of another Git-related article that was making the rounds recently, I was reminded of Git’s own structure and how it influences user experience. Specifically what we assume is part of how Git works, is actually a part of the porcelain (in Git speak, the user interface and commands that back it). As someone developing a Git client, it’s interesting to think Git’s user experience could be significantly different with a different interface, particularly because people have a particular mental model of Git influenced by the default interface. Said influence is enough that libgit2’s API emulates the porcelain’s semantics, in-process.
One of my new favourite features in Apache is managed domains (MDomains). While before, you might need certbot or another client to manage the certificates and even massage the configuration, MDomains provides a nice idiomatic way to automatically fetch and install the certificates.
I had a simple Win32 application fail to create its window (in my case, a dialog box, using either
DialogBox). I got back the error 0x583; unable to create window class. If I forced the window style on my dialog to create regardless of errors, my dialog was empty.
It turns out I was using themed controls in my manifest, but I didn’t call
InitCommonControls. After that, my application worked.
Brief post, but I was porting a C89 project to Visual C++ 6 (don’t ask) when I found something really fun. Turns out “
long long“, the type everyone assumes is the 64-bit type in C, is actually a GCC extension. MSVC uses…
_int64, a different extension. Great, had to convert a bunch of code. You’ll get this fun error from old MSVC when it sees it:
error C2632: 'long' followed by 'long' is illegal
(Note that MSVC will probably assume your C code is C++, which does mean you get some stuff from C99 for free like single-line comments… but then initializers are different between C and C++, and C++ only added
long long in C++11…)
It’s an unfortunate gotcha for those who assume they’re writing standards compliant C89. The reason might be deflated when you have to define your own 64-bit integer with
#ifdef. Oh, and let’s not forgot “long long” could mean 72-bit on your 9-bit byte system, of course. That’s why
stdint.h exists…. except, oh, C89.
I’m trying out Navidrome, a lightweight alternative to Airsonic, and I had difficulty with my music seemingly being tagged various artists when it shouldn’t (sometimes with different tracks), and albums with various artists being considered separate albums. Obviously, this is pretty annoying since I haven’t seen other music library software do it.
tl;dr: As much as I respect the efforts undertaken by groups like Gnome and elementary, I have to wonder if what they’re building is barely enough, and provides an illusion of substance.
There’s been a lot of effort spent on the Linux desktop. The groups I respect the most on this front are Gnome and elementary, due to their focus on UX design and trying to do new things. While Gnome has been controversial due to their design and stance towards design, I think a lot of the controversy on that front is unmerited (i.e Gnome’s design isn’t actually appropriate for tablets as much as the peanut gallery thinks). I appreciate that someone is trying to do something other than “Windows 98 stomping on a human face, forever”, and it’s what I use on my desktop. Controversial for other reasons (also unmerited, a man’s gotta eat; that desktop won’t happen with getting paid in exposure), elementary’s design has been considered very nice (often making it recommended for “my first distro”), if a bit derivative at first glance. What makes it more interesting in the morass of many OSS UX clones is UX as a priority/value (instead of something that’s just there) and iterating on existing UX. Sometimes it works out, doesn’t it doesn’t, but I respect the attempt at trying something new and seeing if it’s better.
However, I wonder if what they’re doing is enough. They have a desktop, many components of that desktop, and human interface guidelines (elementary, Gnome); all components you need. What I think is missing is the substance. Where’s the ecosystem of applications that embrace the HIG, and how does the intricacies of the of the environment come into play for complex applications and situations?
tl;dr: Convergence is a “white elephant” that platforms chase, only to realize there is little appeal. If it’s not a lark, it puts everything else at stake.
One of the biggest buzzwords is “convergence” – the idea that with some additional cables or gadgets, you can turn your smartphone into a laptop. Platform makers have been targeting such a thing for years, pouring millions and changing platforms for it. Yet after all of this investment, there has been very little buy-in from consumers. Why is this?