Sign in to follow this  
zandarina

the toolbar disappears

Recommended Posts

zandarina    122
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

Share this post


Link to post
Share on other sites
LessBread    1415
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).

Share this post


Link to post
Share on other sites
zandarina    122
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);

Share this post


Link to post
Share on other sites
Aardvajk    13207
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

Share this post


Link to post
Share on other sites
zandarina    122
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

Share this post


Link to post
Share on other sites
Aardvajk    13207
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this