在做管理系统的时候,我创建一个对话框,如上图:
资源属性如下:
DDX_Control(pDX, IDC_GIRD, m_Grid);//IDC_GIRD 为ID,m_Grid为成员变量,下同
DDX_Control(pDX, IDC_BUTQUERY, m_ButQuery);
DDX_CBString(pDX, IDC_COMEMBLEM, m_ComEmblem);
DDX_CBString(pDX, IDC_COMFIELD, m_ComField);
DDX_Text(pDX, IDC_EDTCONDITION, m_EdtCondition);
奇怪的是在添加 的那个查询的函数的时候,
void CDWare::OnButquery()
{
CString sField,sEmblem,sCondition,sSQL;
m_Grid.DeleAllCol();
m_ComField.GetWindowText(sField);//获取Combox,Edit里面的内容。
m_ComEmblem.GetWindowText(sEmblem);
m_EdtCondition.GetWindowText(sCondition);
//.........................
}
会出现错误提示:DeleAllCol' : is not a member of 'CListCtrl';
GetWindowTextA' : is not a member of 'CString'
以前也写过这样的,输入 m_ComField加"."后会有GetWindowText()的提示,但这次没有,出现过几次这样的情况了
还有一些关键代码帖一下;
/////////////////////////////////////////////
CToolBarCtrl m_ToolBar;
CImageList m_ImageList;
CStatusBarCtrl m_StatusBar;
UINT ID_TOOLBAR;
UINT IDS_STRING1;
UINT IDS_STATUSBAR;
///////////////////////////////////////////////
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
////////////////////////////////////////////////////////////////////////
//添加工具栏和菜单栏:
TBBUTTON button[11];
/*
typedef struct _TBBUTTON {
int iBitmap;
int idCommand;
BYTE fsState;
BYTE fsStyle;
DWORD dwData;
int iString;
} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON;
typedef const TBBUTTON FAR* LPCTBBUTTON;
*/
int i=0,nStringLength;
CString string;
TCHAR *pString;
m_ImageList.Create(32,32,ILC_COLOR|ILC_MASK,0,0);//Initializes an image list and attaches it to a CImageList object.
/*
BOOL Create(
int cx,
int cy,
UINT nFlags,
int nInitial,
int nGrow
);
*/
m_ToolBar.EnableAutomation();
m_ToolBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,ID_TOOLBAR);
//向ImageList对象中添加图标
UINT Resouce[11]={IDI_ICON1,IDI_ICON2,IDI_ICON3,IDI_ICON4,IDI_ICON5,\
IDI_ICON6,IDI_ICON7,IDI_ICON8,IDI_ICON9};
for(i=0;i<11;i++)
{
m_ImageList.Add(::LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(Resouce[i])));
}
m_ToolBar.SetImageList(&m_ImageList);
for(i=0;i<=9;i++)
{
button[i].dwData=0;//what means?
button[i].fsState=TBSTATE_ENABLED;//The button accepts user input. A button without this state does not accept user input, and is dimmed.
if(i==4||i==8)
{
button[i].fsState=TBSTYLE_SEP;
}
else
button[i].fsState=TBSTYLE_BUTTON;
button[i].iBitmap=i;//Zero-based index of the button image.
string.LoadString(i+IDS_STRING1);
//为每一个字符串加一个"\0"用于向工具栏加字符串
nStringLength=string.GetLength()+1;
pString=string.GetBufferSetLength(nStringLength);
//返回刚加的字符串编号
button[i].iString=m_ToolBar.AddStrings(pString);
string.ReleaseBuffer();
}
button[1].idCommand=ID_MENUITEM32771;
button[2].idCommand=ID_MENUITEM32774;
button[3].idCommand=ID_MENUITEM32781;
button[4].idCommand=ID_MENUITEM32775;
button[5].idCommand=ID_MENUITEM32776;
button[6].idCommand=ID_MENUITEM32777;
button[7].idCommand=ID_MENUITEM32778;
button[8].idCommand=ID_MENUITEM32779;
m_ToolBar.AddButtons(11,button);
m_ToolBar.AutoSize();
m_ToolBar.SetStyle(TBSTYLE_FLAT|CCS_TOP);
//建立状态栏
m_StatusBar.EnableAutomation();
m_StatusBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDS_STATUSBAR);
int width[3];
width[1]=150;
width[2]=500;
width[3]=200;
m_StatusBar.SetParts(4,&width[1]);
m_StatusBar.SetText("Clean_Sky Stdio",0,0);
CString StatusText,UserName;
StatusText.Format("当前用户: %s",UserName);
m_StatusBar.SetText(StatusText,0,3);
/////////////////////////////////////////////////////////////////////////
return TRUE; // return TRUE unless you set the focus to a control
}