Après vérification le MoveWindow suffit largement, c'était tout con en fait
Voici la classe au cas où ça intéresse quelqu'un
EditCustom.cpp :
EditCustom.h :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 // CEditCustom IMPLEMENT_DYNAMIC(CEditCustom, CEdit) CEditCustom::CEditCustom() { this->m_TopMargin = 0; this->m_BottomMargin = 0; } CEditCustom::~CEditCustom() { } BEGIN_MESSAGE_MAP(CEditCustom, CEdit) ON_WM_NCCALCSIZE() END_MESSAGE_MAP() // CEditCustom message handlers void CEditCustom::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp) { // TODO: Add your message handler code here and/or call default this->UpdateMargins(lpncsp->rgrc[0]); lpncsp->rgrc[0].top+=m_TopMargin; lpncsp->rgrc[0].bottom-=m_BottomMargin; } void CEditCustom::UpdateMargins(CRect rect) { CClientDC dc(this); CFont *pOldFont=dc.SelectObject(GetFont()); LONG TextHeight=dc.GetTextExtent(_T(" "),1).cy; dc.SelectObject(pOldFont); LONG delta=rect.Height()-TextHeight; m_TopMargin=delta/2; m_BottomMargin=delta-m_TopMargin; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 // CEditCustom class CEditCustom : public CEdit { DECLARE_DYNAMIC(CEditCustom) public: CEditCustom(); virtual ~CEditCustom(); void UpdateMargins(CRect rect); protected: DECLARE_MESSAGE_MAP() afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp); LONG m_TopMargin; LONG m_BottomMargin; };
Partager