Dynamically Resize Listbox and Tab Control

Hello,

I am writing an application that is a Tab based list control. You can select one of several tabs, and the list control gets populated based on which tab you are on. That works fine. However, I am having a challange with regards to dynamically resizing the control. Basically, whenever the user resizes the parent window (Main Frame), I want the tab box and list control to resize dynamically. While I currently have it working, I don't think it's clean. Here is how I do it:

OnSize(), I call three functions:

m_list.GetWindowRect(&rect);
GetWindowRect(&rectwnd);
m_tab.GetWindowRect(&recttab);

I then call GetWindowPlacement(&wp); for the parent window and set the tab box to the parent's window placement by calling m_tab.SetWindowPlacement(&wp);

I then call the following set of functions to dynamically resize the listbox in relation to the tab control:

windefer=BeginDeferWindowPos(1);

DeferWindowPos(windefer,m_list.m_hWnd,HWND_NOTOPMOST, 5, 30, rectwnd.right - rectwnd.left,rectwnd.bottom - (recttab.top + 30),SWP_SHOWWINDOW|SWP_NOZORDER);

EndDeferWindowPos(windefer);


Again, this does the trick, but I don't think it's clean, and I was interested to see if anyone has a better way of doing it.

Thanks!

Avi


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories