|
Try calling clear() before attempting to write.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
nope...
I've also tried flush() with no success...
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
The following piece of code, modelled after yours, does write everything as intended:
#include <fstream>
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
class CLogBook : public fstream
{
public:
CLogBook(){}
~CLogBook(){ close(); }
void SaveLogData()
{
clear();
write(ErrorMessage().c_str(),ErrorMessage().size());
}
void ReadLogData(string& data)
{
seekg(0);
while(!eof()) {
char* temp = new char[1024];
getline(temp, 1024, '\n');
data.append(temp);
data.append("\n");
delete [] temp;
}
}
int& ErrorCode() { return m_errorCode; };
string& ErrorMessage() { return m_errorMessage; };
string& Extra() { return m_extra; };
private:
string m_errorMessage;
int m_errorCode;
string m_extra;
};
int main()
{
CLogBook dummy;
dummy.open("test.txt", ios_base::in | ios_base::out | ios_base::app);
dummy.ErrorCode() = 123;
dummy.ErrorMessage() = "Error occured in your brain.. please RTFM!";
dummy.Extra() = "WinMain";
dummy.SaveLogData();
string buf("");
dummy.ReadLogData(buf);
MessageBox(NULL, buf.c_str(), "", MB_OK);
dummy.ErrorCode() = 666;
dummy.ErrorMessage() = "never written words";
dummy.Extra() = "BASIC SUCKS";
dummy.SaveLogData();
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Aah!
Now I see what you meant... thanks, it works now!
ps. Would you/anyone be nice and tell me what you think of the class design?
it's not a big class but anyway!?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
One last qestion for now In VC++6 I have a MFC App that is a dialog based application that I have added a menu to. All of these menus have the mnemonics added in the caption &File E&xit... But none of these show up when the program is run. Is there something basic I am forgetting to do or set? It's under Windows XP so I don't know if that makes a difference or not.
Thanks for any info!
|
|
|
|
|
Under the display settings for Windows XP there is an option (on by default) which hides the shortcut keys until you hold down the Alt key.
Dave
|
|
|
|
|
Thanks, Thats weird that I never noticed it until I was working on my own app. Oh well thanks for the info!
|
|
|
|
|
I'm trying to figure out how to sort the date based on the short date format.
ie yyyy mm dd and dd mm yyyy. Any ideas.
Thanks
|
|
|
|
|
Make both YYYY MM DD, in crude pseudo code
wsprintf(szBuffer, "%04d%02d%02d", yyyy,mm,ddd);<br />
lDate = atol(szBuffer; )
The smalest number is the earliest date, the largest is the latest date. Or using M$ convert to COleDateTime format
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Does anyone have or know where I might be able to find like a quick reference card of shortcuts for VC++6 It would be really handy to have so I didn't know if there's one out there. I don't know if one comes with it cause we just have a site license at work so I don't have any manuals in front of me.
|
|
|
|
|
Help -> Keyboard Map
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I an application I am writing, I created several floating dialog bars. The problem is, that they all have the same title in the title bar. How can I create multiple floating Dialog Bars that have different titles?
-- Steve
|
|
|
|
|
CDialogBar bar;
bar.SetWindowText("My title");
I would expect it to be that simple. Tell me if not.
~RaGE();
|
|
|
|
|
I thought that it would be simple like that too. It just named all the floating dailog bars whatever I typed in the last time I called SetWindowText().
-- Steve
|
|
|
|
|
Hiya what is the way best to completely clear a text file so I can use it again and again??
Also how do I display the date "230303", reading it from the system??
Thanks,
grahamoj.
|
|
|
|
|
To clear a file
<br />
FILE* file;<br />
file = fopen("YourFile.txt", "w+");
Probably not the best way, but it works for me.
Kevin
|
|
|
|
|
You can use the strftime function to format a time/date string or you can use GetSystemTime to get the current time and date from the system.
|
|
|
|
|
I need somebody more litirate than I am to tell how to use some MFC classes in my program, but not creating the MFC project.
I was surprised by the following fact. Then I wrote a simple program which were using CAsyncSocket, and SocketInit() function everything was working Ok (I have choosen "Use MFC as shared Dll" in my Project Settings). After, I have decided what it's enough to do the job what is allready done. So, I have found the CPop3 class on CodeProjecta.com. This class uses some other MFC classes so I have done everything like in previous case. But as result I have recieved the error in AFXV_w32.H which required usen't windows.h MFC applications. I'm not able to find a place in the program where this header is included, and I think I won't be able. But this is not important. It's important if somebody expirianced will learn me how to use some suitable MFC classes in my program, would explain me how MFC is working (may be some books or links)
Need your help!!!
|
|
|
|
|
May I get handle of the resource (bitmap or icon) by his name and not his ID.
For example,
HBITMAP hBitmap = GetBitmapFromResource (_T("IDB_BITMAP1"));
If it possible then how can I do it?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
From MSDN:
<br />
HBITMAP LoadBitmap(<br />
HINSTANCE hInstance,
LPCTSTR lpBitmapName
);<br />
Hope this helps.
Rgds,
Nirav
* The world stands aside to let anyone pass who knows where he is going! - David Jordan *
|
|
|
|
|
This method work if pass ID as string. For example "#136". But I need pass the string name of resource, for example "IDB_BITMAP1"
Best regards,
Eugene Pustovoyt
|
|
|
|
|
HINSTANCE hinst = AfxGetInstanceHandle();
HBITMAP hBitmap = LoadBitmap(hinst, MAKEINTRESOURCE(IDB_BITMAP1));
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
No this don't work.
MAKEINTRESOURCE macro converts an integer value to a resource type compatible with the resource-management functions. But I need get resource from his string name and not his ID
Best regards,
Eugene Pustovoyt
|
|
|
|
|
You can't. "IDB_BITMAP1" is not stored anywhere in the resources, it is #defined to a number. You can use a string resource IDs by naming your bitmap "IDB_SOMETHING" (including the quotes), but you can't have a number and string for the same resource at the same time.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Hi,
1) I am going to purchase a Visual C++ Professional
Edition 6.0, I think it will contains InstallShield
Wizard ... but when I tried to read its features, I did
not see any thing mentioning about it?
- Anyone is sure about this?
2) To build a distribution kit, this InstallShield Wizard
looks like missing some dll's to use with DAO/MS Acces Engine?
If I have to merge some dll from MSN 's website ... is it
legal to distribute my application to the third party?
Many thanks,
|
|
|
|