|
Thanks for your reply David... I would like to criticise your post if I was more skilled... But seems to me for now... Maybe not, in the future?? Just joking, thanks again...
|
|
|
|
|
By the way, you can just explain this :
CFileDialog *pOpenDlg=new CFileDialog(FALSE,".txt",NULL,OFN_OVERWRITEPROMPT,"Text Files (*.txt)|*.txt|All Files(*.*)|*.*||");
if you want some more charity from our heavenly father?? PLEASE!
|
|
|
|
|
Try and put this code in a button click and see what happens. then you will understand why is this code required.
Every new day is another chance to change your life.
|
|
|
|
|
hi,
how do i get a list of LANGID in array?
i want initialize an array with LANGIDs (for example i do this in a loop).
int count;
WORD* arr = new WORD[count];
please help me
Zo.Naderi-Iran
|
|
|
|
|
The current list should be in file WinNT.h; search for keyword LANG_NEUTRAL . See also second response.
modified 12-Oct-11 5:18am.
|
|
|
|
|
Further research suggests you should use one of the locale support functions such as EnumSystemLocalesEx()[^].
|
|
|
|
|
zon_cpp wrote: how do i get a list of LANGID in array?
Hi,
I believe Microsoft discourages using the MLANG interface. At least that's what it use to say on MSDN. However I looked just now and could not find the do-not-use disclaimer. With that being said... A few years ago I managed to figure out how to use some of the vaguely documented interfaces. Here is what I use to enumerate available locales:
HRESULT hr = CoInitialize(NULL);
if(SUCCEEDED(hr))
{
IMultiLanguage * pml;
hr = CoCreateInstance(CLSID_CMultiLanguage,NULL,CLSCTX_ALL,IID_IMultiLanguage,(void**)&pml);
if(SUCCEEDED(hr))
{
RFC1766INFO info;
ULONG num;
IEnumRfc1766 *rfc1766;
hr = pml->EnumRfc1766(&rfc1766);
if(SUCCEEDED(hr))
{
while(S_OK == rfc1766->Next(1,&info,&num))
{
WORD wLangID = LANGIDFROMLCID(info.lcid);
}
}
}
pml->Release();
}
CoUninitialize();
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
How to bold a specific listcontrol row?
|
|
|
|
|
in OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) event of CListCtrl
void CMyList::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVCUSTOMDRAW pLVCD reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);
switch(pLVCD->nmcd.dwDrawStage)
{
case CDDS_ITEMPREPAINT:
if(pLVCD->nmcd.dwItemSpec == 1)
{
pLVCD->clrTextBk = RGB(235,235,235);
}
break;
}
}
Zo.Naderi-Iran
|
|
|
|
|
It will chage the color of text, I need to make it BOLD
|
|
|
|
|
Hi,
Modify the code zon_cpp gave you and use something like this in the CDDS_ITEMPREPAINT case:
HFONT hOldFont = (HFONT)SelectObject(pLVCD>hdc, m_Font);
SelectObject(pLVCD>hdc, hOldFont);
In your header add:
CFont m_Font;
In your dialog constructor add something like:
m_Font.CreateFont(13,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,DEFAULT_PITCH | FF_DONTCARE,_T("MS Shell Dlg 2"));
Best Wishes,
-David Delaune
|
|
|
|
|
|
I'm trying to read text from a text file. I look for in msdn how to read and write in text file, and I found this:
http://msdn.microsoft.com/es-es/library/6337eske.aspx[^]
I made this funtion to read from my text file:
void CDlgResultados::loadFromFile(void)
{
CString path= GetUserHomeDir() + _T("\\Documents\\file.txt");
TCHAR szBuffer[256];
UINT nActual = 0;
CFile myFile;
if ( myFile.Open(path, CFile::modeCreate |
CFile::modeRead ) )
{
myFile.Write( szBuffer, sizeof( szBuffer ) );
myFile.Flush();
myFile.Seek( 0, CFile::begin );
nActual = myFile.Read( szBuffer, sizeof( szBuffer ) );
}
m_Edit.SetWindowTextW(szBuffer);
}
But when I run the app and I press the button to read the file, I get a error that it said:
You dont have acces to this file.
|
|
|
|
|
What is the actual value of the string in your path variable, at the time you try to create the file?
|
|
|
|
|
this is the value:
C:\Users\Antonio\Documents\file.txt
|
|
|
|
|
OK, and does that directory exist and can you create that file manually? If so then check also the suggestions from other commenters below.
|
|
|
|
|
Yes, this directory exist and I made the file manually.
|
|
|
|
|
Use the class CStdioFile to read text file.
google for example, there are many.
Watched code never compiles.
|
|
|
|
|
Rule number 0 when working with files. Always check return codes, so you know which call is failing.
Best guess is that when you call to Write() to the file, you do not have permissions, since your Open() call doesn't specify that permission. Maybe the create Permission implies this, but I'm not sure.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
antonio343 wrote: , I get a error that it said: You dont have acces to this file.
Open the file using
CFile::modeReadWrite OR CFile::modeWrite it seems you don't have permission to write.
|
|
|
|
|
I changed the mode by modeReadWrite and I get simbols like this:
<pre>쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌Y쳌쳌쳌쳌꣨ɷ쳌쳌偁泇¬</pre>
I also try this:
void CDlgResultados::loadFromFile(void)
{
CString path= GetUserHomeDir() + _T("\\Documents\\file.txt");
CStdioFile f1;
f1.Open(path, CFile::modeCreate | CFile::modeRead || CFile::typeText);
CStdioFile f(stdin);
TCHAR buf[100];
f1.ReadString(buf, 99);
m_Edit.SetWindowTextW(buf);
}
But I get simbols.
I think that the problem is the function ReadString doesnt get the text from the file, becouse the simbol that I get are the "rubbish" which is inicializated buf
modified 11-Oct-11 14:37pm.
|
|
|
|
|
In your original code you were writing from an uninitialised buffer, hence the garbage recorded in your file. Check the logic of your code thus:
- Create the file with access for writing
- Write some text either from a constant string, or from some data built by the program
- Close the file
- Open the file with access for reading
- Read the text into a buffer
- Close the file
In each case check the results of your function calls to ensure that your code has completed without error. You can also create your file manually using Notepad or similar text editor.
|
|
|
|
|
Yes, I know, I try to do that, and the file is created manually.
But I dont know how to read or write in mfc.
|
|
|
|
|
See CFile[^], and in particular the Read() and Write() functions.
|
|
|
|
|
antonio343 wrote: f1.Open(path, CFile::modeCreate | CFile::modeRead || CFile::typeText);
TCHAR buf[100];
f1.ReadString(buf, 99);
You are creating an empty file and then attempting to read from it. Is that really what you want?
Also, you may want to revise your usage of the | and || operators.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|