Reaction getscreenmode.gadget issue

This forum is for general developer support questions.
Post Reply
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Reaction getscreenmode.gadget issue

Post by xenic »

While I was helping LyleHaze look for a getscreenmode example at http://www.os4coding.net, I posted an example that used this:

Code: Select all

LAYOUT_AddChild, objects[OID_SCREENMODE] = IIntuition->NewObject(NULL, "getscreenmode.gadget",
GA_ID, OID_SCREENMODE,
GA_RelVerify, TRUE,
GA_Disabled,FALSE,
GETSCREENMODE_DisplayID,0,
GETSCREENMODE_MinDepth, 0,
GETSCREENMODE_MaxDepth, 32,
TAG_END),
Both Lyle and I discovered that the program only worked when certain other programs were running.

The example program always works when I cnanged the above code to this:

Code: Select all

#define GetScreenModeClass IGetScreenMode->GETSCREENMODE_GetClass()

LAYOUT_AddChild, objects[OID_SCREENMODE] = IIntuition->NewObject(GetScreenModeClass, NULL,
GA_ID, OID_SCREENMODE,
GA_RelVerify, TRUE,
GA_Disabled,FALSE,
GETSCREENMODE_DisplayID,0,
GETSCREENMODE_MinDepth, 0,
GETSCREENMODE_MaxDepth, 32,
TAG_END),
The getscreenmode_gc.doc states this:

GETSCREENMODE_GetClass
This function is deprecated as of V52.
Use the "getscreenmode.gadget" public class ID instead.

Can anyone explain why "getscreenmode.gadget" doesn't work reliably but the deprecated function does??
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Reaction getscreenmode.gadget issue

Post by salass00 »

Have you opened the class library first by calling either IExec->OpenLibrary() or IIntuition->OpenClass()? If not that's why it doesn't work...

It is recommended to use IIntuition->OpenClass() and pass the class pointer obtained from there to IIntuition->NewObject() rather than using the public class name as not only does it make it harder to make a mistake like forgetting to open the class before using it, it has also has less overhead since NewObject() doesn't need to search the public classes list for the class in question.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Reaction getscreenmode.gadget issue

Post by xenic »

salass00 wrote:Have you opened the class library first by calling either IExec->OpenLibrary() or IIntuition->OpenClass()? If not that's why it doesn't work...

It is recommended to use IIntuition->OpenClass() and pass the class pointer obtained from there to IIntuition->NewObject() rather than using the public class name as not only does it make it harder to make a mistake like forgetting to open the class before using it, it has also has less overhead since NewObject() doesn't need to search the public classes list for the class in question.
Thanks for the info. I was using -lauto which might explain why some classes worked but getscreenmode.gadget did not. I don't write GUI programs much and my first inclination is to check the SDK Reaction examples and autodocs but that's not as helpful as it should be.
AmigaOne X1000 with 2GB memory - OS4.1 FE
Post Reply