Hi,
I'm using this hook function in order to cope with a.o. changes in a window's position, beit in vertical or horizontal direction or in depth. The latter one gives me problems.
The situation is as follows:
From a main window (= mother, indexed by WOID_MAIN) I open a second window (= daughter, indexed by WOID_TASK). Daugther should ALWAYS be in the middle of mother and always be in front of mother and always be the active one. However, whatever I do there is an unacceptable great chance that daughter gets BEHIND mother and is therefore no longer reachable.
The pairn of tags: , WINDOW_Position , ((uint32)WPOS_CENTERWINDOW) is commented out as it does not work (?). Tags WA_Left and WA_Top have taken over and DO give the desired results, as does WA_Activate. So far so good. The final tag, WINDOW_FrontBack gives offence and Result is set to 4 indicating this to be the offending tag.
Rest assured that WINDOW_RefWindow has been set to the motherwindow (and not object).
/* ** ** IDCMPHook.c ** ** tjitte de wolff ** ** Feb 17,2021 ** ***********************/ #define ___GD ((struct GUI_Data *)((struct GUI_Elements *)((struct ExecParam *)hk->h_Data)->xn_GUI_Elements)->ge_GUI_Data) #define ___GE ((struct GUI_Elements *)((struct ExecParam *)hk->h_Data)->xn_GUI_Elements) #define ___ALIGN_LEFT(Mother, Daughter) ___GE->ge_Window[Mother]->LeftEdge + ((___GE->ge_Window[Mother ]->Width - \ ___GE->ge_Window[Daughter]->Width) >> 1) #define ___ALIGN_TOP(Mother , Daughter) ___GE->ge_Window[Mother]->TopEdge + ((___GE->ge_Window[Mother ]->Height - \ ___GE->ge_Window[Daughter]->Height) >> 1) uint32 IDCMPHook(struct Hook *hk UNUSED, APTR Window, struct IntuiMessage *imsg) { uint32 RC = 0; IExec->DebugPrintF("INFO : Message Class [ %08lx ] \n", imsg->Class); switch (imsg->Class) { case IDCMP_CHANGEWINDOW: { if (___GE->ge_ActiveWOID != WOID_MAIN) { uint32 Result = IIntuition->SetWindowAttrs(___GE->ge_Window[___GE->ge_ActiveWOID]//, WINDOW_Position , ((uint32)WPOS_CENTERWINDOW) , WA_Left , ((uint32)___ALIGN_LEFT(WOID_MAIN, WOID_TASK)) , WA_Top , ((uint32)___ALIGN_TOP(WOID_MAIN, WOID_TASK)) , WA_Activate , ((uint32)TRUE) , WINDOW_FrontBack, ((uint32)WT_FRONT) , TAG_END); IExec->DebugPrintF("INFO : Result was [ %lu ( = %s )]\n", Result, (Result == 0) ? ("OK") : ("Tsk, tsk, tsk")); } break; } case IDCMP_MOUSEMOVE: { if ( (((struct Window *)Window)->MouseY > ((struct Window *)Window)->TopEdge) && (((struct Window *)Window)->MouseY < (((struct Window *)Window)->TopEdge + ((struct Window *)Window)->Height)) && (((struct Window *)Window)->MouseX > ((struct Window *)Window)->LeftEdge) && (((struct Window *)Window)->MouseX < (((struct Window *)Window)->LeftEdge + ((struct Window *)Window)->Width)) ) { ___GD->gd_Suspend = TRUE; } else { ___GD->gd_Suspend = FALSE; } break; } } return RC; } /* ** ================================================================================================ ** === End of File ================================================================================ ** ================================================================================================ */
My question is: what could possibly make ', WINDOW_FrontBack, ((uint32)WT_FRONT)' fail?
OldFart
You are mixing up ReAction and Intuiton.
WINDOW_#? attributes are those of a ReAction window.class object.
WA_#? attributes are those of an Intuition window.
SetWindowAttrs can only set attributes of Intuition windows, i.e. WA_#? attributes.
To change WINDOW_#? attributes you have to use IIntuition->SetAttrs on the window.class object.
To be honest, nailing one window to another one is not AmigaOS-like. The way to go to have part of a window hidden by another window-like thing is using a Requester. But I doubt that the AmigaOS concept of requesters works nicely with ReAction. At least I never tried it.
IMHO this "feature" is one of the most annoying things in MS Windows and trying to copy it in AmigaOS will make the application be a bad one. Open the second window in the middle of the first one and then let the user move them independently.
The only app i know that glues multiple windows together is AmigaAMP, to be honest although i think it's not a great UX, I have always been impressed how they pulled it off flawlessly.