BOOL FirstPage::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// The following code will enumerate all the files in the
// current directory, printing the name of each file:
m_nFileIndex.InsertColumn(0,"¿Î³ÌºÅ");
m_nFileIndex.InsertColumn(1,"¿Î³ÌÀà±ð");
m_nFileIndex.InsertColumn(2,"¿Î³ÌÖÐÎÄÃû³Æ");
m_nFileIndex.InsertColumn(3,"¿Î³ÌÓ¢ÎÄÃû³Æ");
m_nFileIndex.InsertColumn(4,"¿Î³ÌÃèÊö");
m_nFileIndex.InsertColumn(5,"¿Î³Ìѧʱ");
m_nFileIndex.InsertColumn(6,"½Ì²Ä");
m_nFileIndex.InsertColumn(7,"µÈЧ¿Î³Ì");
m_nFileIndex.InsertColumn(8,"Ô¤Ð޿γÌ");
m_nFileIndex.InsertColumn(9,"³õѵ/¸´Ñµ±êÖ¾");
m_nFileIndex.InsertColumn(10,"¿ª¿Î²¿ÃÅ");
}
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// The following code will enumerate all the files in the
// current directory, printing the name of each file:
m_nFileIndex.InsertColumn(0,"¿Î³ÌºÅ");
m_nFileIndex.InsertColumn(1,"¿Î³ÌÀà±ð");
m_nFileIndex.InsertColumn(2,"¿Î³ÌÖÐÎÄÃû³Æ");
m_nFileIndex.InsertColumn(3,"¿Î³ÌÓ¢ÎÄÃû³Æ");
m_nFileIndex.InsertColumn(4,"¿Î³ÌÃèÊö");
m_nFileIndex.InsertColumn(5,"¿Î³Ìѧʱ");
m_nFileIndex.InsertColumn(6,"½Ì²Ä");
m_nFileIndex.InsertColumn(7,"µÈЧ¿Î³Ì");
m_nFileIndex.InsertColumn(8,"Ô¤Ð޿γÌ");
m_nFileIndex.InsertColumn(9,"³õѵ/¸´Ñµ±êÖ¾");
m_nFileIndex.InsertColumn(10,"¿ª¿Î²¿ÃÅ");
}
解决方案 »
- 一个static的问题
- 图片一闪一闪的。。。。。
- 关于位图,不用MFC,用API,怎么把**.bmp文件与位图句柄联系起来啊?
- 有关多线程何时开始执行……
- !!!! 急死我了!!! 如何在弹出来的modeless对话框上显示父窗口的按钮!!!!!
- XtremeToolkit1922 怎样编译中文?
- 请问高手
- 请问如何获取Dialog中某个控件的坐标?请指教,谢谢!!
- 怎样在关闭时询问是否退出?是哪个消息呢?
- AAAAAAAAAAAAAAAAA大家去http://www.csdn.net/expert/topic/133/133967.shtm拿分~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~绝不食言
- CListCtrl能设置行高吗?
- 怎么调整CListCtrl控件的行高度?
m_lstCtrl.InsertColumn(1,_T("地址"),LVCFMT_LEFT,80);
m_lstCtrl.InsertColumn(2,_T("颜色类型"),LVCFMT_LEFT,80);
m_lstCtrl.InsertColumn(3,_T("扫描类型"),LVCFMT_LEFT,80);
m_lstCtrl.InsertColumn(4,_T("宽度"),LVCFMT_LEFT,80);
m_lstCtrl.InsertColumn(5,_T("高度"),LVCFMT_LEFT,80);从你的代码中不太能确定是什么问题。是不是没有设置列宽度。你只是看不到列。而实际上是插入了的。
BOOL FirstPage::OnInitDialog() {
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// The following code will enumerate all the files in the
// current directory, printing the name of each file:
m_nFileIndex.InsertColumn(0,"j");
m_nFileIndex.InsertColumn(1,"a");
m_nFileIndex.InsertColumn(2,"b");
m_nFileIndex.InsertColumn(3,"c");
m_nFileIndex.InsertColumn(4,"d");
m_nFileIndex.InsertColumn(5,"e");
m_nFileIndex.InsertColumn(6,"f");
m_nFileIndex.InsertColumn(7,"g");
m_nFileIndex.InsertColumn(8,"h");
m_nFileIndex.InsertColumn(9,"i");
m_nFileIndex.InsertColumn(10,"h");
RECT rect;
m_nFileIndex.GetWindowRect(&rect);
int wid = rect.right - rect.left;
m_nFileIndex.SetColumnWidth(0, wid/11);
m_nFileIndex.SetColumnWidth(1, wid/11);
m_nFileIndex.SetColumnWidth(2, wid/11);
m_nFileIndex.SetColumnWidth(3, wid/11);
m_nFileIndex.SetColumnWidth(4, wid/11);
m_nFileIndex.SetColumnWidth(5, wid/11);
m_nFileIndex.SetColumnWidth(6, wid/11);
m_nFileIndex.SetColumnWidth(7, wid/11);
m_nFileIndex.SetColumnWidth(8, wid/11);
m_nFileIndex.SetColumnWidth(9, wid/11);
m_nFileIndex.SetColumnWidth(10, wid/11);
m_nFileIndex.SetExtendedStyle(LVS_EX_FULLROWSELECT); return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
看不明白阿
void CResorceData::RefreshData()
{
LV_ITEM ListItem;
int iRow;
int m_iFields;
CString tempstr;
COleVariant tempvar;
m_resorcelistctrl.DeleteAllItems();
CDaoRecordset rs(&theBase);
CString strSQL;
rs.Open(dbOpenDynaset,"select * from SJK");
m_iFields = rs.GetFieldCount();
if(!rs.IsEOF())
{
try
{
iRow=0;
ListItem.mask=LVIF_TEXT;
rs.MoveFirst();
while(!rs.IsEOF())
{
ListItem.iItem=iRow++;
for(int i=0;i < 5;i++)
{
rs.GetFieldValue(StrColumnNames[i],tempvar);
CCrack::VARIANTstr(tempvar,tempstr);
ListItem.iSubItem=i;
ListItem.pszText=tempstr.GetBuffer(100);
m_resorcelistctrl.InsertItem(&ListItem);
m_resorcelistctrl.SetItemText(ListItem.iItem,ListItem.iSubItem,ListItem.pszText);
}
rs.MoveNext();
}
}
catch(CDaoException *e)
{
CSurveyApp::DisplayDaoException(e);
e->Delete();
}
}
rs.Close();
}
这个CCrack是专门负责数据转换的封装类
#if !defined(AFX_CRACK_H__894E3242_D5D9_4A79_ACFE_611204416816__INCLUDED_)
#define AFX_CRACK_H__894E3242_D5D9_4A79_ACFE_611204416816__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//完成 COleVariant 类型到各个常见类型的转换
//不必深究
.h
class CCrack
{
public:
static void strVARIANT(const CString &strValue,int iType,COleVariant& Var);
static COleDateTime strDateTime(const CString &strDateTime);
static COleDateTime strDate(const CString &strDate);
static COleDateTime strTime(const CString &strTime);
static CString strBOOL(bool flag);
static void VARIANTstr(const COleVariant& var,CString &cs,int idatetime=0);
};#endif // !defined(AFX_CRACK_H__894E3242_D5D9_4A79_ACFE_611204416816__INCLUDED_)
.cpp
// Crack.cpp: implementation of the CCrack class.
//
//////////////////////////////////////////////////////////////////////#include "stdafx.h"
#include "Survey.h"
#include "Crack.h"#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
void CCrack::VARIANTstr(const COleVariant &var,CString &cs,int idatetime)
{
static int i=0;
if((i++)==6)
i=0;
switch(var.vt)
{
case VT_EMPTY:
case VT_NULL:cs=_T("");break;
case VT_I2:cs.Format(_T("%hd"),V_I2(&var));break;
case VT_I4:cs.Format(_T("%d"),V_I4(&var));break;
case VT_R4:cs.Format(_T("%e"),(double)V_R4(&var));break;
case VT_R8:cs.Format(_T("%e"),(double)V_R8(&var));break;
case VT_CY:cs=COleCurrency(var).Format();break;
case VT_DATE:
switch(idatetime) {
case 0:
cs=COleDateTime(var).Format(_T("%H:%M:%S"));
case 1:
cs=COleDateTime(var).Format(_T("%Y-%m-%d"));
case 2:
cs=COleDateTime(var).Format(_T("%Y-%m-%d %H:%M:%S"));
}
break;
case VT_BSTR:cs=V_BSTRT(&var);break;
case VT_BOOL:cs=strBOOL(V_BOOL(&var));break;
}}CString CCrack::strBOOL(bool flag)
{
CString strRet=(flag?"是":"否");
return strRet;
}
//strTime格式:HH:MM:SS
COleDateTime CCrack::strTime(const CString &strTime)
{
static COleDateTime retTime;
static int iHour;
static int iMinuter;
static int iSecond;
//retTime=COleDateTime::GetCurrentTime();//初始化Date=当前日期(因为在CClock中进行时间比较时,要比较日期
sscanf(strTime.Left(2),"%d",&iHour);//得到时
sscanf(strTime.Mid(3,2),"%d",&iMinuter);//分
sscanf(strTime.Mid(6,2),"%d",&iSecond);//秒
retTime.SetTime(iHour,iMinuter,iSecond);
return retTime;
}
//strDate格式 YYYY/MM/DD
COleDateTime CCrack::strDate(const CString &strDate)
{
static COleDateTime retTime;
static int iYear;
static int iMonth;
static int iDay;
sscanf(strDate.Left(4),"%d",&iYear);
sscanf(strDate.Mid(5,2),"%d",&iMonth);
sscanf(strDate.Mid(8,2),"%d",&iDay);
retTime.SetDate(iYear,iMonth,iDay);
return retTime;
}
//strDateTime格式 YYYY/MM/DD HH:MM:SS
COleDateTime CCrack::strDateTime(const CString &strDateTime)
{
static COleDateTime retTime;
static int iYear;
static int iMonth;
static int iDay;
static int iHour;
static int iMinuter;
static int iSecond;
sscanf(strDateTime.Left(4),"%d",&iYear);
sscanf(strDateTime.Mid(5,2),"%d",&iMonth);
sscanf(strDateTime.Mid(8,2),"%d",&iDay);
sscanf(strDateTime.Mid(11,2),"%d",&iHour);//得到时
sscanf(strDateTime.Mid(14,2),"%d",&iMinuter);//分
sscanf(strDateTime.Mid(17,2),"%d",&iSecond);//秒
retTime.SetDateTime(iYear,iMonth,iDay,iHour,iMinuter,iSecond);
return retTime;
}
//包含strDate|strTime
void CCrack::strVARIANT(const CString &strValue,int iType,COleVariant &var)
{
static bool bl;
static BYTE ba;
static short st;
static long ln;
static float ft;
static COleDateTime dt;
static double db; switch(iType)
{
case (dbBoolean):
{
if(strValue=="是")
bl=true;
else
bl=false;
var.Clear();
var.ChangeType(VT_BOOL);
var.boolVal=bl;
}
break;
case (dbByte):////////////问题
{
ba=(BYTE)strValue.GetAt(0);
var=COleVariant(ba);
}
break;
case(dbInteger):
{
st=(short)atoi((LPCTSTR)strValue);
var=COleVariant(st,VT_I2);
}
break;
case(dbLong):
{
long ln=(long)atol((LPCTSTR)strValue);
var=COleVariant(ln);
}
break;
case(dbSingle):
{
float ft=float(atof((LPCTSTR)strValue));
var=COleVariant(ft);
}
break;
case(dbDouble):
{
double db=(double)atof((LPCTSTR)strValue);
var=COleVariant(db);
}
break;
case(dbDate):
{
dt=strDate(strValue);
var=COleVariant((DATE)dt);
}
break;
case(dbText):
case(dbMemo):
{
var=COleVariant(strValue,VT_BSTRT);//不能用VT_BSTR!!!!!!!
}
break;
case( dbTime ):
{
dt=strTime(strValue);
var=COleVariant((DATE)dt);
}
break;
}
}
急需,要一行代码应个急啊
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// The following code will enumerate all the files in the
// current directory, printing the name of each file:
m_nFileIndex.InsertColumn(0,"j");
m_nFileIndex.InsertColumn(1,"a");
m_nFileIndex.InsertColumn(2,"b");
m_nFileIndex.InsertColumn(3,"c");
m_nFileIndex.InsertColumn(4,"d");
m_nFileIndex.InsertColumn(5,"e");
m_nFileIndex.InsertColumn(6,"f");
m_nFileIndex.InsertColumn(7,"g");
m_nFileIndex.InsertColumn(8,"h");
m_nFileIndex.InsertColumn(9,"i");
m_nFileIndex.InsertColumn(10,"h");
RECT rect;
m_nFileIndex.GetWindowRect(&rect);
int wid = rect.right - rect.left;
m_nFileIndex.SetColumnWidth(0, wid/11);
m_nFileIndex.SetColumnWidth(1, wid/11);
m_nFileIndex.SetColumnWidth(2, wid/11);
m_nFileIndex.SetColumnWidth(3, wid/11);
m_nFileIndex.SetColumnWidth(4, wid/11);
m_nFileIndex.SetColumnWidth(5, wid/11);
m_nFileIndex.SetColumnWidth(6, wid/11);
m_nFileIndex.SetColumnWidth(7, wid/11);
m_nFileIndex.SetColumnWidth(8, wid/11);
m_nFileIndex.SetColumnWidth(9, wid/11);
m_nFileIndex.SetColumnWidth(10, wid/11);
m_nFileIndex.SetExtendedStyle(LVS_EX_FULLROWSELECT); return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}这个代码没问题,我测试过了
是不是你没有把listctrl的风格设为report
现在重装完了,马上就显示了