Well... good... hm, I think, that's ok.
So you want to write your own GUI(tm).
First, you need memory management - especially heap memory management. we will put the book keeping info into the heap to avoid limit ourselves in static arrays.
Then you build a structure which holds info about:
id of the window, to whom the window belongs,
x position, y position, width, height, pointer in the z-order list, pointers into the tree organization of windows (where also the hidden ones are listed)
You chain the window object together in two different structures. One is the tree (can be used for mdi-stuff), the other one is the z order list (which tells the order in which windows are to be drawn - from bottom to top)
from the z order ist you need to calculate your clipping: i e per window list of rectangles: the visible area/s of the window.
An other approach is to keep a map of integers as large in resolution as your screen. in this map you keep the information to which window a region of the screen belongs to - per pixel. this means that for each pixel you are about to set inside a given window you need to look into this map first to check if the pixel belongs to the window in question.
It might be intrigueing to check out a mixture of the two of these approaches.
As you are already moving/resizing a window I don''t think I have to rant about this too much.
Just keep in mind, that for the move, you have to repaint what 's been beneath the window. I've buildt a buggy version of checking who's been covered: I'm redrawing everything beneatch which even MIGHT intersect with the moving window - althou it's totally obscured. Nonsense this is and performance stealing.
Best Hint gathered so far: paint the window to drag into an offscreen buffer and paint this one to the main offscreen buffer (ere blitting to screen after all the other operations). This one 's by Pype. Second HInt I can give: think about a way to avoid background redrawing too.Upon dragging, with stored away window: first clip the background without the dragged window. Redraw, what's been beneath. Blit that to screen. Then blit the window to screen. Change of position. Blit background to screen. Blit window to new position on screen. Don't know, if that wouldn't flicker like Hell. Haven't tried it yet.
stay safe and hth.