1. Restrining a child window's positioning within parent window
- Posted by Rad <radhx at rediffmail.com> Jun 03, 2006
- 645 views
Hi, I have a Parent window containing many child windows. I want to restrain any child window from being moved out of parent window's client area (using win32lib). How can I do this? Regards, Rad.
2. Re: Restrining a child window's positioning within parent window
- Posted by don cole <doncole at pacbell.net> Jun 03, 2006
- 581 views
Rad wrote: > > Hi, > > I have a Parent window containing many child windows. > > I want to restrain any child window from being moved out of parent window's > client area (using win32lib). > > How can I do this? > > Regards, > Rad. Hello Rad, I don't know exactly how to do this, but you would have to know, The size of you main window. The size and location of all the children. I would try getChildren() along with getSystemMetrics() to monitor things. Then setRect() to make sure do not exceed you limits. Don Cole Bonds > Ruth. Giants STILL in last place Hmmmmmmmm!
3. Re: Restrining a child window's positioning within parent window
- Posted by don cole <doncole at pacbell.net> Jun 03, 2006
- 568 views
Rad wrote: > > Hi, > > I have a Parent window containing many child windows. > > I want to restrain any child window from being moved out of parent window's > client area (using win32lib). > > How can I do this? > > Regards, > Rad. I have re-thought your question. I don't really know what you are tring to do. But it appears to me that you are trying to open a main Window with an undetermined amount of children inside. If that's the case what I do is design a main Window with three children that fit nicely. Put the info into the first three children. Then with the message box ask More? YESSNO. If yes then erase the first three chilren and add three more. If the child you are looking for is on the screen then click no and the message box goes away. I think this would be easier than trying to calculate the size of an undetermined amout of children. Don Cole Bonds > Ruth. Giants STILL in last place Hmmmmmmmm!
4. Re: Restrining a child window's positioning within parent window
- Posted by Bernie Ryan <xotron at bluefrog.com> Jun 03, 2006
- 565 views
Rad wrote: > > Hi, > > I have a Parent window containing many child windows. > > I want to restrain any child window from being moved out of parent window's > client area (using win32lib). > > How can I do this? > > Regards, Rad: The easiest way to do this is to use an MDI window as the parent window. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
5. Re: Restrining a child window's positioning within parent window
- Posted by Rad <radhx at rediffmail.com> Jun 04, 2006
- 570 views
don cole wrote: > > I have re-thought your question. > > I don't really know what you are tring to do. > Ok, I have this Main Window where all the options of the application are available through a Menu. Each option when clicked, opens up a child window, in which I display/accept/process all the required details. My problem is, once activated, user can move these Child Windows off the screen by moving them around. I would like to restrict the movement of these child windows within the client area of the main window, so they are movable but not outside the client area of main window. Is this possible? Regards, Rad.
6. Re: Restrining a child window's positioning within parent window
- Posted by Rad <radhx at rediffmail.com> Jun 04, 2006
- 567 views
Bernie Ryan wrote: > > The easiest way to do this is to use an MDI window > as the parent window. > How to convert an existing parent window to MDI (or create MDI Window)? Regards, Rad.
7. Re: Restrining a child window's positioning within parent window
- Posted by don cole <doncole at pacbell.net> Jun 04, 2006
- 571 views
Rad wrote: > > don cole wrote: > > > > I have re-thought your question. > > > > I don't really know what you are tring to do. > > > > Ok, I have this Main Window where all the options of the application are > available > through a Menu. > > Each option when clicked, opens up a child window, in which I > display/accept/process > all the required details. > > My problem is, once activated, user can move these Child Windows off the > screen > by moving them around. Why don't you tell your users not be doing that? > > I would like to restrict the movement of these child windows within the client > area of the main window, so they are movable but not outside the client area > of main window. > > Is this possible? > > Regards, > Rad. Don Cole Bonds > Ruth. Giants STILL in last place Hmmmmmmmm!
8. Re: Restrining a child window's positioning within parent window
- Posted by don cole <doncole at pacbell.net> Jun 04, 2006
- 587 views
I you use: global constant CWindow = createEx( Window, "CWindow", Window1, 425,0, 308, 240,{WS_CHILD, WS_THICKFRAME}, 0 ) Then users can't move the window. Don Cole
9. Re: Restrining a child window's positioning within parent window
- Posted by Pete Stoner <stoner.pete at gmail.com> Jun 05, 2006
- 601 views
Rad wrote: > > I would like to restrict the movement of these child windows within the client > area of the main window, so they are movable but not outside the client area > of main window. Try using {WS_SYSMENU, WS_CHILD, WS_CAPTION} this is not resizeable, moves with the parent window and can be moved itself only within the parent. or if you don't want to allow any movement use either {WS_CHILD, WS_DLGFRAME} or {WS_CHILD, WS_BORDER} the last 2 move with the parent window but are not resizable or moveable by themselves. Regards PeteS
10. Re: Restrining a child window's positioning within parent window
- Posted by "Greg Haberek" <ghaberek at gmail.com> Jun 05, 2006
- 617 views
- Last edited Jun 06, 2006
> I have a Parent window containing many child windows. > > I want to restrain any child window from being moved out of parent window's > client area (using win32lib). I think what you want is the WS_CLIPCHILDREN style. This prevents the child windows from being moved outside the parent's client area.
include Win32Lib.ew without warning constant Main = create( Window, "Restrict Child Window Movement Demo", 0, Default, Default, 640, 480, WS_CLIPCHILDREN ), Child1 = create( Window, "Child Window", Main, Default, Default, 320, 240, w32or_all({WS_CHILD,WS_VISIBLE}) ) WinMain( Main, Normal )
11. Re: Restrining a child window's positioning within parent window
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 06, 2006
- 622 views
Greg Haberek wrote: > > > I have a Parent window containing many child windows. > > I want to restrain any child window from being moved out of parent window's > > client area (using win32lib). > > I think what you want is the WS_CLIPCHILDREN style. This prevents the > child windows from being moved outside the parent's client area. The example below fully restricts the child window so that no part of it goes beyond the parent's borders.
include Win32Lib.ew without warning constant Main = create( Window, "Restrict Child Window Movement Demo", 0, Default, Default, 640, 480, WS_CLIPCHILDREN ), Child1 = create( Window, "Child Window", Main, Default, Default, 320, 240, w32or_all({WS_CHILD,WS_VISIBLE}) ) constant WM_MOVING = #0216 procedure Moving_Child1(integer self, integer event, sequence parms) sequence lPos sequence vPos -- Only interested in moving windows. if parms[1] != WM_MOVING then return end if -- Get parent client area and calc boundaries. vPos = getClientSize(Main) vPos[3] += vPos[1] vPos[4] += vPos[2] -- Get boundaries of the moving window lPos = peek4s({parms[3],4}) -- Check that left, top, right and bottom edge is still inside -- the parent boundary, and if not recalc where the edges should be. if (lPos[1] < vPos[1]) then lPos[3] = vPos[1] + lPos[3] - lPos[1] lPos[1] = vPos[1] end if if (lPos[2] < vPos[2]) then lPos[4] = vPos[2] + lPos[4] - lPos[2] lPos[2] = vPos[2] end if if (lPos[3] > vPos[3]) then lPos[1] = vPos[3] - lPos[3] + lPos[1] lPos[3] = vPos[3] end if if (lPos[4] > vPos[4]) then lPos[2] = vPos[4] - lPos[4] + lPos[2] lPos[4] = vPos[4] end if -- Write back the new boundaries so Windows can reposition the window. poke4(parms[3], lPos) end procedure setHandler(Child1, w32HEvent, routine_id("Moving_Child1")) WinMain( Main, Normal )
-- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
12. Re: Restrining a child window's positioning within parent window
- Posted by Rad <radhx at rediffmail.com> Jun 06, 2006
- 565 views
Derek Parnell wrote: > > The example below fully restricts the child window so that no part of it > goes beyond the parent's borders. > Thanks Derek, this is was I was looking for. And thanks to all Euphorians for the help. One more Q Derek..... When child window is opened for first time, the top-left/right of client rectangle is correctly used. But then one can drag the window over "Toolbar" (but not over "Menu") at the top as well as over "Statusbar" at the bottom. If this a win32lib issue of not excluding toolbar and statusbar (if present) from client area of a window? Regards, Rad.
13. Re: Restrining a child window's positioning within parent window
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 06, 2006
- 586 views
Rad wrote: > When child window is opened for first time, the top-left/right of client > rectangle > is correctly used. But then one can drag the window over "Toolbar" (but not > over "Menu") at the top as well as over "Statusbar" at the bottom. If this a > win32lib issue of not excluding toolbar and statusbar (if present) from client > area of a window? Technically the status bar and tool bar are children of the window and are thus inside the parent's client area. However, I can see your point. All you need to do is take the height of these bars into consideration when calculating the parent's boundaries...
include Win32Lib.ew without warning constant Main = create( Window, "Restrict Child Window Movement Demo", 0, Default, Default, 640, 480, WS_CLIPCHILDREN ), SB = create(StatusBar, "", Main, 0, 0, 0, 0, 0), TB = create(ToolBar, "", Main, 0, 0, 40, 40, 0), Bnt1 = create(Button, "CLICK", TB, 4, 4, 50, 25, 0), Child1 = create( Window, "Child Window", Main, 0, 0, 320, 240, {WS_CHILD,WS_VISIBLE,WS_CAPTION,WS_SYSMENU} ) constant WM_MOVING = #0216 integer TBH integer SBH procedure Activate_Main(integer self, integer event, sequence parms) sequence lSB, lTB -- Force the screen to be fully rendered at startup time. repaintWindow(0) -- Calc height of statusbar and toolbar lSB = getRect(SB) SBH = lSB[4] - lSB[2] - 1 lTB = getRect(TB) TBH = lTB[4] - lTB[2] - 1 end procedure procedure Moving_Child1(integer self, integer event, sequence parms) sequence lPos sequence vPos -- Only interested in moving windows. if parms[1] != WM_MOVING then return end if -- Get parent client area and calc boundaries taking the -- status and tool bars into consideration. vPos = getClientSize(findParent(self)) vPos[2] += TBH vPos[3] += vPos[1] vPos[4] += vPos[2] - TBH - SBH -- Get boundaries of the moving window lPos = peek4s({parms[3],4}) -- Check that left, top, right and bottom edge is still inside -- the parent boundary, and if not recalc where the edges should be. if (lPos[1] < vPos[1]) then lPos[3] = vPos[1] + lPos[3] - lPos[1] lPos[1] = vPos[1] end if if (lPos[2] < vPos[2]) then lPos[4] = vPos[2] + lPos[4] - lPos[2] lPos[2] = vPos[2] end if if (lPos[3] > vPos[3]) then lPos[1] = vPos[3] - lPos[3] + lPos[1] lPos[3] = vPos[3] end if if (lPos[4] > vPos[4]) then lPos[2] = vPos[4] - lPos[4] + lPos[2] lPos[4] = vPos[4] end if -- Write back the new boundaries so Windows can reposition the window. poke4(parms[3], lPos) end procedure setHandler(Child1, w32HEvent, routine_id("Moving_Child1")) setHandler(Main, w32HActivate, routine_id("Activate_Main")) WinMain( Main, Normal )
-- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
14. Re: Restrining a child window's positioning within parent window
- Posted by Cuvier Christian <christian.cuvier at insee.fr> Jun 06, 2006
- 582 views
> Subject: Re: Restrining a child window's positioning within > parent window > > > posted by: don cole <doncole at pacbell.net> > > Rad wrote: > > > > Hi, > > > > I have a Parent window containing many child windows. > > > > I want to restrain any child window from being moved out of > parent window's > > client area (using win32lib). > > > > How can I do this? > > > > Regards, > > Rad. > > Hello Rad, > > I don't know exactly how to do this, but you would have to know, > > The size of you main window. > The size and location of all the children. > I would try getChildren() along with getSystemMetrics() to > monitor things. > Then setRect() to make sure do not exceed you limits. > > Don Cole > Bonds > Ruth. > Giants STILL in last place > Hmmmmmmmm! First of all, use addStyle(your_window,WS_CHILD), or, better, add this style in the create[Ex] statement used to create it. I can't test it right now, but that should be the simplest way. If the problem is preventing any portion of a child to be clipped out of the main window, it means that you can move the child. Hook the move, and then check if the child's client rect is inside the main client rect. "Hooking the move" means setting up a routine which will monitor the WM_MOVING message, then issuing
setWinMsgHandler(my_window,WM_MOVING,routine_id("my_handler"))
my_handler will be called with a pointer to a rectangle as its lparam argument. This is the rectangle of the moved window. Just peek4s and poke4 values there to check and set the new position. Offsets are: +0=left,+4=top,+8=right,+12=bottom. CChris
15. Re: Restrining a child window's positioning within parent window
- Posted by George Walters <gwalters at sc.rr.com> Jun 06, 2006
- 576 views
Derek, interesting example. On my computer if I drag the child window to the very top of the parent window then down, the top of the child window is somewhat destroyed and it's top is only several black lines. Is there a fix for this? I'm using 59.1 if that might make any difference.
16. Re: Restrining a child window's positioning within parent window
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 06, 2006
- 573 views
George Walters wrote: > > Derek, interesting example. On my computer if I drag the child window to the > very top of the parent window then down, the top of the child window is > somewhat destroyed and it's top is only several black lines. Is there a fix > for this? I'm using 59.1 if that might make any difference. Don't know why that's happening. I'm using the latest win32lib on XP and it works fine. Try repainting the child window. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
17. Re: Restrining a child window's positioning within parent window
- Posted by Rad <radhx at rediffmail.com> Jun 07, 2006
- 558 views
Derek Parnell wrote: > > Technically the status bar and tool bar are children of the window and are > thus > inside the parent's client area. However, I can see your point. > > All you need to do is take the height of these bars into consideration when > calculating the parent's boundaries... Thanks Derek. Got it working with your latest code. Regsrds, Rad.