设为首页 加入收藏

TOP

对话方块(六十八)
2010-12-30 21:13:56 来源: 作者: 【 】 浏览:40853
Tags:对话 方块
STR) pConv, (PTSTR) pText) ;
#endif

}
else // the file is not Unicode
{
pText = pBuffer ;
// Allocate memory for possibly converted string.
pConv = malloc (2 * iFileLength + 2) ;
// If the edit control is Unicode, convert ASCII text.
#ifdef UNICODE
MultiByteToWideChar (CP_ACP, 0, pText, -1, (PTSTR) pConv,
iFileLength + 1) ;
// If not, just copy buffer
#else
lstrcpy ((PTSTR) pConv, (PTSTR) pText) ;
#endif
}

SetWindowText (hwndEdit, (PTSTR) pConv) ;
free (pBuffer) ;
free (pConv) ;

return TRUE ;
}

BOOL PopFileWrite (HWND hwndEdit, PTSTR pstrFileName)
{
DWORD dwBytesWritten ;
HANDLE hFile ;
int iLength ;
PTSTR pstrBuffer ;
WORD wByteOrderMark = 0xFEFF ;
// Open the file, creating it if necessary

if (INVALID_HANDLE_VALUE ==
(hFile = CreateFile (pstrFileName, GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, 0, NULL)))
return FALSE ;
// Get the number of characters in the edit control and allocate
// memory for them.

iLength = GetWindowTextLength (hwndEdit) ;
pstrBuffer = (PTSTR) malloc ((iLength + 1) * sizeof (TCHAR)) ;

if (!pstrBuffer)
{
CloseHandle (hFile) ;
return FALSE ;
}

// If the edit control will return Unicode
首页 上一页 65 66 67 68 69 70 71 下一页 尾页 68/82/82
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇剪贴簿 下一篇功能表及其他资源

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: