// /// This method repositions the columnHeader control within the client area /// of its parent window by taking advantage of the columnHeader's ability /// to specify its desired/appropriate position from a specified bounding /// rectangle. This method assumes that the control will occupy the full /// width of the client area of its parent. // bool TColumnHeader::Layout(uint swpFlags) { WINDOWPOS wp; TRect rect = GetParentO()->GetClientRect(); if (Layout(rect, wp)) { SetWindowPos(wp.hwndInsertAfter, wp.x, wp.y, wp.cx, wp.cy, wp.flags|swpFlags); return true; } return false; }
/// Move and resize the window so that the window is the same size as the hyperlink /// text. This stops the hyperlink cursor being active when it is not directly over /// the text. If the text is left justified then the window is merely shrunk, but if /// it is centred or right justified then the window will have to be moved as well. // // Suggested by Pål K. Tønder void TUrlLink::PositionWindow() { // Get the current window position TRect rect; GetWindowRect(rect); TWindow* pParent = GetParentO(); if(pParent){ pParent->ScreenToClient(rect.TopLeft()); pParent->ScreenToClient(rect.BottomRight()); } // Get the size of the window text TTmpBuffer<tchar> buffer(MAX_PATH); GetText(buffer, MAX_PATH); TSize size = LinkFont->GetTextExtent(&buffer[0]); // Get the text justification via the window style uint32 style = GetStyle(); //TWindow // Recalc the window size and position based on the text justification if (style & SS_CENTERIMAGE) rect.Inflate(0, -(rect.Height() - size.cy)/2); else rect.bottom = rect.top + size.cy; if (style & SS_CENTER) rect.Inflate( -(rect.Width() - size.cx)/2, 0); else if (style & SS_RIGHT) rect.left = rect.right - size.cx; else // SS_LEFT = 0, so we can't test for it explicitly rect.right = rect.left + size.cx; // Move the window SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER); }
// /// Draws the drag cursor. // void TDragList::DrawInsert(int item) { if (TCommCtrl::IsAvailable()) TCommCtrl::Dll()->DrawInsert(*GetParentO(), *this, item); }
// /// Common initialization of the contained data structures. // void TPrintDialog::Init() { memset(&Pd, 0, sizeof Pd); Pd.lStructSize = sizeof Pd; Pd.hwndOwner = GetParentO() ? GetParentO()->GetHandle() : 0; Pd.hInstance = *GetModule(); Pd.Flags = PD_ENABLEPRINTHOOK | PD_ENABLESETUPHOOK | Data.Flags; Pd.Flags &= ~PD_RETURNDEFAULT; if (PrintTemplateName.length() > 0) { Pd.lpPrintTemplateName = PrintTemplateName.c_str(); Pd.Flags |= PD_ENABLEPRINTTEMPLATE; } else Pd.Flags &= ~PD_ENABLEPRINTTEMPLATE; if (SetupTemplateName.length() > 0) { Pd.lpSetupTemplateName = SetupTemplateName.c_str(); Pd.Flags |= PD_ENABLESETUPTEMPLATE; } else Pd.Flags &= ~PD_ENABLESETUPTEMPLATE; Pd.lpfnPrintHook = 0; Pd.lpfnSetupHook = 0; Pd.nFromPage = (uint16)Data.FromPage; Pd.nToPage = (uint16)Data.ToPage; Pd.nMinPage = (uint16)Data.MinPage; Pd.nMaxPage = (uint16)Data.MaxPage; Pd.nCopies = (uint16)Data.Copies; memset(&Psd, 0, sizeof Psd); Psd.lStructSize = sizeof Psd; Psd.hwndOwner = GetParentO() ? GetParentO()->GetHandle() : 0; Psd.hInstance = *GetModule(); Psd.Flags = PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGEPAINTHOOK | Data.PageSetupFlags; if (SetupTemplateName.length() > 0) { Psd.lpPageSetupTemplateName = SetupTemplateName.c_str(); Psd.Flags |= PSD_ENABLEPAGESETUPTEMPLATE; } else Psd.Flags &= ~PSD_ENABLEPAGESETUPTEMPLATE; Psd.lpfnPageSetupHook = 0; Psd.lpfnPagePaintHook = 0; Psd.ptPaperSize = Data.PaperSize; Psd.rtMinMargin = Data.MinMargin; Psd.rtMargin = Data.Margin; #if WINVER >= 0x0500 memset(&Pde, 0, sizeof Pde); Pde.lStructSize = sizeof Pde; // Note: PRINTDLGEX::hwndOwner cannot be NULL (see Windows API). // But, we need to maintain compatibility with older versions which allowed Parent == 0. // So, if no parent has been passed we'll try to assign the main window handle. // If this fails we'll handle the problem in DoExecute by reverting to the old dialog. TWindow* main_window = GetApplication() ? GetApplication()->GetMainWindow() : 0; Pde.hwndOwner = GetParentO() ? GetParentO()->GetHandle() : main_window ? main_window->GetHandle() : NULL; Pde.hInstance = *GetModule(); Pde.Flags = Data.Flags; Pde.Flags &= ~PD_RETURNDEFAULT; Pde.Flags2 = 0; Pde.nStartPage = START_PAGE_GENERAL; // Needed, won't work otherwise even for PD_RETURNDEFAULT if (PrintTemplateName.length() > 0) { Pde.lpPrintTemplateName = PrintTemplateName.c_str(); Pde.Flags |= PD_ENABLEPRINTTEMPLATE; Pde.hInstance = GetModule()->GetHandle(); } else { Pde.Flags &= ~PD_ENABLEPRINTTEMPLATE; Pde.hInstance = 0; } Pde.lpCallback = 0; Pde.nMaxPageRanges = 1; Pde.lpPageRanges = &PdeRange; Pde.lpPageRanges[0].nFromPage = (uint16)Data.FromPage; Pde.lpPageRanges[0].nToPage = (uint16)Data.ToPage; Pde.nMinPage = (uint16)Data.MinPage; Pde.nMaxPage = (uint16)Data.MaxPage; Pde.nCopies = (uint16)Data.Copies; #endif //#if WINVER >= 0x0500 }