|
what about to write your own logging system? it doesn't take much time and you can simply adjust it to your needs. i recommand it.
it consists of singleton class with method that add records to the log file. you can write also time, thread_id, process_id, variables values, states and so on...
4apai
There're no impossible tasks. There're tasks that required infinite period of execution time.
|
|
|
|
|
Jerome Conus wrote:
I need to implement some logging in my app.
If the quantity of data is small, you could use the system's event log. It has it's own API.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I looked at lots of logging packages about a year ago for Surfulater and in the end used AMLOG which you'll find here on CP. I had various problems with other loggers and some were just too big and complex for my needs.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hello,
I need to insert a dialog windows in to a nother dialog,
Well I have i MFC app and I need to make a type a Wizard.
And I have check but don't find a good one on this site. So how can I make a dialog apare in my dialog?
Is there a fast way to do this? Please help me.
|
|
|
|
|
He he
You can use the win32gui library.
(http://www.torjo.com/win32gui/)
It's extremely easy to have a dialog (A) on another dialog (B).
On dialog B, just insert a static control (a label), and give it the ID of the dialog A (for example, IDD_SAMPLE). That's it!
Best,
John
John Torjo, Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- http://www.torjo.com/win32gui/
-- v1.4 - true binding of your data to UI controls!
+ easily add validation rules (win32gui/examples/smart_dlg)
|
|
|
|
|
Thanks i will use that,
You are a life saver.
|
|
|
|
|
do you have to have the win32gui library you spoke of to insert dialog B onto dialog A in the static control? Or is there some specific property you have to set? I tried it and can't get it to work.
[insert witty comment here]
bdiamond
|
|
|
|
|
He he
Of course you need the win32gui library
Besides, if you really want something fun (smart dialogs) - you can check out the win32gui/examples/smart_dialogs examples.
(true binding of your data to controls)
Best,
John
John Torjo, Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- http://www.torjo.com/win32gui/
-- v1.4 - true binding of your data to UI controls!
+ easily add validation rules (win32gui/examples/smart_dlg)
|
|
|
|
|
hello,
I've the following problem:
1) two files one with data and another one with header about data's file
2) I need to insert the header into the data file at the beginning of file
3) I tried using Createfile in this form
<br />
tempfd=CreateFile(filename_save, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, NULL, NULL);<br />
but when I use the ReadFile, it returns error 183, that's defined in msdn ad
<br />
183 Cannot create a file when that file already exists. <br />
My idea was to copy the content of two files in memory, than paste the header into data file, than append the data file, but doesn't seems to work, any suggestion??
Thanks in advance
Paolo
|
|
|
|
|
as i understand
the code (pseudo) is following:
HANDLE hFile_header = CreateFile(filename_header, ...);
HANDLE hFile_save = CreateFile(filename_save, ...);
// and we want to append them?!
BOOL bRet = ReadFile(hFile_header);
// bRet = false?
DWORD dwError = GetLastError();
// and dwError = 183?
am i right?
post code to definite error faster...
4apai
There're no impossible tasks. There're tasks that required infinite period of execution time.
|
|
|
|
|
yes, you're right, here's my code
<br />
<br />
HANDLE source=CreateFile("header", GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL);<br />
HANDLE destination=CreateFile(filename_save, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, NULL, NULL);<br />
bool AppendToBeginOfFile(HANDLE source, HANDLE destination)<br />
{<br />
DWORD source_size=0,<br />
destination_size=0,<br />
BRs=0,<br />
BRd=0,<br />
BW=0;<br />
char *tmp1=NULL,<br />
*tmp2=NULL;<br />
if((source == NULL) && (destination == NULL)) return false;<br />
<br />
source_size=GetFileSize(source, NULL);<br />
destination_size=GetFileSize(destination, NULL);<br />
<br />
tmp1=(char*)malloc(source_size*sizeof(char));<br />
tmp2=(char*)malloc(destination_size*sizeof(char));<br />
<br />
<br />
bool k=ReadFile(destination, tmp2, destination_size, &BRd, NULL);<br />
DWORD l=GetLastError();<br />
k=ReadFile(source, tmp1, source_size, &BRs, NULL);<br />
l=GetLastError();<br />
if((BRs < source_size) || (BRd < destination_size)) return false;<br />
<br />
SetFilePointer(destination, 0 , 0 ,FILE_BEGIN);<br />
WriteFile(destination, source, source_size, &BW, NULL);<br />
}<br />
|
|
|
|
|
man. you open file for writing and try to read it?!
investigate createfile function.
4apai
There're no impossible tasks. There're tasks that required infinite period of execution time.
|
|
|
|
|
I know, it's not possible to obtain an handle for both ? ReadFile and WriteFile?? I'll do a CloseHandle and reopen with read permission, seems the only way to me, thanks
|
|
|
|
|
hm. thats possible. why not?)
CreateFile with GENERIC_READ | GENERIC_WRITE access.
read about CreateFile more carefully, i'm not saying smth that is not in common-access documentation.
4apai
There're no impossible tasks. There're tasks that required infinite period of execution time.
|
|
|
|
|
If you are going to read and write to the destination or source files, then you need to open for both reading and writing.
Also, you open the 'source' for CREATE_ALWAYS, yet you try to read from it. CREATE_ALWAYS will truncate the file to zero length, so why are you trying to read from it
If both files are supposed to exist and contain data before you start, I would do this:
HANDLE source=CreateFile("header", GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
HANDLE destination=CreateFile(filename_save, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
If your destination doe snot need to exist before hand, then open it with:
HANDLE destination=CreateFile(filename_save, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, NULL, NULL);
Your last WriteFile call is not using arguments that make any sense.
I think you wanted to append 'Destination' to end of 'Source'.
// start writing at beginning of file
SetFilePointer(destination, 0 , 0 ,FILE_BEGIN);
// make sure file is not going ot be longer than expected
SetEndOfFile(destination);
// write 'source' to destination
WriteFile(destination, tmp1, source_size, &BW, NULL);
// now write 'destination' to destination
WriteFile(destination, tmp2, destination_size, &BW, NULL);
This gives you a 'destination' file with the 'source' at the beginning and the
'destination' after that.
|
|
|
|
|
Hi,
I have a form view with many controls. When i resize my form view i.e change the size by moving it, my controls on form view also should get adjusted in size accordingly. Can anyone please help me to achive this?
Thanks
Madhavi
|
|
|
|
|
Hi,
Add resizing code on OnSize() function. Can use either the GetClientRect / the parameter from the onsize function, calculate the position and move the control to the new position using the MoveWindow function.
Sujan
|
|
|
|
|
There are several articles (with sample code) here on CP that discuss this very topic.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi ,
I am able to get it...i.e resize the controls. But I have a new problem now.
When I try to resize the view i.e child frame, there is a lot of flickering of all the controls. Can anyone please help to to remove this filckering of controls.
Thanks
Madhavi
|
|
|
|
|
this may not be of much help to you because I can't remember the exact name of the functions, but I was looking for something about resizing dialogs a while back and there's some function you can call like DeferDrawing() or something like that and then call another type of update function so that it draws everything at once sort of like a batch mode update. It might be a member of CWnd; check MSDN. Sorry I couldn't provide more info, but it's in a book I have (C++ .Net Bible by Tom Archer) that I don't have here at work with me today. And it's not .Net related.
[insert witty comment here]
bdiamond
|
|
|
|
|
hi,
Can anyone let me know how to add a scroll bar to Mainframe in MDI application?
Thanks
Madhavi
|
|
|
|
|
A scroll bar will appear automatically if any child frames stick out of the MDI window (main frame
blank area).
Failing that, you could add one in the same way as toolbars take up room around the edge, but that
is a lot of work.
Iain.
|
|
|
|
|
Hi All,
I have requirement to tranfer a file(test.txt) between 2 machines connected in same LAN.
May be we can use Sockets, but i dont know full details . please give me complete details with simple code if possible.
Regards,
Prax
|
|
|
|
|
I don't know if CopyFile will work between 2 different machines, but this should:
CFile fileFrom,fileTo;
CString strFrom,strTo;
int nOpen = fileFrom.Open(strFileArray[uFile],CFile::modeRead|CFile::shareDenyWrite);
if(!nOpen)
return;
unsigned long nLength = file.GetLength();
BYTE* pBytes = new BYTE[nLength];
if(!pBytes)
return;
fileFrom.Read(pBytes,nLength);
fileFrom.Close();
if(fileTo.Open(strTo,CFile::modeCreate | CFile::modeWrite,&ex))
{
fileTo.Write(pBytes,nLength);
fileTo.Close();
}
delete [] pBytes;
[insert witty comment here]
bdiamond
|
|
|
|
|
in the above code, the fileFrom.Open() call should have strFrom as the first parameter, not strFileArray[uFile];
[insert witty comment here]
bdiamond
|
|
|
|
|