ThinkC [Study Group 2] - Events & Menu Management

Relating to ThinkC Development

Crutch

Tinkerer
Jul 10, 2022
293
228
43
Chicago
You do have it set to get background NULL events. Check your SIZE flags popup there, you’ll find it’s checked (I can tell because the first digit of 0x50E0 implies the high byte has bit 5 set).

Turn that off and this issue should stop happening, I think.
 

pretzelFTW

New Tinkerer
Sep 5, 2022
26
8
3
You do have it set to get background NULL events. Check your SIZE flags popup there, you’ll find it’s checked (I can tell because the first digit of 0x50E0 implies the high byte has bit 5 set).

Turn that off and this issue should stop happening, I think.
Ah, now I get it.

Yeah "Accept Remote HighLevel Events" needed to be unchecked. That was explained in the book (p152) and I'd totally forgotten that you could click the little icon beside SIZE for a menu. That's what happens when you take a three month break in the middle of a chapter :p

@Crutch thanks for shedding some light on that!
 

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
I cannot seem to get my EventTracker to respond to the AppleEvent generated by EventTrigger.
I made sure to set the Creator code correctly in Tracker and to use ‘Prmr’ as the appSig that is the destination in Trigger… I’m a bit stuck!!
 

Attachments

  • 29C71FB8-9DC1-4050-92C9-FEE807252388.jpeg
    29C71FB8-9DC1-4050-92C9-FEE807252388.jpeg
    513.6 KB · Views: 52

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
I cannot seem to get my EventTracker to respond to the AppleEvent generated by EventTrigger.
I made sure to set the Creator code correctly in Tracker and to use ‘Prmr’ as the appSig that is the destination in Trigger… I’m a bit stuck!!
And I figured it out… I don’t see where in the text I missed this but I have to go in Event *Trigger*’s “Set Project Type..” window and set the HIGH LEVEL EVENT AWARE flag in the SIZE flags.
The book def says to do all this for Event*Tracker* but I don’t see where it says to do this for EventTRIGGER.
Anyway I must be missing it but either way some of the last few posts in this thread here spurned my thoughts on this.
 

Attachments

  • CB8DCFB9-9F95-404C-B757-7E916139A5AA.jpeg
    CB8DCFB9-9F95-404C-B757-7E916139A5AA.jpeg
    475.6 KB · Views: 58

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
Is there a way for my program to query the OS to see what other applications are currently running? And then to access those apps' application icon?

My goofball project is to make a very simple likeness to the OS X dock that hovers at the bottom of the screen. --- Playing it real simple for now just housing it all in a simple program (not an extension or control panel... yet) that has one rectangular Window on the bottom and draw the current running programs.

When I have that I'll add repeated queries (probably during Null Events) to keep it up to date

Later I'll add making the program clickable and switching you to those programs

And then support adding links to non-running apps and even files and folders.

But for now -- I'm looking for help on how to query the OS for what programs are running and subsequently how to access those programs' icons.
Appreciate any help!
 

Attachments

  • tempImage6lF4hI.png
    tempImage6lF4hI.png
    139.6 KB · Views: 55

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
Is there a way for my program to query the OS to see what other applications are currently running? And then to access those apps' application icon?

My goofball project is to make a very simple likeness to the OS X dock that hovers at the bottom of the screen. --- Playing it real simple for now just housing it all in a simple program (not an extension or control panel... yet) that has one rectangular Window on the bottom and draw the current running programs.

When I have that I'll add repeated queries (probably during Null Events) to keep it up to date

Later I'll add making the program clickable and switching you to those programs

And then support adding links to non-running apps and even files and folders.

But for now -- I'm looking for help on how to query the OS for what programs are running and subsequently how to access those programs' icons.
Appreciate any help!
Also does anyone have a good link to digital copies of Inside Macintosh volumes?
Here's a link to Inside Macintosh Volumes:
 
Last edited:

Crutch

Tinkerer
Jul 10, 2022
293
228
43
Chicago
Is there a way for my program to query the OS to see what other applications are currently running? And then to access those apps' application icon?
Yes.

You want the Process Manager to get a list of all the apps running, and the Desktop Database to get icon information.

To walk the list of all currently running processes, call GetNextProcess() repeatedly. The first time, pass it kNoProcess. Thereafter, pass it the prior processes’ ProcessSerialNumber (psn) until you get an error.

GetNextProcess() wlll give you back a psn. You can pass those to GetProcessInformation() to get the application’s type (presumably APPL for applications, but desk accessories and background apps are also processes) and creator (processSignature field of the ProcessInfoRec).

You can then use the Desktop Database routine PBDTGetIcon() to get icon information given that type and creator.
 

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
Yes.

You want the Process Manager to get a list of all the apps running, and the Desktop Database to get icon information.

To walk the list of all currently running processes, call GetNextProcess() repeatedly. The first time, pass it kNoProcess. Thereafter, pass it the prior processes’ ProcessSerialNumber (psn) until you get an error.

GetNextProcess() wlll give you back a psn. You can pass those to GetProcessInformation() to get the application’s type (presumably APPL for applications, but desk accessories and background apps are also processes) and creator (processSignature field of the ProcessInfoRec).

You can then use the Desktop Database routine PBDTGetIcon() to get icon information given that type and creator.
Thanks yes! I was just reading up on this in Inside Macintosh! Had gotten as far as how to produce a list of running processes but hadn’t seen yet the part about PBDTGetIcon to get the icon.
Thanks
 

Crutch

Tinkerer
Jul 10, 2022
293
228
43
Chicago
By the way - your project sounds really cool!

If you just want to try something like this that’s already available today, I highly recommend Program Switcher https://macintoshgarden.org/apps/program-switcher

It allows your to Cmd-Tab between open applications, and also permanently include certain applications in the list whether they are open or not, so you can use it as an instant hotkey to launch whatever you use most.

This latest version also lets you choose another hotkey to cycle between open windows in the current app.

It’s maybe my favorite single extension/cdev of the System 7+ era.
 

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
By the way - your project sounds really cool!

If you just want to try something like this that’s already available today, I highly recommend Program Switcher https://macintoshgarden.org/apps/program-switcher

It allows your to Cmd-Tab between open applications, and also permanently include certain applications in the list whether they are open or not, so you can use it as an instant hotkey to launch whatever you use most.

This latest version also lets you choose another hotkey to cycle between open windows in the current app.

It’s maybe my favorite single extension/cdev of the System 7+ era.
Thanks! I have never used that but will try it for fun. I didn't do any research on whether something like my project exists mainly because I'm doing it to have a target to exercise what I'm learning in this programming tutorial so things like market acceptance and uniqueness aren't too important :) but I appreciate the tip nonetheless!!!
 

Patrick

Tinkerer
Oct 26, 2021
434
1
224
43
aside, it was one thing that i was jealous of my windows friends duirng the system 7 timeframe. (when it was new)

and was pretty happy when apple added the cmd-tab in the os in later OS versions. (was it 8 that had it native ? i don't remember)

anyways. cool project idea. i wish you success !
 

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
Funny that process signature for the ThinkC debugger is LSD?
9D63E098-DFC5-418E-864D-ACFA37341071.jpeg

Anyway thanks for the tips ok process info. I’m getting there… next I’ll pull up the icon and figure how to parse the data and then display it on my little dock!
 

Crutch

Tinkerer
Jul 10, 2022
293
228
43
Chicago
It stands for LightSpeed Debugger 😊 THINK C’s original name was LightSpeed C (because it was fast!).
 

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
It stands for LightSpeed Debugger 😊 THINK C’s original name was LightSpeed C (because it was fast!).
That’s right, I forgot! Well between LSD and the little diamond I thought maybe it was a drug reference or at least a Lucy In the Sky with diamonds thing. But Lightspeed Debugger makes more sense :)
 

MacOfAllTrades

Tinkerer
Oct 5, 2022
168
182
43
Ah I’m close (and so far away). I’m at the point where I’ve set up all my stuff and can iterate through each process and then get its icon (im sure I’m doing this in a lame inefficient way setting up a PBRecord etc..). In the debugger I can see the bytes that make up the icon data and can tell it’s correct (Think C’s icon conveniently has a black border so the first row is 0xFFFF and the next several rows have one black pixel at the start and end and I see it’s all there!!

I’m going to see what QuickDraw routines exist in case there’s one that will draw bitmaps given an array and row width sort of thing… there must be something there as it’s an all too common situation to display bitmaps. Else I’ll write my own. This way I can just be psyched to see my icons on a dock even if it’s otherwise functionless… for now :)
 

Crutch

Tinkerer
Jul 10, 2022
293
228
43
Chicago
PlotIcon is what you need, confusingly in the Toolbox Utilities chapter. Or of course you can always stuff your icon into a bitmap and use CopyBits.

Edit: of course you aren’t actually getting an ICON resource this is just showing you how to draw it. I don’t remember if PBDTGetIcon() gives you back a pointer to a bitmap already — I think it does — in that case you can just pass that pointer to CopyBits. If not, it sounds like you know where the underlying icon bitmap data is, and you can just use a pointer to that data as the b.baseAddr below and plot it with CopyBits anyway.

C:
BitMap b = {NULL, 4, {0, 0, 32, 32} };
const Handle icon = GetResource(‘ICON’, 128);

HLock(icon);
b.baseAddr = *icon;
CopyBits(&b, &thePort->portBits, &b.bounds, &b.bounds, srcCopy, NULL);
 
Last edited: