动态批改Static控件边框颜色.

动态修改Static控件边框颜色...
//OCX上绘4个Static控件,单击控件,修改边框颜色,好像就第一次管用,
//后面再单击都不起作用了。


//4个Static控件映射单击函数
ON_STN_DBLCLK(IDC_TestStatic_1, OnDoubleclickedButton1)
ON_STN_DBLCLK(IDC_TestStatic_2, OnDoubleclickedButton2)
ON_STN_DBLCLK(IDC_TestStatic_3, OnDoubleclickedButton3)
ON_STN_DBLCLK(IDC_TestStatic_4, OnDoubleclickedButton4)

//创建Static控件
CTestOCXCtrl::CTestOCXCtrl()
{
InitializeIIDs(&IID_DTestOCX, &IID_DTestOCXEvents);

// TODO: Initialize your control's instance data here.
CRect rcSize;
GetClientRect(rcSize); 
m_static_1.DestroyWindow();
m_static_2.DestroyWindow();
m_static_3.DestroyWindow();
m_static_4.DestroyWindow();

//1
CRect rcStatic_1(rcSize.left, //x
rcSize.top, 
rcSize.left+(rcSize.Width()/2),  //x
rcSize.top + (rcSize.Height() / 2));

//3
CRect rcStatic_3(rcSize.left, //x
rcSize.top + (rcSize.Height() / 2), 
rcSize.left+(rcSize.Width()/2), //x
rcSize.top + (rcSize.Height()));

//2
CRect rcStatic_2(rcSize.left+rcSize.Width()/2, //x
rcSize.top , 
rcSize.left+ rcSize.Width(), //x
rcSize.top + rcSize.Height()/2);

//4
CRect rcStatic_4(rcSize.left+rcSize.Width()/2, //x
rcSize.top + rcSize.Height()/2, 
rcSize.left+rcSize.Width(), //x
rcSize.top + rcSize.Height());

m_static_1.Create("Video-1", WS_CHILD|WS_VISIBLE|SS_NOTIFY, rcStatic_1, this, IDC_TestStatic_1); 
m_static_2.Create("Video-2", WS_CHILD|WS_VISIBLE|SS_NOTIFY, rcStatic_2, this, IDC_TestStatic_2); 
m_static_3.Create("Video-3", WS_CHILD|WS_VISIBLE|SS_NOTIFY, rcStatic_3, this, IDC_TestStatic_3); 
m_static_4.Create("Video-4", WS_CHILD|WS_VISIBLE|SS_NOTIFY, rcStatic_4, this, IDC_TestStatic_4);
}

//单击Static_1
void CTestOCXCtrl::OnStatic1()
{
// AfxMessageBox("单击Static-1");
CStatic* pStatic = NULL;
LONG style = 0;

pStatic = (CStatic*)GetDlgItem(IDC_TestStatic_1);
//style = GetWindowLong(pStatic->GetSafeHwnd(), GWL_STYLE);
style |= WS_CHILD;  
style |= WS_VISIBLE;  
style |= SS_NOTIFY;
style |= SS_BLACKFRAME; //1  
SetWindowLong(pStatic->GetSafeHwnd(),GWL_STYLE, style);

pStatic = (CStatic*)GetDlgItem(IDC_TestStatic_2);
//style = GetWindowLong(pStatic->GetSafeHwnd(), GWL_STYLE);
style |= WS_CHILD;  
style |= WS_VISIBLE;  
style |= SS_NOTIFY;
style |= SS_WHITEFRAME; //白色边框  
SetWindowLong(pStatic->GetSafeHwnd(),GWL_STYLE, style);

  pStatic = (CStatic*)GetDlgItem(IDC_TestStatic_3);
  //style = GetWindowLong(pStatic->GetSafeHwnd(), GWL_STYLE);
  style |= WS_CHILD;  
  style |= WS_VISIBLE;  
  style |= SS_NOTIFY;
  style |= SS_WHITEFRAME; //白色边框  
  SetWindowLong(pStatic->GetSafeHwnd(),GWL_STYLE, style);
  
  pStatic = (CStatic*)GetDlgItem(IDC_TestStatic_4);
  //style = GetWindowLong(pStatic->GetSafeHwnd(), GWL_STYLE);
  style |= WS_CHILD;