Software Archive
Read-only legacy content
17061 Discussions

Effective client area

wkramer
Beginner
540 Views
Hello,

I am trying to implement a status bar in a windows application with a single edit control in the client area.

To prevent the status bar from being painted over the edit control I tried to use the following approach:

After creating the Status bar using "CreateStatusWindow" I try to call "GetEffectiveClientRect" to find the rectangular area remaining for the edit control.

The code I use with WM_CREATE looks something like this:

     
szDescription="flup"C
hwndStatbar=CreateStatusWindow(IOR (WS_CHILD,WS_VISIBLE),szDescription, &
hwnd,IDM_STATUSBAR)
call GetEffectiveClientRect(Hwnd,Rect,RectInfo)
hwndEdit = CreateWindowEx(0,"edit"C, &
""C, &
IOR(WS_CHILD, IOR(WS_VISIBLE, &
IOR(WS_HSCROLL, IOR(WS_VSCROLL, &
IOR(WS_BORDER, IOR(ES_LEFT, &
IOR(ES_MULTILINE, IOR(ES_NOHIDESEL, &
IOR(ES_AUTOHSCROLL, IOR(ES_READONLY, &
ES_AUTOVSCROLL)))))))))), &
Rect.left, Rect.top, Rect.right, Rect.bottom, &
hwnd, EDITID, ghInstance, NULL)



Declarations of variables and constants:

 
integer(2), parameter :: IDM_STATUSBAR = 501
type(T_RECT) Rect
integer(2), dimension(4) :: RectInfo=(/1,IDM_STATUSBAR,0,0/)



However, GetEffectiveClientRect returns the same Rect data as GetClientRect would. So the edit control is painted over the status bar. I have my doubts about the RectInfo array.


Does anyone have an idea? Perhaps I am using a completely wrong approach?


Thanks,



Walter Kramer
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
540 Views
Hi Walter,

Frankly, this is the first time I hear about GetEffectiveClientRect. Why not
simply subtract status bar from frame's client rect in order to obtain
desired height of edit control?:

 
CALL GetWindowRect(hWndStatbar,Rect) 
iStatusHeight=Rect%Bottom - Rect%Top 
CALL GetClientRect(hWnd,Rect) 
 
hWndEdit=CreateWindowEx(... 
               Rect%left, Rect%top, Rect%right, Rect%bottom-iStatusHeight 
               ...) 
 


HTH

Jugoslav
0 Kudos
wkramer
Beginner
540 Views
Hi, Jugoslav



Thank you, this works without any problem.




Walter Kramer
0 Kudos
Reply