Article View: comp.sys.mac.oop.powerplant
Article #42Re: LWindow-Can change AutoPosition Manually?
From: 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
Technical Details
Message-ID:
<gridd-0307011332500001@modemcable215.92-202-24.mtl.mc.videotron.ca>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sunqbc.risq.qc.ca!wesley.videotron.net!wagner.videotron.net.POSTED!griddReferences:
<B7669966.27EA%sk@karma-lab.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bcce,c55fc3df69c11b0
X-Google-Attributes: gid10bcce,public
X-Google-Thread: f635e,c55fc3df69c11b0
X-Google-Attributes: gidf635e,public
X-Google-Thread: f7f77,c55fc3df69c11b0
X-Google-Attributes: gidf7f77,public
X-Google-ArrivalTime: 2001-07-03 10:32:49 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sunqbc.risq.qc.ca!wesley.videotron.net!wagner.videotron.net.POSTED!gridd
From: gridd@mail.com (Dave Vasilevsky)
Newsgroups: comp.sys.mac.oop.powerplant,comp.sys.mac.programmer.codewarrior,codewarrior.mac
Mail-Copies-To: always
Subject: Re: LWindow-Can change AutoPosition Manually?
Message-ID: <gridd-0307011332500001@modemcable215.92-202-24.mtl.mc.videotron.ca>
References: <B7669966.27EA%sk@karma-lab.com>
X-Newsreader: MT-NewsWatcher 2.4.4
X-Face: .M=w)J@UDy^Cn=dYB`=f|08m[.q@]tSXh{e?:OPH*Mc1kOE,.6q)II-s^4CtX
`$,z|#&*nyq5(5Dd8iTcz:6&u%rC1&GK2e]8[
Lines: 78
Date: Tue, 03 Jul 2001 13:32:50 -0400
NNTP-Posting-Host: 24.202.92.215
X-Complaints-To: abuse@videotron.net
X-Trace: wagner.videotron.net 994181568 24.202.92.215 (Tue, 03 Jul 2001 13:32:48 EDT)
NNTP-Posting-Date: Tue, 03 Jul 2001 13:32:48 EDT