static void PositionHeader(HWND hwndListView) { HWND hwndHeader = GetWindow(hwndListView, GW_CHILD); DWORD dwStyle = GetWindowLong(hwndListView, GWL_STYLE); /*To ensure that the first item will be visible, create the control without the LVS_NOSCROLL style and then add it here*/ dwStyle |= LVS_NOSCROLL; SetWindowLong(hwndListView, GWL_STYLE, dwStyle); //only do this if we are in report view and were able to get the header hWnd if(((dwStyle & LVS_TYPEMASK) == LVS_REPORT) && hwndHeader) { RECT rc; HD_LAYOUT hdLayout; WINDOWPOS wpos; GetClientRect(hwndListView, &rc); hdLayout.prc = &rc; hdLayout.pwpos = &wpos; Header_Layout(hwndHeader, &hdLayout); SetWindowPos( hwndHeader, wpos.hwndInsertAfter, wpos.x, wpos.y, wpos.cx, wpos.cy, wpos.flags | SWP_SHOWWINDOW); ListView_EnsureVisible(hwndListView, 0, FALSE); } }
wxSize wxHeaderCtrl::DoGetBestSize() const { RECT rc = wxGetClientRect(GetHwndOf(GetParent())); WINDOWPOS wpos; HDLAYOUT layout = { &rc, &wpos }; if ( !Header_Layout(GetHwnd(), &layout) ) { wxLogLastError(wxT("Header_Layout")); return wxControl::DoGetBestSize(); } return wxSize(wpos.cx, wpos.cy); }
int wxRendererMSW::GetHeaderButtonHeight(wxWindow * WXUNUSED(win)) { // some "reasonable" value returned in case of error, it doesn't really // correspond to anything but it's better than returning 0 static const int DEFAULT_HEIGHT = 20; // create a temporary header window just to get its geometry HWND hwndHeader = ::CreateWindow(WC_HEADER, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); if ( !hwndHeader ) return DEFAULT_HEIGHT; wxON_BLOCK_EXIT1( ::DestroyWindow, hwndHeader ); // initialize the struct filled with the values by Header_Layout() RECT parentRect = { 0, 0, 100, 100 }; WINDOWPOS wp = { 0, 0, 0, 0, 0, 0, 0 }; HDLAYOUT hdl = { &parentRect, &wp }; return Header_Layout(hwndHeader, &hdl) ? wp.cy : DEFAULT_HEIGHT; }
BOOL CXTPHeaderCtrl::RecalcLayout() { if (!::IsWindow(m_hWnd)) return FALSE; HD_LAYOUT hdl; CXTPClientRect rcClient(this); hdl.prc = &rcClient; WINDOWPOS wp; ZeroMemory(&wp, sizeof(WINDOWPOS)); hdl.pwpos = ℘ if (!Header_Layout(m_hWnd, &hdl)) return FALSE; // Set the size, position, and visibility of the header window. ::SetWindowPos(m_hWnd, wp.hwndInsertAfter, wp.x, wp.y, wp.cx, wp.cy, wp.flags | SWP_FRAMECHANGED); CWnd* pWndParent = GetParent(); if (!::IsWindow(pWndParent->GetSafeHwnd())) return FALSE; // Force list control to recalculate it's layout. CXTPWindowRect rcWindow(pWndParent); const int cx = rcWindow.Width(); const int cy = rcWindow.Height(); pWndParent->SetWindowPos(NULL, 0, 0, cx, cy+1, SWP_NOMOVE | SWP_FRAMECHANGED); pWndParent->SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_FRAMECHANGED); return TRUE; }
void FileChildWindow::resize_children(int cx, int cy) { HDWP hdwp = BeginDeferWindowPos(4); RECT rt; rt.left = 0; rt.top = 0; rt.right = cx; rt.bottom = cy; cx = _split_pos + SPLIT_WIDTH/2; if (_left && _right) { WINDOWPOS wp; HD_LAYOUT hdl; hdl.prc = &rt; hdl.pwpos = ℘ Header_Layout(_left->_hwndHeader, &hdl); hdwp = DeferWindowPos(hdwp, _left->_hwndHeader, wp.hwndInsertAfter, wp.x-1, wp.y, _split_pos-SPLIT_WIDTH/2+1, wp.cy, wp.flags); hdwp = DeferWindowPos(hdwp, _right->_hwndHeader, wp.hwndInsertAfter, rt.left+cx+1, wp.y, wp.cx-cx+2, wp.cy, wp.flags); } if (_left_hwnd) hdwp = DeferWindowPos(hdwp, _left_hwnd, 0, rt.left, rt.top, _split_pos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); if (_right_hwnd) hdwp = DeferWindowPos(hdwp, _right_hwnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); EndDeferWindowPos(hdwp); }
void DoLayoutRepStuff(HWND hwnd, LPLAYOUT pfr) { HD_LAYOUT FAR* playout; HD_LAYOUT lay; RECT rc = { 0, 0, 0, 0 }; WINDOWPOS wpos = { NULL, NULL, 0, 0, 0, 0, 0 }; int ret; HGLOBAL hglb; rc.left = pfr->left; rc.right = pfr->right; rc.top = pfr->top; rc.bottom = pfr->bottom; if (pfr->NullHDLAYOUT) playout = NULL; else playout = &lay; if (pfr->NullWindowPOS) lay.pwpos = NULL; // can this be done ?? else { lay.pwpos = &wpos; } if (pfr->NullRECT) lay.prc = NULL; else lay.prc = &rc; if (pfr->NullHwd) ret = Header_Layout(NULL, playout); else ret = Header_Layout(pfr->hwnd, playout); wsprintf(szDbgMsg, "%d = Header_LayoutItem()", ret); MyDebugMsg(DM_TRACE, "%s", (LPCSTR) szDbgMsg); SetDlgItemInt(hwnd, IDC_LAYOUTRET, ret, TRUE) ; if (ret) { // RECT struct SetDlgItemInt(hwnd, IDC_LAYOUTLEFT, rc.left, TRUE); SetDlgItemInt(hwnd, IDC_LAYOUTRIGHT, rc.right, TRUE); SetDlgItemInt(hwnd, IDC_LAYOUTTOP, rc.top, TRUE); SetDlgItemInt(hwnd, IDC_LAYOUTBOTTOM, rc.bottom, TRUE); // WindowPOS struct wsprintf(szTemp, szLongFilter, (DWORD) wpos.hwnd) ; SetDlgItemText(hwnd, IDC_LAYOUTHWND, szTemp); wsprintf(szTemp, szLongFilter, wpos.hwndInsertAfter); SetDlgItemText(hwnd, IDC_LAYOUTHWNDINSERTAFTER, szTemp); SetDlgItemInt(hwnd, IDC_LAYOUTX, wpos.x, TRUE); SetDlgItemInt(hwnd, IDC_LAYOUTY, wpos.y, TRUE); SetDlgItemInt(hwnd, IDC_LAYOUTCX, wpos.cx, TRUE); SetDlgItemInt(hwnd, IDC_LAYOUTCY, wpos.cy, TRUE); CheckDlgButton(hwnd, IDC_LAYOUTDRAWFRAME, wpos.flags & SWP_DRAWFRAME); CheckDlgButton(hwnd, IDC_LAYOUTHIDEWINDOW, wpos.flags & SWP_HIDEWINDOW); CheckDlgButton(hwnd, IDC_LAYOUTNOACTIVATE, wpos.flags & SWP_NOACTIVATE); CheckDlgButton(hwnd, IDC_LAYOUTNOZORDER, wpos.flags & SWP_NOOWNERZORDER); CheckDlgButton(hwnd, IDC_LAYOUTNOSIZE, wpos.flags & SWP_NOSIZE); CheckDlgButton(hwnd, IDC_LAYOUTNOREDRAW, wpos.flags & SWP_NOREDRAW); CheckDlgButton(hwnd, IDC_LAYOUTNOREPOSITION, wpos.flags & SWP_NOREPOSITION); CheckDlgButton(hwnd, IDC_NOZORDER, wpos.flags & SWP_NOZORDER); } }