المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Different GUI rendereng between WinXP and Vista-Win7



C++ Programming
11-27-2011, 09:33 AM
Hi,

I have gotten arount Most of the security challenges around the New Windows Model.
One issue remains a challenge. I created a derrived MFC Control: 'CMultiColumListBox', derived from MFC-'CListBox'. It in turn, is used as a Baseclass for various data tabulations. it all works to perfection under Win 95/98. Win NT, and Windows XP. With Vista and Windows 7, the Header Button listtakes up about 80% of the width of the CListbox Window, the Text Colums take up even Less.
One part of the creation process sets up the display Geometry parameters. I must have missed a Translation Somewhere.

The Salient part of the control that does this is as follows:-

BOOL CMultiColumListBox::RegisterControl(CDialog * pDialog){ if(!m_bDrawButtons)return TRUE; ASSERT(pDialog->IsKindOf( RUNTIME_CLASS(CWnd) ) ); ASSERT(::IsWindow(pDialog->m_hWnd)); CDC* pDC=pDialog->GetDC(); ASSERT(pDC); m_pParentDialog=pDialog; CRect CtrlRect,DlgWndRect,DlgClientRect,BnRect; GetWindowRect(&CtrlRect);// Coordinates based on WindowRect // pDialog->GetWindowRect(&DlgWndRect); // Calculate the height of the Title Bar // We need this to calculate the Position of // the Header tabs in Client Coordinates pDialog->GetClientRect(&DlgClientRect); int BorderWidth=DlgWndRect.Width() - DlgClientRect.Width(); int TitleBarHeight=DlgWndRect.Height() - DlgClientRect.Height()-BorderWidth; BorderWidth/=2; int Base_x,Base_y,BaseWidth; Base_x=CtrlRect.left-1; Base_y=CtrlRect.top; BaseWidth=CtrlRect.Width(); for(int i=0;i<span class="code-keyword">GetDlgItem(m_nColumList[i].n_ID); ASSERT(pWnd); pWnd->ShowWindow(SW_NORMAL); int Width=m_nColumList[i].width; if(i==m_nNrOfColumns-1)Width=BaseWidth; if(Width>BaseWidth)Width=BaseWidth; BnRect.left=Base_x-DlgWndRect.left-BorderWidth; BnRect.right=Base_x+Width-DlgWndRect.left-BorderWidth; BnRect.top=Base_y-m_nItemHeight*2-TitleBarHeight-DlgWndRect.top-1; BnRect.bottom=Base_y-TitleBarHeight-DlgWndRect.top-1; pWnd->MoveWindow(&BnRect);// Moves Based on ClientRect Base_x+=Width; BaseWidth-=Width; char* p=m_nColumList[i].lpcstrColumHeader; if(p)pWnd->SetWindowText(p); } return TRUE;}
This function would Typicaly be called from OnInitDialog()from the Dlg that contains it. It sets the Parameters for subsequent Drawing and Painting.

Any Idea about DlgToScreen() ScreenToDlg(),etc tha should have been used here






http://www.barakasoft.com/script/Forums/Images/smiley_confused.gif
Bram van Kampen