• Hello MLAers! We've re-enabled auto-approval for accounts. If you are still waiting on account approval, please check this thread for more information.

Window Snapping for Classic Macintosh?

For most cases, I would seriously recommend using ResEdit instead of Rez for anything remotely visual.

Edit: Sorry, I just realised I did that awful thing where you asked a specific question and I didn't answer it, instead giving you dubiously helpful advice to do something else. If you want to use Rez, THINK Pascal bundles standalone versions of them called SARez and SADeRez, in one of the utilities folders. Those will bring up the same UI as if you opened the Rez commando in MPW; if you have a Rez command you're trying to run, you can paste it in the bottom of the window IIRC
 
<snip>I just realised I did that awful thing where you asked a specific question and I didn't answer it, instead giving you dubiously helpful advice to do something else.<snip>
This kind of thing happens all the time on StackOverflow, I think it's just common for engineers (including myself) to try and rethink another person's problem, which can sometimes provide insights, but also sometimes doesn't.

It's an interesting project. I never use window-snapping and when it was the default on Windows 7 or 10 (I forget which) it immediately wound me up, because I felt like I was always wrestling with the OS. Instead I found the control panel to turn it off. I don't use it on macOS, but now I've been reminded that you can get it by option-clicking the green lollipop I see it could be useful, but I think it's good that it's not the default.

@gingerbeardman , does your technique work similarly, e.g. with an option-click in the zoom or size boxes?

The original desktop metaphor, as I understand it, is to mimic pieces of paper. Although the paper is abstract (you can scroll through it, though it remains flat, but it doesn't operate like a notepad where you can flip through pages, except in specific apps), like real pieces of paper you can place them anywhere you like and overlap them as you please.

Part of the long-standing cultural difference between Windows users and Mac users is the former's preference for full-screen apps, to the extent that Windows would be better named Window. Why is this? I think this is probably something to do with Apple's early lawsuits against MS, but it was never the default for Unix workstations. Mostly I think it's because pre-Windows applications only worked in full-screen mode and in the cross-over, where people ran MS-DOS applications under Windows, they expected the same environment. This was then passed on down generations of PC users, who think it's simply better to make use of all the screen space for a given app.

Tiling has a wholly different pedigree. It was originally a pseudo-technique for windowing on computers that didn't have the power to support overlapping bit-blitting: so confining screen output to specific bounds was much easier; and GUIs that supported it were much simpler. The problem is that it's harder to maintain document layouts without reformatting or zooming. Tabbed windows with split views I think are arguably better, but that's nothing to do with this thread.
 
For most cases, I would seriously recommend using ResEdit instead of Rez for anything remotely visual.
Right, I've not be so clear. I can use ResEdit to create the equivalent resource, but how do I package the rsrc and my code into a final app. Even that is still not a great description of the sticking point here. I can code the Pascal using the Toolbox, but I am not sure of all the other steps to required to package up or produce the final control panel.

An example project would fill in all my knowledge gaps, as source or in a book or web page, but I am yet to find one.

does your technique work similarly, e.g. with an option-click in the zoom or size boxes?
No, I don't use modern macOS green button tiling, I use other apps to do something similar (Tiles for mouse control, custom Hammerspoon script for keyboard controls). I can quickly and easily size and move windows between quarters, halves, thirds, displays. Everything is done on my command, windows are NOT moved or repositioned automatically. Take a look: https://freemacsoft.net/tiles/

I have no vested interests or opinion in what is right or wrong, expected or unexpected, Mac or Windows.

My goal with this is to make my time managing windows in Classic as similar as my time managing windows in modern Mac OS X.
Much like Exposé for Classic made that way of working possible. And that those who are like me might also use it ...is a bonus.
 
but I am not sure of all the other steps to required to package up or produce the final control panel.

OK - right. I haven't used THINK Pascal in a very long time so this will be, necessarily, vague, I'm afraid, but I can hopefully give you some pointers. I'm sorry I haven't got links to more discursive documentation: I haven't used any in a long time, and my memory of what's good and what isn't has rotted. I hope this is what you mean - if I'm talking down to you, I don't mean to!

The first question, about how you bundle your code resource and your other resources together is simple but annoying. The box to choose the resource file to bundle into your final project is under Run Options... in the Run menu for some bizarre reason. You'd expect it to be in the Project menu, under compile options or something. Nope. It's under Run Options. Now that you're good and annoyed, I'll try to answer the broader question a bit.

A cdev is a kind of Code Resource. A code resource is just any resource that contains code. The CODE resources in an application are technically code resources, but they work rather differently, so usually you get a distinction between 'Application' and 'Code resource'.

These resources are contained in files, like any other resource. And this is where some of the confusion comes in - the file type of the file that your cdev resource lives in is also 'cdev'. So a 'cdev' can refer either to a file or a resource, and you have to work out from context which is meant. This is one of the reasons Apple started calling the files 'Control Panels' in system 7. So your cdev resource, along with other resources for its icons and possibly some other supporting code resources (an INIT is usually necessary for a control panel) is contained within a cdev file.

So, how do you go about creating a code resource in THINK Pascal? I vaguely remember the chapter in the THINK Pascal manual on code resources is relatively good but I haven't read that for 25 years so ... perhaps that's fiction.

The THINK Pascal Demos that are packaged with the compiler are somewhat anæmic but there are examples of generic code resources in the HyperCard Demos folder. You'll need to use the Code Resource runtime library (which I think is called RSRCRuntime.Lib) rather than the application one. You also need to set up the project metadata appropriately.

To set the kind of resource you're compiling into, go to Project -> Set Project Type, and choose Code Resource. This will enable the resource flags section in the dialog box. Note that you have two boxes for resource type and file type. For a control panel, both are cdev.

The actual contract that your cdev needs to follow is in, I think, IM: Devices (??). You need to provide a routine that the OS will call whenever the user interacts with anything in your window - in some ways this is much simpler than application programming, because you don't need to manage your own event loop.

I'd suggest getting a simple CDEV working before trying to do anything more dramatic, but you will also need to create an INIT resource eventually, and put the two in one file. The INIT will contain the code that runs at startup and actually patches _DragWindow or whatever you're intending to do, the control panel will contain the UI.

edit: As a side note, unless you're targetting system 6, you might find it easier to distribute this as an Application for setting settings and an INIT for doing the startup stuff, which share a preferences file. This is what Apple started doing in 7.5, because at that point there's really not much point in building a cdev, since they're no longer hosted in the Control Panel desk accessory.
 
Last edited:
Back
Top