Reaction getscreenmode.gadget issue

This forum is for general developer support questions.

Reaction getscreenmode.gadget issue

Postby xenic » Sat Jun 04, 2016 9:39 pm

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
xenic
 
Posts: 1148
Joined: Sun Jun 19, 2011 1:06 am

Re: Reaction getscreenmode.gadget issue

Postby salass00 » Sat Jun 04, 2016 10:04 pm

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.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 507
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: Reaction getscreenmode.gadget issue

Postby xenic » Sat Jun 04, 2016 10:45 pm

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
xenic
 
Posts: 1148
Joined: Sun Jun 19, 2011 1:06 am


Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 8 guests