Thread View: comp.sys.mac.oop.powerplant
3 messages
3 total messages
Started by Stephen Kay
Tue, 03 Jul 2001 01:34
LWindow-Can change AutoPosition Manually?
Author: Stephen Kay
Date: Tue, 03 Jul 2001 01:34
Date: Tue, 03 Jul 2001 01:34
19 lines
1750 bytes
1750 bytes
Is it possible to change the "AutoPosition" attribute of an LWindow dynamically before it is created? In other words, the WIND Resource type provide these constants: noAutoCenter = 0x0000, centerMainScreen = 0x280a, alertPositionMainScreen = 0x300a, etc. You can select one of these in LWindow's Inspector (in Constructor). Can you change this on the fly before you create the windows through code? If someone knows how to do this, it would be greatly appreciated. I spent several hours so far attempting to understand and track this down, but it's not clear to me at all whether this is even possible. Thanks, Stephen Kay
Re: LWindow-Can change AutoPosition Manually?
Author: Dave Vasilevsky
Date: Tue, 03 Jul 2001 17:32
Date: Tue, 03 Jul 2001 17:32
78 lines
3872 bytes
3872 bytes
In article <B7669966.27EA%sk@karma-lab.com>, Stephen Kay
<sk@karma-lab.com> wrote:
> Is it possible to change the "AutoPosition" attribute of an LWindow
> dynamically before it is created?
>
> In other words, the WIND Resource type provide these constants:
>
> noAutoCenter = 0x0000,
> centerMainScreen = 0x280a,
> alertPositionMainScreen = 0x300a,
> etc.
>
> You can select one of these in LWindow's Inspector (in Constructor).
> Can you change this on the fly before you create the windows through code?
There is a Toolbox function, RepositionWindow(), which on OS 8.5 and
higher will set the position of a window using options similar to those
in the WIND Resource.
<http://devworld.apple.com/techpubs/macos8/HumanInterfaceToolbox/WindowManager/ProgWMacOS8.5WindowMgr/WindowMgr.43.html#10814>
So if you want to "AutoPosition" an LWindow, here's how you would do it
(untested code):
#include <LWindow.h>
#include <LException.h>
#include <MacWindows.h>
inline
LWindow*
CreateAndPositionWindow(
ResIDT inWindowID,
LCommander* inSuperCommander,
WindowPositionMethod inPositionMethod)
{
// Create the new window. It should not have "Initially visible" set in
// Constructor, or else it will show before being AutoPositioned.
LWindow* theWindow = LWindow::CreateWindow( inWindowID, inSuperCommander);
ThrowIfNil_(theWindow);
// If necessary, get the parent window.
WindowPtr parentMacWindow = NULL;
if ( (inPositionMethod % 3) != 1 ) // Tests if we need a super window
{
LWindow* parentLWindow = dynamic_cast<LWindow*>(inSuperCommander);
if ( parentWindow == nil )
{
throw LException( errInvalidWindowPtr,
"\pNo parent window found.");
}
else
{
parentMacWindow = parentLWindow->GetMacPort();
}
}
::RepositionWindow( theWindow->GetMacPort(), parentWindow, inPositionMethod);
return theWindow;
}
A couple of caveats:
- It may be preferable to accomplish this by deriving a new class from
LWindow, and overloading FinishCreate(), and making a new Constructor
template for it. This would allow you to call AdjustUserBounds() after the
move (a good thing), and would work whether or not the "Initially Visible"
flag is set. However, you'd have to do some trivial, boring rewrites of
LWindow's constructors.
- The call to RepositionWindow() *may* (I'm not sure, I've never tried
calling the function before) automatically show the window.
Good luck,
Dave
Re: LWindow-Can change AutoPosition Manually?
Author: Eden Smallwood
Date: Tue, 03 Jul 2001 18:45
Date: Tue, 03 Jul 2001 18:45
54 lines
3444 bytes
3444 bytes
In article <B7669966.27EA%sk@karma-lab.com>, Stephen Kay <sk@karma-lab.com> wrote:
� Is it possible to change the "AutoPosition" attribute of an LWindow
� dynamically before it is created?
�
� In other words, the WIND Resource type provide these constants:
�
� noAutoCenter = 0x0000,
� centerMainScreen = 0x280a,
� alertPositionMainScreen = 0x300a,
� etc.
�
� You can select one of these in LWindow's Inspector (in Constructor).
� Can you change this on the fly before you create the windows through code?
It's *Backward-compatible-Man* ("BM"), to the rescue!
The other response you got for system 8.5 and above- I guess that's
the right way to do it, though it seems like alot of trouble for what
you want to do. For earlier OS, you might try something more brute force:
The PPob file you're editing in Constructor- if you drop that file
on ResEdit, you'll notice the 'WIND' resources in there which correspond
to your LWindows- the LWindow will be using that regular ol' Mac
toolbox WIND resource to *base itself* on- the values in that WIND are
used in creating the LWindow.
So, you've almost answered your own question- just grab that WIND,
change the field with that position value, before you execute the
code which causes UReanimator to read that PPob, which contains an
LWindow, which reads that WIND. See?
Handle windH = ::Get1Resource( 'WIND' , theID );
HLock( windH );
(*windH)[ theOffset ] = centerMainScreen;
HUnlock( windH );
NowDoPowerPlantCodeToLoadAndShowWin( theID );
As far as theOffset, *where* that value is stored, I think it's
the last two bytes of a system 7 or beyond WIND, but you can deduce
it for yourself either by playing in ResEdit, ( duplicate the WIND,
alter the "autoPosition" of one from the menu, compare those two ), or
add up what you see in "MacWindows.r" describing the WIND. See?
Who *was* that BitMasked man?
Eden
� If someone knows how to do this, it would be greatly appreciated.
� I spent several hours so far attempting to understand and track this down,
� but it's not clear to me at all whether this is even possible.
�
� Thanks,
� Stephen Kay
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads