![]() |
| ||
| Calculating a control position on a window Hi, I am trying to create a treeview control in a window that includes a toolbar and a status bar, I need to position the treeview immediately below the toolbar. In order to do this I need to calculate the height of the toolbar and used it as the Y parameter in the CreateWindowEx function that creates the Treeview. The problem is that the treeview appears on top of the toolbar covering the lower part of it. I am using the function below to calculate the height for both the toolbar and status bar to position the treeview between both of them. The calculation is correct for the status bar but something is wrong for the toolbar, that is the treeview appear immediately above the status bar but does not appear immediately below the toolbar. Below is my code: This is the function to calculate the height for both the toolbar and the status bar: This is the function for creating the treeview: /* Calculate the client area of the parent window */ I appreciate it if anybody can tell me what is wrong. Thank you in advance. |
| ||
| Re: Calculating a control position on a window Could you post a short example program that we can compile, and that demonstrates the problem? |
| ||
| Re: Calculating a control position on a window Can you do something like this in the WM_SIZE event and tell me what happens? case WM_SIZE: |
| ||
| Re: Calculating a control position on a window Thanks for both GloriousEremite and WolfPack for responding to my request. I found the error but I am posting the corrected code below so that other people can benefit from my mistake. But maybe you can help me with one more minor problem. When the form shows up if you click the menu item File, Exit. The help text appears in the status bar but the three parts of the status bar disappear. They reapear once again if you resize the window. Any idea why?
The error was that I did not define the HWND hStatusBar, hToolBar, hTreeView as static. And the other change I made is that I added the following piece of code in the SIZE message:
But to be honest I still don't understand why not having the MoveWindow function would have such impact when the form is created (before any sizing message) !!! |
| ||
| Re: Calculating a control position on a window Quote:
SendMessage(GetDlgItem(hwnd, IDC_STATUSBAR), SB_SETTEXT, 255, (LPARAM)(LPSTR)"Ready");The WPARAM argument should be a zero-based index (with 255/SB_SIMPLEID it probably assumes the control is a single-part bar) |
| ||
| Re: Calculating a control position on a window Thanks, it works now. |
| All times are GMT -4. The time now is 6:23 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC