"Not to interrupt you or anything, but before you get started on one of your long boring introductions, I should point out that I already scrolled down to the picture and this looks suspiciously like that thing you wrote before... what's the deal?"
Yeah, it's basically the same thing. If anything, it actually has less functionality.
"But why are you always rewriting things you already wrote? Have you run out of original ideas? And of all the things to rewrite, why choose the one that nobody ever used in the first place?"
You don't know what it's like - every day Nikos sends me hateful email calling me a "script kiddie" and generally denigrating my endeavours with AutoIt - he throws sand in my face and everything - he's just a big bully and it begins to wear down my self-esteem. So I seek comfort in the things I know.
![Wink :wink:](./images/smilies/icon_wink.gif)
"Well, ok, I can understand that - he always did come across as a bit aloof - but what's so special about this utility thing? Most people don't even know what Reparse-Points are, never mind want to mess around with them. Can't you just write nice pleasant helpful script for once that doesn't involve all your usual technical rigmarole? Not everything needs to be explained in excruciating detail you know!"
They say the devil is in the details, and there's a few things about this project that aren't immediately obvious to the casual reader; it contained all the ingredients that I needed: 1) The stuff "behind the scenes" was sufficiently complex to be challenging, yet familiar enough to be achievable, and 2) the GUI element was both simple and yet deceptively complex at the same time. It's really this last thing that was the crux.
"Ok, fine, I'll hear you out: make it good though, my attention span hasn't improved in recent years. And since Google went and changed their logo last week, nothing has been the same in my life - why does everyone always feel the need to mess with crap that doesn't need fixing?"
And that, curiously enough, is what it's all about. In the last few years the AutoIt scripts that I've been writing have begun to develop a rather schizophrenic disposition: on the one hand they're containing more and more technical esoterica from the Windows API, while on the other being smothered in the simplicity of scripting where everything is designed (to put it bluntly) for idiots. So I decided to finally do something about this imbalance, and therein started a little adventure of getting sidetracked by one thing after another.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
So, to put it simply, the last time I wrote a programme in a non-scripting language was at least 25 years ago. Back then there weren't any GUI's - or, rather, there were, but they were Windows made of textually drawn elements and inverted-colour backgrounds meant to give the impression of dimensionality - but, well, like the rest of life, it was all just clever fakery.
And then I put aside my childhood toys and walked away from computers (and everything else) never to touch another one for about 16 years. You'll never see or experience anything of the real world (the subtlety of pain, the deception of suffering, real loneliness in a historical perspective) if you're using a computer, or computerised toy. Throw away your smart-phones kids! Let thee delude thyself no longer!
![Wink :wink:](./images/smilies/icon_wink.gif)
But about 7 years ago I built a PC from parts for a lark, just to see what's new and different. And I thought to myself, "I know, I'll get myself a copy of Visual Studio and get back into this C thing!" Well, it turns out that in the intervening years all sorts of bullshit was added to Windows: ATL, MFC, WTL, .NET and some idiot even added "++" to the good old trusty C language! Ugh, the audacity of change and so-called progress! Fakery! Nonsense! Balderdash!
To put a long story short, I never could get comfortable with Visual Studio. It always seemed to install gigabytes of so-called "helpful" rubbish that I never wanted... I don't need services for managing SQL, thank you... no, I won't be developing "Web-Apps" or "Phone-Apps", no, I don't think I need my code "managed" whatever that means, and what do you mean I have to actually pay for MFC just to make a GUI? And why do all my users have to install the MS C++ Runtimes just to run something I wrote? Isn't the whole idea of "dependencies" something we should be trying to get away from? What the heck had the world come to? "Just In Time" used to mean you actually caught the bus, or didn't show up late to a funeral. Put a bunch of technocrats in charge of the world and you don't get a technological wonderland, you get a hegemony of "our way or the highway". Who put them in charge, anyway?
"Yo, dude, chill out. This is just the way it is. If you dislike it so much, maybe you should have just stayed lost in the woods for another decade, no? And are you anywhere near getting to a point? Talk about missing the bus..."
Indeed. Back when I was about 10 I attended a "hobbyist's course" in assembly language programming for the Z80 CPU architecture - because I wanted to make video games, like every other 10 year old kid, and Basic just wasn't cutting it, having no access to interrupts or screen memory, or any of that good stuff.
So I sat quietly through about 3 meetings of the club dutifully taking notes on mnemonic instructions, popping of registers, and all the other stuff - until I finally got fed up and asked for a real world example that could make a segmented-caterpillar float across the screen smoothly. I was just one of those people who learned better "backwards" by taking a working sample of something and backtracking until it was broken down into its component parts. Now, naturally, this didn't work with everything - like I never really understood how all those funny-smelling glowing television-tubes resulted in Bugs Bunny or Gilligan's Island. That was just hocus-pocus... but I reckoned that if I could grasp the relationship of balanced-byte mnemonic coding and this thing appearing on the screen I would have a foothold to work with.
The same thing applies these days. Did you ever try to read one of those books like "C++ for Dummies"? I just can't get enthused copying console programmes about converting Celsius to Fahrenheit and back again. And besides, I always had this sneaky suspicion that traditional ANSI C was like Chess, and C++ was kind of like what would happen if someone said "Wouldn't it be great if we could create a cross between Chess, Scrabble, and some crazy card-game? That would be really cool!" Turns out that it's not very cool - it's just 99.9% unnecessary. It's beyond me how it ever caught on. And then there's C# which doesn't seem to have anything to do with C at all... it doesn't even have pointers... it's kind of like a dumbed-down version of Java re-branded for grown-ups (because no one would take a Java-clone seriously on its own so they renamed it after a respected language thinking more people would use it). What a mess.
But I digress.
Probably the most astonishing open-source project known to the computer world is the GCC. On the Windows end of things, that means MinGW, or, better yet, one of its forks, the TDM-GCC MinGW Compiler which allows for seamless x86/x64 target compilations, without any of the nonsense that Visual Studio throws at you. Combine that with a decent IDE, such as CodeBlocks, and you've got yourself a party - a few hundred MB's of disc-space used, and absolutely no installation (of anything!) is required. Kinds of makes you wonder exactly what all that crap in Visual Studio really is - they don't even allow off-line documentation anymore.
"Now hold on a minute! I know all those projects - I used Audacity back in the day, and Gimp, and all that good stuff the cool kids are using instead of paying for other things. I hate the interfaces, though - they always look so old and small, and never seem to act like native Windows applications."
That's because (just like Windows and its MFC, ATL/WTL stuff) they're not creating GUI's natively, they're using wrappers and substitute functions and cross-platform libraries which are designed to make life easier. After all, you don't want to maintain two or three code-bases for Linux, Mac, and Windows just for some silly GUI nonsense, do you? I mean, if some widget-class makes things easier, and doesn't add too much flab to the EXE, what's the harm?
"But I don't care about Linux or Mac - I just want to write stuff for Windows - and these free-compiler things won't go near the proprietary MFC stuff, and (no matter what Nikos says) WTL still looks like rubbish! Isn't writing things in 'pure API' too hard for beginners?"
Yeah, that's what I thought. And don't get me wrong: it's not easy. The Win32API is a scary place when you don't know what you're doing, and you don't even have a resource editor to work with.
"Wait - no resource editor? You mean I have to design a GUI by hand? How does that work? I thought everyone just dragged and dropped controls (checkboxes, combo-boxes, labels, etc) around a grid and let the system take care of the funny stuff?"
Well, yes, most people do it that way - they've never really known anything else. And beginners love it - designing a GUI using a proper resource-editor (say, in Visual Studio) is a really easy thing to do.
"But...? I can hear the sound of a 'But' coming on... What's wrong with just pointing me at something like The Forger's Win32 API Tutorial and jumping in?"
And that's exactly what I'm doing. A great place to start learning - simple examples, etc. Except - there are a few things they don't tell you that are necessary for the modern age.
For instance, the API has no built-in adaptation for high DPI adjustments - you either rely upon Windows awful DPI-Virtualisation or do it manually. Except they don't tell you how to do it manually. And to be honest, I don't know how to do it either, I've seen some examples where it's done in the WM_PAINT callback, but that doesn't always end up the way it seems like it should - so I used the Bull-In-The-China shop approach and did it myself, which works perfectly.
Another thing (that everyone takes for granted) is that when a GUI window's borders are "adjustable" the controls therein grow/shrink move according to certain docking parameters as the user drags the edges around. What they don't tell you is that there's absolutely no relative control docking built into the API. You have to do it manually. And so I did.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Basically what you're looking at here is a gigantic "proof of concept" (much like the original script was!), which serves as an example of how to do some of the more esoteric (yet still necessary) stuff of GUI design, that the Win32API tutorials don't usually address. (For example, for someone used to a scripting environment, just getting a bit of text to change colour according to certain conditions is surprisingly difficult!)
Remember, this GUI looks simple, but there's a lot of stuff "under the hood" which is not immediately obvious.
![Image](http://i1109.photobucket.com/albums/h440/Kilmatead/TRPC.png)
Download: Touch Reparse-Point (C-Version) 1.0.1.0 (Last updated 18-Sep-2015)
Points of interest for the perusing user:
- 100% pure WinAPI ("Doin' it the hard way!")
- No MFC, ATL/WTL or 3rd-party dependencies
- 100% C-Language from the ground up, without any external DLL's, etc
- Made with 100% portable free tools (nothing need be "installed" to build it from scratch)
- Fully DPI-ratio adaptive
- Full (horizontal) control docking when expanding/contracting
- Unicode (everything, including the stuff you can't see)
- Embedded manifest allowing for DPI and theme adaptation
- Expected information when mousing-over the EXE in a file-manager
- Tooltips
- Correctly sized icon extraction for GUI and taskbar
- Multiple font sizes/types throughout, none default
- Multiple types of accelerator handling (not done as a resource!)
- Menus done manually (again, not as a resource!)
- Drag-n-Drop items from a file-manager
- Copy text from static label into clipboard just by clicking on it
- Command-line options and sub-options
- Auto-moving pointer to default controls (respecting user's choice in system settings)
- Auto-centring of main window (again DPI adaptive)
- GUI designed and created entirely without a resource-editor of any kind
Now, any normal developer would just look at that and say, "Yeah, so what?" And true - nothing in this list is ground-breaking - but for beginners these things are not easy to do when the internet does not provide as many examples as one would hope. And we will also note that very few developers could do it all without a resource-editor, and using only what the API gives them.
![Wink :wink:](./images/smilies/icon_wink.gif)
And remember - I haven't written a C programme in 25 years: this is just my humble version of Hello World for the modern age.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Naturally, all the functions of the programme work as expected (it is meant to be a practical example after all), though they are somewhat limited (it's a proof of concept, remember). But overall there's enough here to be interesting... numerous user-selectable timestamp formats, millisecond-display, etc.
Also, the original foundation for the project (the function that returns the target and type of any Reparse-Point) has been translated into C and is all the better for it, including auto-matching Mount-Point GUID's to logical hard-drives, etc.
One last thing of interest to developers:
As part of the GetReparseTarget() functionality, I had a line that detected a GUID by RegExp to differentiate Mount-Points from mere Junctions. While this was a simple thing to do in a scripting language, proper C does not have regular expressions. It is available as part of the C++11 standard (at the cost of some absurd EXE bloat and non-PERL compatibility), and - to be honest - is not really even necessary for this project (I could leave it out altogether and no one would notice), but in case anyone wanted an example of how to statically-link and use a RegExp in C, I decided to add it in. (It increases the EXE sizes by about 70KB which is ridiculous for just one function call, but again, this is all intended as a working-example and proof-of-concept project at the end of the day.
Of the numerous RegExp libraries available, I chose the well-known PCRE2 project, which I recompiled myself, and have included the necessary 10.20 version 16-bit (wchar_t) x64 and x86 static-linking libraries in the download.
For the curious, I also played around with the out-of-development (and C++ only) DEELX library too, which (at a single file) is rather easy to self-compile, though in small tests is slightly slower than PCRE. I prefer PCRE simply because it's still in development (and has been for the last 18 years) with a recent update just this summer. It's also the same library used in AutoIt, so it's compatible with everything I already learned about RegExp patterns.
![Wink :wink:](./images/smilies/icon_wink.gif)
Final note:
For anyone interested in building this project from scratch (the download includes x86 and x64 EXE's, and all necessary source-code, plus the specific PCRE libraries mentioned above) I have included the .CBP file which is the fully-configured project-file for CodeBlocks IDE, prefigured for the TDM-GCC compiler flags setup, etc. You'll need one of the recent nightly-builds of CodeBlocks (no installation required) to take the -F pe-i386 flag which keeps the x86 build happy with its resources.
For anyone else with other compilers, there shouldn't be anything funny that you can't figure out on your own - I have used some C99 notation, but that's not enough to break anything.
Also, if anyone needs some tips for independently compiling PCRE from source, just ask. Took me a little while to figure it out before I got it right.
Thanks for reading.
![Image](https://www.autoitscript.com/forum/uploads/emoticons/default_bye.gif.11111111111111111111111111111111.gif)
"Wait, you didn't finish your joke..."
A Writer and an Editor were walking across the desert, both of them dying of thirst. When they crested a hill and found an oasis with a pool of water, the Writer rushed forward and thrust his face into the pool to drink.
At the same time, he heard the Editor behind him and looked up, astonished at what he saw, for the Editor was standing there urinating into the pool of water.
"What the heck are you doing?!" the Writer decried.
"It's okay," the Editor said, "I'm making it better."
* * *
And that, for anyone who has read this far, is my comment on how the "++" got into C, and how the MFT/ATL/WTL got in the way of learning about the API and how Windows really works.