Bonjour,
j'ai voulu créer des champs textes et des boutons dans un dockablepane.
Pour cette raison j'ai créé une classe qui hérite de cdockablePane.
Le probléme est que ce dockablePane n'a pas de background.
C'est à dire j'aurai dans les espaces dont lesquelles j'ai rien affichés dans le dockablepane, le backround de mon bureau.
voilà une image qui décrit mon dockablepane

voilà le fichier .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
 
#pragma once
 
class CdpCordinates : public CDockablePane 
{
public:
	//constrcuteur par défaut
	CdpCordinates();
	//destructeur
	~CdpCordinates();
	//méthodes
	void AdjustLayout();
private:
	CEdit m_X;
	CEdit m_Y;
	CEdit m_Z;
	CStatic m_stX;
	CStatic m_stY;
	CStatic m_stZ;
	CButton m_Update;
	CFont m_fntList;
	CMFCButton m_button;
 
protected:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
	void SetListFont();
	DECLARE_MESSAGE_MAP()
};

voilà le fiichier .cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "stdafx.h"
#include "dp_Coordinates.h"
 
 
CdpCordinates::CdpCordinates()
{
}
CdpCordinates::~CdpCordinates()
{
}
BEGIN_MESSAGE_MAP(CdpCordinates, CDockablePane)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_SETTINGCHANGE()
END_MESSAGE_MAP()
 
 
void CdpCordinates::AdjustLayout()
{
	if (GetSafeHwnd() == NULL)
	{
		return;
	}
	CRect rectClient,rectX,rectY,rectZ,rectStX,rectStY,rectStZ;
	GetClientRect(rectClient);
 
	m_X.GetWindowRect(&rectX);
	m_Y.GetWindowRect(&rectY);
	m_Z.GetWindowRect(&rectZ);
	m_stX.GetWindowRect(&rectStX);
	m_stY.GetWindowRect(&rectStY);
	m_stZ.GetWindowRect(&rectStZ);
 
	int cyX = rectX.Size().cy;
	int cyY = rectY.Size().cy;
	int cyZ = rectZ.Size().cy;
	int cxX= rectStX.Size().cx;
	m_stX.SetWindowPos(NULL,rectClient.left+5,rectClient.top+5,20,30,SWP_NOACTIVATE | SWP_NOZORDER);
	m_stY.SetWindowPos(NULL,rectClient.left+5,rectClient.top+cyX+5,rectClient.Width(),30,SWP_NOACTIVATE | SWP_NOZORDER);
	m_X.SetWindowPos(NULL,30,rectClient.top+5,50,30,SWP_NOACTIVATE | SWP_NOZORDER);
}
 
int CdpCordinates::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDockablePane::OnCreate(lpCreateStruct) == -1)
		return -1;
 
	CRect rectDummy;
	rectDummy.SetRectEmpty();
	const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
	m_X.Create(dwViewStyle,rectDummy,this,1);
	m_Y.Create(dwViewStyle,rectDummy,this,1);
	m_Z.Create(dwViewStyle,rectDummy,this,1);
	m_stX.Create("X =",dwViewStyle,rectDummy,this,1);
	m_stY.Create("Y =",dwViewStyle,rectDummy,this,1);
	m_stZ.Create("Z =",dwViewStyle,rectDummy,this,1);
	//SetBkColor(geth,RGB(255,0,0));
	return 1;
}
void CdpCordinates::OnSize(UINT nType, int cx, int cy)
{
	CDockablePane::OnSize(nType, cx, cy);
	AdjustLayout();
}
void CdpCordinates::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
{
	CDockablePane::OnSettingChange(uFlags, lpszSection);
	SetListFont();
}
 
void CdpCordinates::SetListFont()
{
::DeleteObject(m_fntList.Detach());
 
	LOGFONT lf;
	afxGlobalData.fontRegular.GetLogFont(&lf);
 
	NONCLIENTMETRICS info;
	info.cbSize = sizeof(info);
 
	afxGlobalData.GetNonClientMetrics(info);
 
	lf.lfHeight = info.lfMenuFont.lfHeight;
	lf.lfWeight = info.lfMenuFont.lfWeight;
	lf.lfItalic = info.lfMenuFont.lfItalic;
 
	m_fntList.CreateFontIndirect(&lf);
 
	m_X.SetFont(&m_fntList);
	m_Y.SetFont(&m_fntList);
	m_Z.SetFont(&m_fntList);
	m_stX.SetFont(&m_fntList);
	m_stY.SetFont(&m_fntList);
	m_stZ.SetFont(&m_fntList);
}
Merci pour vos aides