Hi,
understanding that the method ::GetRect() always returns an oRect with the coordinates on the main window.
But how to get the coordinates of a child window (TMdiChild) relative to the parent window (TMdiFrame) when the user moved/sized it?
Is there a method or function which is doing this job or have I write one for my own
Any suggestion for this 'HowTo' are welcome
How to get the coordinates of a child window?
Re: How to get the coordinates of a child window?
The methods :GetCliRect() and :GetCliAreaRect() are doing exactly what I was looking for
Here are some posts regarding these two methods:
http://forums.fivetechsupport.com/viewt ... ect#p41038:
Antonio wrotes:
Conclusions:
:GetCliRect() - returns an oRect with the relative gross coordinates, mean including the menu (SM_CYMENU), button and message bar,...
:GetCliAreaRect() - returns an oRect with the relative net coordinates, mean excluding the menu, button and message bar,...
Both oRect excluded the window title (SM_CYCAPTION) and frame (SM_CYDLGFRAME, SM_CYDLGFRAME)
Any comments or corrections
Here are some posts regarding these two methods:
http://forums.fivetechsupport.com/viewt ... ect#p41038:
Antonio wrotes:
http://forums.fivetechsupport.com/viewt ... ect#p62355:The buttonbar and the messagebar are also controls, in the same way as SAYs, GETs, Buttons, etc.
You just need to use oBar:nHeight and oMsgBar:nHeight to calculate the right coordinates for the other controls
When you do oWnd:oClient = oControl the FWH calculates the remaining client area automatically
http://forums.fivetechsupport.com/viewt ... =6&t=35139&:Can you be more specific about your problem. It seams to me now, you have the same problem I as have. My question is: do you create browse from RESOURCE (.RC or .DLL) or you put it on the dialog with @ y,x commands? It is important. If I don't use resources, I can fit browse without problem, but if I use resources, then there are problems, browse doesn't fit always in the dialog! The difference arise when I change the system settings related to the font sizes! (Setup-display-settings-font size).
Try: ...
lo que hace es centrar en la pantalla, no en la ventana contenedora.
A mi entender, creo que deberia de funcionar el evento Center() del ejemplo anterior, seria lo mas "correcto"
Y para centrarlo, de momento... lo hago "calculando" el ancho/alto...
Code: Select all
#include "FiveWin.ch"
function Main()
local oWnd, oChild1
Local nClientWidth
DEFINE WINDOW oWnd FROM 1,0 TO 500,800 PIXEL
nClientWidth := oWnd:GetCliAreaRect():nWidth
DEFINE WINDOW oChild1 FROM 0, (nClientWidth-250)/2 TO 0, (nClientWidth/2)+125 PIXEL OF oWnd
oChild1:nHeight := oWnd:GetCliAreaRect():nHeight
oChild1:Show()
ACTIVATE WINDOW oWnd
Return nil
:GetCliRect() - returns an oRect with the relative gross coordinates, mean including the menu (SM_CYMENU), button and message bar,...
:GetCliAreaRect() - returns an oRect with the relative net coordinates, mean excluding the menu, button and message bar,...
Both oRect excluded the window title (SM_CYCAPTION) and frame (SM_CYDLGFRAME, SM_CYDLGFRAME)
Any comments or corrections
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: How to get the coordinates of a child window?
You are right.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: How to get the coordinates of a child window?
but GetCliRect() and GetCliAreaRect() doesn't work as expected, nTop and nLeft are always 0
I then tried GetCoors() and it works:
I then tried GetCoors() and it works:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: How to get the coordinates of a child window?
They always start with 0,0. That is to be expected.but GetCliRect() and GetCliAreaRect() doesn't work as expected
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: How to get the coordinates of a child window?
Ok, that is what I suspected, but I wasn't quite sure, if it is true, because it's not very clear explained here:
https://docs.microsoft.com/en-us/window ... clientrect
Nevertheless, I have got want I want and can go further now
https://docs.microsoft.com/en-us/window ... clientrect
They should be say:Retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0).
... the coordinates of the upper-left corner are ALWAYS (0,0).
Nevertheless, I have got want I want and can go further now