#import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE11\\MSO.DLL" rename( "RGB", "MSORGB" )
using namespace Office;
#pragma warning(disable : 4192)
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB"
#import "D:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE" \
rename( "DialogBox", "ExcelDialogBox" ) \
rename( "RGB", "ExcelRGB" ) \
rename( "CopyFile", "ExcelCopyFile" ) \
rename( "ReplaceText", "ExcelReplaceText" )
void CRecordView::OnFileExport()
{
TCHAR szFilter[] = { _T("Excel文件 (*.xls)|*.xls|所有文件 (*.*)|*.*||") };
CFileDialog SaveDialog(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);
if (SaveDialog.DoModal() == IDOK)
{
_variant_t varOption((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
CWaitCursor wait;
try
{
Excel::_ApplicationPtr pExcelApp(_T("Excel.Application"));
Excel::_WorkbookPtr pBook = pExcelApp->Workbooks->Add(varOption);
Excel::_WorksheetPtr pSheet = pBook->ActiveSheet;
//Excel::RangePtr pRange = pSheet->GetRange(_T("A1"), _T("D1"));
Excel::RangePtr pRange = pSheet->Cells;
CHeaderCtrl* pHeader = m_wndList.GetHeaderCtrl();
int nColumn = pHeader->GetItemCount();
{
TCHAR szText[40] = { 0 };
HDITEM hdi = { 0 };
hdi.mask = HDI_TEXT;
hdi.pszText = szText;
hdi.cchTextMax = 40;
for (int i = 1; i < nColumn; i++)
{
pHeader->GetItem(i, &hdi);
pRange->Item[1][i] = hdi.pszText;
}
Excel::RangePtr pHeaderRange = pRange->GetRange(variant_t(_T("A1")), variant_t(_T("F1")));
pHeaderRange->Font->Bold = true;
}
for (int i = 0; i < m_wndList.GetItemCount(); i++)
{
for (int j = 1; j < nColumn; j++)
{
pRange->Item[i+2][j] = (LPCTSTR)m_wndList.GetItemText(i, j);
}
}
pRange = pRange->EntireColumn;
pRange->AutoFit();
pBook->Close(true, (LPCTSTR)SaveDialog.GetPathName(), varOption);
pExcelApp->Quit();
AfxMessageBox(_T("数据已成功导出到Excel表格中!"), MB_OK | MB_ICONINFORMATION);
}
catch (...)
{
AfxMessageBox(_T("导出数据错误!"), MB_OK | MB_ICONERROR);
return;
}
}
}
posted @
2007-09-10 12:25 披星戴月 阅读(1057) |
评论 (0) |
编辑 收藏
BOOL CRoiDialog::ContinueModal()
{
if(m_wndToolBar.IsWindowVisible())
{
CWnd* pWndParent = m_wndToolBar.GetParent();
m_wndToolBar.OnUpdateCmdUI((CFrameWnd*)this, TRUE);
}
return CDialog::ContinueModal();
}
posted @
2007-09-10 12:22 披星戴月 阅读(534) |
评论 (0) |
编辑 收藏
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CFrameWndBase::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
return TRUE;
}
BOOL CMainView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~WS_BORDER;
return CFormView::PreCreateWindow(cs);
}
posted @
2007-09-10 12:21 披星戴月 阅读(167) |
评论 (0) |
编辑 收藏
class CRecycleFile : private SHFILEOPSTRUCT
{
public:
CRecycleFile()
{
memset((SHFILEOPSTRUCT*)this,0,sizeof(SHFILEOPSTRUCT));
fFlags |= FOF_SILENT; // don't report progress
fFlags |= FOF_NOERRORUI; // don't report errors
fFlags |= FOF_NOCONFIRMATION; // don't confirm delete
}
~CRecycleFile()
{
}
//
// Send a file to the recycle bin. Args:
// - full pathname of file.
// - bDelete: if TRUE, really delete file (no recycle bin)
//
int Recycle(LPCTSTR pszPath, BOOL bDelete=FALSE)
{
TCHAR buf[_MAX_PATH + 1]; // allow one more character
_tcscpy(buf, pszPath); // copy caller's path name
buf[_tcslen(buf)+1]=0; // need two NULLs at end
// Set SHFILEOPSTRUCT params for delete operation
wFunc = FO_DELETE; // REQUIRED: delete operation
pFrom = buf; // REQUIRED: which file(s)
pTo = NULL; // MUST be NULL
if(bDelete)
{ // if delete requested..
fFlags &= ~FOF_ALLOWUNDO; // ..don't use Recycle Bin
}
else
{ // otherwise..
fFlags |= FOF_ALLOWUNDO; // ..send to Recycle Bin
}
return SHFileOperation(this); // do it!
}
}
posted @
2007-09-10 12:20 披星戴月 阅读(713) |
评论 (0) |
编辑 收藏
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE11\\MSO.DLL" named_guids
using namespace Office;
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB"
#import "D:\\Program Files\\Microsoft Office\\OFFICE11\\MSWORD.OLB" named_guids rename("ExitWindows","WordExitWindows")
posted @
2007-09-10 12:15 披星戴月 阅读(662) |
评论 (0) |
编辑 收藏
摘要: .Net Reflector——.NET反编译工具软件
.Net Reflector is the class browser, explorer, analyzer and documentation viewer for .NET. Reflector allows to easily view, navigate, search, decompile and analyze .NET assemblies in C#, Visual Basic and IL.
Lutz Roeder's Net Reflector URL: http://www.aisto.com/roeder/dotnet/
阅读全文
posted @
2007-09-10 12:14 披星戴月 阅读(1427) |
评论 (0) |
编辑 收藏
象如下定义就得到一个数组的引用
类型名 (&变量明)[N];
实例
int int_array[10];
int (&int_ref)[10] = int_array;
这样就得到了一个数组的应用
在函数的声明中用数组的引用定义,就不怕数组退化了。如下
for_each( int (&int_ref)[10] )
{
for( int i=0; i<10; ++i )
std::cout << int_ref[i] << std::endl;
}
int main( int argc, char* argv[] )
{
int int_array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
for_each( int_array );
return 0;
}
在上面的代码中,如果你传入不是10个尺寸的数组,是编译通不过的。代码的安全性提高了。
想要定义一个数组引用类型,方法如下
typedef 类型明 (&数组引用类型明)[N];
实例
typedef int (&Array_Ref)[10];
Array_Ref就是一个数组的引用类型了。
posted @
2007-09-10 12:09 披星戴月 阅读(272) |
评论 (0) |
编辑 收藏
1. 捕获WM_NCHITTEST:
UINT CMyDialog::OnNcHitTest(CPoint point)
{
UINT nResult = CDialog::OnNcHitTest(point);
return nResult == HTCLIENT ? HTCAPTION : nResult;
}
2. 捕获WM_LBUTTONDOWN:
void CMyDialog::OnLButtonDown(CPoint point)
{
SendMessage(WM_SYSCOMMAND, 0xF012, 0);
CDialog::OnLButtonDown(point);
}
posted @
2007-09-10 12:06 披星戴月 阅读(318) |
评论 (0) |
编辑 收藏
摘要: TinyXml:
Homepage: http://www.grinninglizard.com/tinyxml/
Download:http://sourceforge.net/projects/tinyxml
阅读全文
posted @
2007-09-06 12:22 披星戴月 阅读(680) |
评论 (0) |
编辑 收藏
1. tmail:
-service: 调用类型,比如MMS,SMS,ActiveSync等
-attach: 添加附件
-subject: 添加subject
-to: 添加目标地址
举个例子:
const szCMD[] = _T(" -service \"MMS\" -to \"test@sina.com;13800571505\"");
CreateProcess(_T(\\Windows\\tmail.exe), szCMD, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL)
2. prun cprog.exe -url tel:121
posted @
2007-06-21 13:41 披星戴月 阅读(1281) |
评论 (3) |
编辑 收藏