|
i am doing a programm such that, i have created a text file through CFile and i am writing some text in it through "Write" function of CFile, i want to add a new line character after every line but getting some different result when i check the text file after writting the data. My code and result i am getting is as follows,
CFile oFile;
if(!oFile.Open("test.txt",CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite))
{
AfxMessageBox("Sorry! text file can't be created");
}
else
{
for(int i=0;i<3;i++)
{
oFile.Write("code project",sizeof("code project"));
oFile.Write("\n",1);
}
}
Results=
code project || code project || code project ||
can anybody help me plz, how to do it?
Thanks & Regards,
Anay Kulkarni
|
|
|
|
|
|
Well, that will print exactly this in the file: "\n".
|
|
|
|
|
Use oFile.Write("\r\n",2); (or "\n\r", I don't remember exactly).
|
|
|
|
|
|
Check this line
oFile.Write(_T("code project\n"),sizeof(_T("code project\n")));
|
|
|
|
|
Does it have any difference from the actual code?
- NS -
|
|
|
|
|
I checked this line it works.
|
|
|
|
|
But what is the magic between
oFile.Write(_T("code project\n"),sizeof(_T("code project\n")));
and
oFile.Write("code project",sizeof("code project"));
oFile.Write("\n",1);
- NS -
|
|
|
|
|
Well can you check it and then tell me what did you see?;)
|
|
|
|
|
Use:
oFile.Write("code project", strlen("code project")); or
CStdioFile oFile;
...
oFile.WriteString("code project\n");
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
am using Hot key in one of my appliation.But there is a problem.
The Hot key combination works only when the focus is on that window . while my application is runing in the background( Its a Win32 dialog based application and i make dialog hidden at startup)and so the Hot key is not working. Is there any way I can solve this.
I am using something like this now,
LRESULT CALLBACK MyDialogProc(HWND hWndDlg,....)
{
ShowWindow(hWndDlg,SW_HIDE);
switch(message)
{
case WM_INITDIALOG:
{
InitCommonControls();
HWND hHotKey = GetDlgItem(hWndDlg,IDC_HOTKEY1);
if(!RegisterHotKey(hWndDlg , IDC_HOTKEY1, MOD_ALT | MOD_CONTROL,0x67))
{
dError = GetLastError();
MessageBox(NULL,L"Hot Key Not Working ",L"Error",0);
}
}
break;
case WM_HOTKEY:
ChangeString(hWndDlg);
break;
}
}
Thnx in advance.....
|
|
|
|
|
GauranG33 wrote: HWND hHotKey = GetDlgItem(hWndDlg,IDC_HOTKEY1);
if(!RegisterHotKey(hWndDlg , IDC_HOTKEY1, MOD_ALT | MOD_CONTROL,0x67))
From MSDN:
BOOL RegisterHotKey( HWND hWnd, int id, UINT fsModifiers, UINT vk);
id
[in] Specifies the identifier of the hot key.
but from your code, it seems the ID of a control window.
And where are you using hHotKey ?
|
|
|
|
|
Yes, IDC_HOTKEY1 is the cotrol ID of the Hotkey control which I have dragged from the ToolBox on my dialog box.
I am using Win32 Dialog Based Application. In that I have put the Hotkey Control and then I am using the previous code. The problem is that hotkey is working only when the focus is on dialog box. If the Focus is on other window.Hot Key combinations are not working.
I want to call some function when the combination of some key are pressed.And so I am using HotKey for that.
|
|
|
|
|
how to retreive the height an dwidth of an HBITMAP ?
void GetBitmapResolution( HBITMAP hBmpIn , int *BmpCx , int *BmpCy )
{
// plz tell me hwo to solve this function
}
thanks & regards
|
|
|
|
|
I almost looked this up for you, but I could not bring myself to do it. Any Windows help system will provide the answer, and several articles at CP.
Shortcut: look up my name and examine the code, I am sure the solution is in there some where.
Sorry, in a bad mood tonight.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Did you see BITMAP structure and see GetObject .
|
|
|
|
|
|
I am making an mfc dialog based application where when I click on a button should open a installation type dialogs with NEXT PREVIOUS and CANCEL BUTTON.
How to do it on mfc.
Please help me.
Dhiraj Kumar Saini
|
|
|
|
|
Have a look at PropertySheet section on this site. You will get tons of articles.
Prasad
MS MVP - VC++
|
|
|
|
|
|
I saw a code chunk like this:
// MP3FRAMEHEADER structure
struct MP3FRAMEHEADER
{
unsigned emphasis : 2; // M
unsigned original : 1; // L
unsigned copyright : 1; // K
unsigned modeext : 2; // J
unsigned chanmode : 2; // I
unsigned privbit : 1; // H
unsigned padding : 1; // G
unsigned samplerate : 2; // F
unsigned bitrate : 4; // E
unsigned hascrc : 1; // D
unsigned mpeglayer : 2; // C
unsigned mpegver : 2; // B
unsigned framesync : 11; // A
};
There,the number like 2,1,1,... means what?
It does not look like the initialized number of its front member?
Who would like to tell why the writer coding like above?
Thanks.
GOOD LUCK!
|
|
|
|
|
|
It is called as bit-fields. Have a look at link provided by Nitin.
Prasad
MS MVP - VC++
|
|
|
|
|
Oh,I see.
Thank you very much.
|
|
|
|