OSLib wimp_window_info cast to wimp_window
Alan Robertson (52) 420 posts |
I was wondering if there are any OSLib developers in these forums who can help me out of a pickle. I currently have a window that I want to change slightly and this is my current steps:
Unfortunately I am having difficulties in achieving this. Achieving this in BASIC is easy, but using C with OSLib is different kettle of fish altogether. Has anyone ever cast between these two data types before? Can it be done? update: just adding some more details. the two data structures ( |
Matthew Phillips (473) 687 posts |
Well, the block returned by Wimp_GetWindowInfo has the window handle in the first word, but the remainder of the block is the same as the block you would pass to Wimp_CreateWindow. So it’s the address four bytes on from the wimp_window_info that you need to pass to wimp_create_window. I would have expected the structure definition for wimp_window_info to have consisted of the handle followed by a wimp_window structure, but looking at the headers in oslib.h.wimp it seems that both are built from individual components which are identical apart from the handle at the start of wimp_window_info. This is probably so that you can read information easily from the winp_window_info structure, but it is a bit of a shame for your purposes. Thus there does not seem to be any official way of doing this, so your best bet is to cast to an int*, add one, and cast to a wimp_window. How the code will look depends on what you are passing to wimp_get_window_info. Suppose the info block is called “b”. Are you calling wimp_get_window_info(b) or wimp_get_window_info(&b) ? If it’s the latter, then the call to wimp_create_window needs to look like this:
If it was the former, then you need:
I think that should work. Untested, and I do not usually use OSLib, so take care! |
Alan Robertson (52) 420 posts |
Wow. I’ve tried about 1000 different ways to solve this problem today with no luck, and you solve it in a heartbeat. Thanks so much. This worked first time. Easy when you know how! Thanks again. |