MDI child windows

MDI child windows

Post by Dan Ritchi » Tue, 02 Dec 2003 06:45:40



Hi all. I have a problem with MDI forms. I have a window
that is a child of an MDI form and I'm saving the windows
position and size to the registry so I can retrieve it
when my program restarts. Problem is, I'm getting an
offset because MDI child windows use the client area of
the MDI form instead of screen coordinates. (My forms
creep downward more everytime I restart the app)
So, I need a function that will let me read and set the
position in absolute cooridinates, or I need to compensate
for the offset. Any ideas?
 
 
 

MDI child windows

Post by alpin » Tue, 02 Dec 2003 08:04:08

On Sun, 30 Nov 2003 13:45:40 -0800, "Dan Ritchie"




Standard behavior for MDI child windows is to either cascade or tile
within the MDI parent. A better suggestion would be to just set the
size of the child windows and let the MDI parent show each child
window where it chooses.

If you feel you must set the position of the window, why not use each
form's Left and Top property? These will give you the correct
position within the MDI parent.

HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don' XXXX@XXXXX.COM Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas

 
 
 

MDI child windows

Post by anonymou » Wed, 03 Dec 2003 07:16:37


window
windows
compensate
cascade or tile
just set the
each child
not use each
correct

The windows I'm opening are tools that get associated with
the MDI form, (Plugins, if you will) that I want to be
open in from of my MDI form.
They're separate executables, who's windows I pass as an
object through an activeX interface. I then open the
windows like MyObject.show ,MDIform

I'm sure this isn't supported, but it's the only way I've
found to open another apps window on top of an mdi form.

I'm totaly open to other suggestions, but I could use some
help with the original problem, otherwise.
 
 
 

MDI child windows

Post by alpin » Wed, 03 Dec 2003 09:17:15

On Mon, 1 Dec 2003 14:16:37 -0800,




Have you tried setting the owner of your "tool" windows to the MDI
form? Just pass the MDI form as the second parameter to the Show
method for the tool object.

HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don' XXXX@XXXXX.COM Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
 
 
 

MDI child windows

Post by Randy Birc » Wed, 03 Dec 2003 11:46:41

Check out the ScreenToClient and ClientToScreen APIs. I have demos that use
either or both (for other purposes) on my site, which will at least show
their use. http://www.yqcomputer.com/

--

Randy Birch
MVP Visual Basic
http://www.yqcomputer.com/
Please respond only to the newsgroups so all can benefit.




:
: Hi all. I have a problem with MDI forms. I have a window
: that is a child of an MDI form and I'm saving the windows
: position and size to the registry so I can retrieve it
: when my program restarts. Problem is, I'm getting an
: offset because MDI child windows use the client area of
: the MDI form instead of screen coordinates. (My forms
: creep downward more everytime I restart the app)
: So, I need a function that will let me read and set the
: position in absolute cooridinates, or I need to compensate
: for the offset. Any ideas?
:
 
 
 

MDI child windows

Post by anonymou » Wed, 03 Dec 2003 12:38:46


That just took me to a VBnet search page.


have demos that use
will at least show
http://www.yqcomputer.com/


window
windows
compensate
 
 
 

MDI child windows

Post by anonymou » Wed, 03 Dec 2003 12:42:38

>
to the MDI
the Show


"I then open the windows like MyObject.show ,MDIform"
Yep. That's what I'm doing. The problem is I don't get
the right offset when I set the possition.
 
 
 

MDI child windows

Post by Randy Birc » Wed, 03 Dec 2003 12:57:37

Yes ... I said there are several examples of those APIs ... search for them.

--

Randy Birch
MVP Visual Basic
http://www.yqcomputer.com/
Please respond only to the newsgroups so all can benefit.




:
: That just took me to a VBnet search page.
:
:
: >-----Original Message-----
: >Check out the ScreenToClient and ClientToScreen APIs. I
: have demos that use
: >either or both (for other purposes) on my site, which
: will at least show
: >their use.
: http://www.yqcomputer.com/
: >
: >--
: >
: >Randy Birch
: >MVP Visual Basic
: > http://www.yqcomputer.com/
: >Please respond only to the newsgroups so all can benefit.
: >
: >


: >:
: >: Hi all. I have a problem with MDI forms. I have a
: window
: >: that is a child of an MDI form and I'm saving the
: windows
: >: position and size to the registry so I can retrieve it
: >: when my program restarts. Problem is, I'm getting an
: >: offset because MDI child windows use the client area of
: >: the MDI form instead of screen coordinates. (My forms
: >: creep downward more everytime I restart the app)
: >: So, I need a function that will let me read and set the
: >: position in absolute cooridinates, or I need to
: compensate
: >: for the offset. Any ideas?
: >:
: >
: >
: >.
: >
 
 
 

MDI child windows

Post by alpin » Wed, 03 Dec 2003 13:03:20

On Mon, 1 Dec 2003 19:42:38 -0800,




How are you setting the position now? (post the relevant code)

HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don' XXXX@XXXXX.COM Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
 
 
 

MDI child windows

Post by Dan Ritchi » Thu, 04 Dec 2003 07:21:16

>
code)

I'm just saving out the form.left and form.top properties
and loading them in again.


'save position to registry (of all forms) ' for n=0 to
number of forms -1...
'
SaveSetting MyApp, MySection, Keyname, Forms(n).Top
'


'get position from registry 'in window load event.
T = GetSetting(MyApp, MySection, KeyName, -1)
'
'if I get the default value (-1) I just skip ...
'else
Form.Top = T
'
 
 
 

MDI child windows

Post by Randy Birc » Thu, 04 Dec 2003 07:37:17

Don't forget that the value returned by GetSetting is a string ... and
you're assigning a string to a property expecting a numeric value. Use
Val(T).

--

Randy Birch
MVP Visual Basic
http://www.yqcomputer.com/
Please respond only to the newsgroups so all can benefit.




: >
: >How are you setting the position now? (post the relevant
: code)
:
: I'm just saving out the form.left and form.top properties
: and loading them in again.
:
:
: 'save position to registry (of all forms) ' for n=0 to
: number of forms -1...
: '
: SaveSetting MyApp, MySection, Keyname, Forms(n).Top
: '
:
:
: 'get position from registry 'in window load event.
: T = GetSetting(MyApp, MySection, KeyName, -1)
: '
: 'if I get the default value (-1) I just skip ...
: 'else
: Form.Top = T
: '
:
 
 
 

MDI child windows

Post by anonymou » Thu, 04 Dec 2003 07:57:20


Sorry, didn't realize they were API calls when I couldn't
find ScreenToClient in API guide. I found ClientToScreen
though.


APIs ... search for them.


I
benefit.
message

it
of
forms
the
 
 
 

MDI child windows

Post by Randy Birc » Thu, 04 Dec 2003 08:03:12

ScreenToClient is in the api viewer as well.

Private Declare Function ScreenToClient Lib "user32" Alias "ScreenToClient"
(ByVal hwnd As Long, lpPoint As POINTAPI) As Long


--

Randy Birch
MVP Visual Basic
http://www.yqcomputer.com/
Please respond only to the newsgroups so all can benefit.




:
: Sorry, didn't realize they were API calls when I couldn't
: find ScreenToClient in API guide. I found ClientToScreen
: though.
:
:
: >-----Original Message-----
: >Yes ... I said there are several examples of those
: APIs ... search for them.
: >
: >--
: >
: >Randy Birch
: >MVP Visual Basic
: > http://www.yqcomputer.com/
: >Please respond only to the newsgroups so all can benefit.
: >
: >


: >:
: >: That just took me to a VBnet search page.
: >:
: >:
: >: >-----Original Message-----
: >: >Check out the ScreenToClient and ClientToScreen APIs.
: I
: >: have demos that use
: >: >either or both (for other purposes) on my site, which
: >: will at least show
: >: >their use.
: >: http://www.yqcomputer.com/
: >: >
: >: >--
: >: >
: >: >Randy Birch
: >: >MVP Visual Basic
: >: > http://www.yqcomputer.com/
: >: >Please respond only to the newsgroups so all can
: benefit.
: >: >
: >: >
: >: >"Dan Ritchie" < XXXX@XXXXX.COM > wrote in
: message

: >: >:
: >: >: Hi all. I have a problem with MDI forms. I have a
: >: window
: >: >: that is a child of an MDI form and I'm saving the
: >: windows
: >: >: position and size to the registry so I can retrieve
: it
: >: >: when my program restarts. Problem is, I'm getting an
: >: >: offset because MDI child windows use the client area
: of
: >: >: the MDI form instead of screen coordinates. (My
: forms
: >: >: creep downward more everytime I restart the app)
: >: >: So, I need a function that will let me read and set
: the
: >: >: position in absolute cooridinates, or I need to
: >: compensate
: >: >: for the offset. Any ideas?
: >: >:
: >: >
: >: >
: >: >.
: >: >
: >
: >
: >.
: >
 
 
 

MDI child windows

Post by alpin » Thu, 04 Dec 2003 08:32:24

On Tue, 2 Dec 2003 14:21:16 -0800, "Dan Ritchie"




If you aren't doing anything special, like using the SetParent API
function to make these forms children of the MDI client, this should
be returning the correct screen position the next time you load each
form. Somehow, I get the feeling we still don't have the whole
picture here....

HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don' XXXX@XXXXX.COM Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
 
 
 

MDI child windows

Post by Rick Mogst » Fri, 05 Dec 2003 03:21:33

but its not in API Guide, which a lot of developers use Exclusively for APIs.