最近在做一個配置管理軟件碰到的一些小問題

突然發現每天晚上把當天遇到的問題記錄下來是一個很好的習慣。

◆PropertySheet中去掉下方默認的按鈕的方式,以及重新繪製按鈕添加響應函數的代碼:

GetDlgItem(IDOK)->ShowWindow(SW_HIDE); 
    GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE); 
    GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE); 
	GetDlgItem(IDHELP)->ShowWindow(SW_HIDE);
	//SetDlgItemText(IDHELP,"退出");
    /* CRect btnRect;
 	GetDlgItem(IDCANCEL)->GetWindowRect(&btnRect); 
 	//獲取窗體尺寸
 	CRect wdnRect; 
	GetWindowRect(&wdnRect);
 	//調整窗體大小 
 	::SetWindowPos(this->m_hWnd, HWND_TOP, 0,0,wdnRect.Width(),wdnRect.Height() - btnRect.Height(), SWP_NOMOVE | SWP_NOZORDER); 
	*/
    CButton *m_applyBtn = new CButton();
	CRect rect, tabrect;
	int width;
	//Get button sizes and positions
	GetDlgItem(IDOK)->GetWindowRect(rect);
	GetTabControl()->GetWindowRect(tabrect);
	ScreenToClient(rect); 
	ScreenToClient(tabrect);
	//New button -> width, height and Y-coordiate of IDOK
	// -> X-coordinate of tab control
	width = rect.Width();
	rect.left = tabrect.left+200; rect.right = tabrect.left + width+280;
	//Create new "Add" button and set standard font
	m_applyBtn->Create("應用",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_TABSTOP, rect, this, IDC_BUTTON_APPLY);
	m_applyBtn->SetFont(GetFont());
◆將控件多個控件編組方便組操作的代碼:

CIPAddressCtrl m_IP[10];
void CServerIP::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CServerIP)
	//}}AFX_DATA_MAP
	DDX_Control(pDX, IDC_IP1, m_IP[0]);
	DDX_Control(pDX, IDC_IP9, m_IP[8]);
	DDX_Control(pDX, IDC_IP8, m_IP[7]);
	DDX_Control(pDX, IDC_IP7, m_IP[6]);
	DDX_Control(pDX, IDC_IP6, m_IP[5]);
	DDX_Control(pDX, IDC_IP5, m_IP[4]);
	DDX_Control(pDX, IDC_IP4, m_IP[3]);
	DDX_Control(pDX, IDC_IP3, m_IP[2]);
	DDX_Control(pDX, IDC_IP2, m_IP[1]);
	DDX_Control(pDX, IDC_IP10, m_IP[9]);
}
想要操作控件時輪詢數組即可。

CIPAddressCtrl類的使用(IP地址與CString的互相轉化):

//將CString   型IP地址在IPAddressCtrl中顯示  
CString   strIP="192.168.0.10";  
DWORD   dwIP;  
dwIP   =   inet_addr(strIP);  
unsigned   char   *pIP   =   (unsigned   char*)&dwIP;  
m_ipAddr.SetAddress(*pIP,   *(pIP+1),   *(pIP+2),   *(pIP+3));  

//將IPAddressCtrl中的IP地址獲得並轉換成CString型  
unsigned   char   *pIP;  
CString   strIP;  
DWORD   dwIP;  
m_ipAddr.GetAddress(dwIP);  
pIP   =   (unsigned   char*)&dwIP;  
strIP.Format("%u.%u.%u.%u",*(pIP+3),   *(pIP+2),   *(pIP+1),   *pIP);
 
BYTE nf1,nf2,nf3,nf4;
 pIP->GetAddress(nf1,nf2,nf3,nf4);
 CString str;
 str.Format("%d.%d.%d.%d",nf1,nf2,nf3,nf4);//這裏的nf得到的值是IP值了.
 MessageBox(str);
◆CComboBox的注意:

在使用CComboBox時必須進行初始化,如果不進行初始化,系統會報錯。

在使用CComboBox的頁面,必須先激活否則還是會報錯。

SetActivePage,激活屬性頁。

◆CStdioFile類進行讀寫文件:

        CStdioFile myFile;
	if (myFile.Open(CLIENTPATH, CFile::modeCreate|CFile::modeWrite) == FALSE)
	{
		return;
	}
	sprintf(buf,"%s\r\n","20");
	myFile.WriteString(buf);
讀文件是ReadString

◆通過索引名查詢索引所在表:

select user_ind_columns.column_position from user_ind_columns where user_ind_columns.index_name = "索引名";









發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章