CompuServe Thread

#2.04 Tags confusion

7 messages in this thread
#20033From: Harry CallesisFeb 6, 1992 12:04 AM
Desperation time … I'm trying to define a window using tags (under 2.04). I want to associate it with a custom screen (which I have been able to figure out how to do with tags). The declaration of the screen pointer is: struct Screen *myscreen; When I build the window tag list, I include the entry { WA_CustomScreen, (ULONG) myscreen }, I try to compile (using SAS/C 5.10b) and it tells me "invalid constant expression". I use the ULONG cast in other places, so I'm sure it's not that. Can someone tell me what I'm doing wrong? "Includes & Autodocs" seems to say that the WA_CustomScreen tag replaces the NewWindow.Screen field, which is a Screen * type, so that's why I assumed I could plug the pointer into there. Thanks … Harry
#20045From: KEITH YOUNGFeb 6, 1992 9:21 AM
Harry, Are you setting up the tag list in the data section and then passing the address of it to the OpenWindow() call? If so, then that's probably the problem… remember, the 'myscreen' variable is a pointer (which is what the WA_CustomScreen tag needs). Since it's a pointer, at compiletime, it's a null pointer (it gets initialized by your code after the screen is opened). If that tag took 'the address of a pointer' as the arguement, you could use { WA_CustomScreen, (ULONG) &myscreen } and the compiler would be happy because it could resolve that… but it doesn't, so you need to do something else. I typically use the variable args OpenWindowTags() version of OpenWindow() and pass the tags on the stack. You can pass them all or just a few, with a TAG_MORE pointing at the rest of them. I hope that made sense… Keith
#20066From: Harry CallesisFeb 6, 1992 6:00 PM
Keith – It makes perfect sense 8^). I thought about the constant/variable thing after I posted the message, but forgot about TAG_MORE (it was late …). Assuming TAG_MORE takes a pointer to a tagitem list, and that "windowtags" is my existing array of tagitems, I can do OpenWindowTagList( NULL, WA_CustomScreen, (ULONG) myscreen, TAG_MORE, windowtags ); or something like that (and windowtags ends with TAG_DONE). I'll give this a try tonight. Thanks! On another note, if I want to have more than one window on a screen, and the same menu active no matter what window I'm in (like DiskMaster II seems to), all I have to do is SetMenu (or something) the menu to every window, right? Thanks again … Harry
#20082From: KEITH YOUNGFeb 7, 1992 10:26 AM
Harry, re: SetMenuStrip() to each window… yup, and of course, ClearMenuStrip() on each window before closing each. Keith
#20083From: KEITH YOUNGFeb 7, 1992 10:31 AM
Also… re your OpenWindowTags() call… after the 'TAG_MORE, &windowtags', you should complete that (stack based) tag list with a TAG_DONE. Keith
#20095From: Harry CallesisFeb 7, 1992 8:33 PM
Keith – Thanks for the info. It's all working fairly well now (at least, it does what I've told it to do for a change 8^) ). I even figured out how to get the 2.0 3D look, color-wise. Had to look at an article by Andy Finkel in AWTech for that one (I'm gonna _miss_ that mag!). Isn't there someplace that has all these new tricks, hints and gotchas all in one place? Do I have to become an official developer to get it? Oh, well. No one said it'd be easy … Harry
#20106From: KEITH YOUNGFeb 8, 1992 12:05 AM
Being a developer helps… other than that, sample code in the libs, tech mags (what's left of them), questions here in the msg base and last (but probably _mostly_) 'if at first you don't succeed….'. Keith