the toolbar disappears

Started by
4 comments, last by Aardvajk 17 years, 5 months ago
Hi, i am trying to add to my application a toolbar, using winapi. (I can't use MFC, because I have a win32 app). And when I run my app , my toolbar just appears a few seconds and suddenly disappears. It disappears when the scenary is loaded, and the scenary loads over the toolbar. I am using directx to paint. Thank you very much
Advertisement
The toolbar rides on top of the main window client area. Try adjusting your calculations to take into account the thickness of the toolbar (height for horizontal, width for vertical).
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Hi, thank you for answering, I have tried to change
the client window's coordinates but i just
made the windows smaller. Is there any way to change the
size of the client's windows , so that the render doesn't paint over toolbar?

I have tried the function setposition too but with no success.

Thanks
RECT rcClient,R;

GetClientRect(hwnd, &R);
GetWindowRect(hwndTB,&rcClient);
//ScreenToClient(hwnd,(LPPOINT)(&rcClient.right)); // convert the "bottom" member
R.top=rcClient.bottom;


MoveWindow(hwnd, R.left, R.top,R.right - R.left,R.bottom - R.top+20, TRUE);
GetClientRect(hwnd, &R);
To my knowledge, you can't change the size of a Window's client area like that. The client area is kind of defined by the size of the window and a toolbar or status bar will always occupy part of the client space.

I believe what LessBread meant was to take account of the size of the toolbar when doing your drawing and not draw in the area occupied by the toolbar. I know nothing about drawing to a window with DirectX (as you mentioned you are doing) but in a traditional response to a WM_PAINT, your pseudo might look a bit like:

RECT R; GetClientRect(Hw,&R);R.top+=HeightOfToolBar;FillRect(Dc,&R,MyFunkyBrush);


sort of thing.

The alternative would be to create a borderless sub-window that you place as a child window on the main window, aligned so its top is at the bottom of the toolbar and its bottom at the bottom of the main window client area. You could just then paint to the whole of the client area of the sub-window and move it appropriatley on resize events.

HTH
Hi, finally i have done what you suggested me, i have created a
new child windows and i haved painted it completely.
Maybe it 's not possible to paint only the client's area.

Thank you very much

Bye
Quote:Original post by zandarina
Hi, finally i have done what you suggested me, i have created a
new child windows and i haved painted it completely.
Maybe it 's not possible to paint only the client's area.

Thank you very much

Bye


The problem is that unlike the menu and system scroll bars, tool bars and status bars are part of the client area.

I think the child window solution is acceptable. It similar what you have to do with MDI applications when you create the MDI frame window and it simplifies all the drawing code, although it would be equally simple to provide a wrapper function for GetClientRect that took account of the bar controls.

If anyone knows a simpler way, I'd be interested.

This topic is closed to new replies.

Advertisement