|
Per MSDN, read() reads the number of bytes specified by the second parameter. In this case, it reads 1 byte into charVar , but leaves the CRLF characters in the stream for the next call to read() . I think you need to use getline() instead.
LudaLuda wrote:
and I have to use the ios::binay method to open the file,
Why? From what you've shown, binary mode is not necessary.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
okey guys I got that part to work.
Now I have another problem.
how do I move the pointer so that it points to the beginning of the next record location in the file. I have several records in the file.
|
|
|
|
|
seekp(...);
seekg(...);
Maxwell Chen
|
|
|
|
|
LudaLuda wrote:
how do I move the pointer so that it points to the beginning of the next record location in the file. I have several records in the file.
That all depends on what a "record" is.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I have the following code:
TCHAR * ptszVersionInfo = _T(""); //Executes OK
ptszVersionInfo = new TCHAR[10]; //Executes OK
delete ptszVersionInfo; //Executes OK
ptszVersionInfo = _T("Anton"); //Executes OK
delete ptszVersionInfo; //Weird erro. From debug assert.It basically says there is an error with _CrtIsValidHeapPointer.
Now how come. (I am not very good with string allocation ).
|
|
|
|
|
HAHAHA_NEXT wrote:
_T("Anton"); is a pointer to STATIC memory, u can't free it!
HAHAHA_NEXT wrote:
ptszVersionInfo = new TCHAR[10]; //Executes OK
delete ptszVersionInfo; //Executes OK this would rather be delete [] ptszVersionInfo;
Don't try it, just do it!
|
|
|
|
|
Is there a way i can allocate _T("Anton") Into a dynamic memory ? because my code is all mixed up. (I allocate the string using both methods).
|
|
|
|
|
HAHAHA_NEXT wrote:
Is there a way i can allocate _T("Anton") Into a dynamic memory ?
This does not quite make sense, but I think what you want is:
TCHAR *p = new TCHAR[6];
_tcscpy(p, _T("Anton"));
...
delete [] p;
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Ths. It is exactly what i needed. The reason for this kind of weird stuff is because i can allocate the same string 2 ways:
the first is
p = "Anton"
and the second is
<br />
p = new TCHAR[6];<br />
_stprintf(p, ....)<br />
This will avoid me having different variable and one clean delete statement .
|
|
|
|
|
HAHAHA_NEXT wrote:
...
delete ptszVersionInfo; //Executes OK
ptszVersionInfo = _T("Anton"); //Executes OK
delete ptszVersionInfo;
Two problems:
1) You are using ptszVersionInfo after you've done a delete on it.
2) You are doing a second delete on a ptr that you've already done a delete on.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
I have a derived Dialog class - CGeneralStatus that has a CString variable. If I set the string before I create the CGeneralStatus dialog it is displayed OK. When I set this string to different value the value in the window does not get changed. Even if I close and reopen the dialog window the value does not change.
Any input is greatly appreciated !
------------------------------------------------------------------------
Application code:
void CFV3TaskMonApp::OnGeneralstatus()
{
if(IsShowingGeneral())
{
HideGeneral();
}
else
{
ShowGeneral(m_pMainWnd->GetActiveWindow());
}
}
void CFV3TaskMonApp::ShowGeneral(CWnd* parent)
{
if (!::IsWindow(*m_generalStatus))
{
m_generalStatus->Create(IDD_GeneralStatus, parent);
}
m_generalStatus->GeneralChanged(); // update the string
m_generalStatus->ShowWindow(1);
}
Code snippet to update the string value before calling ShowWindow(1):
void CGeneralStatus::GeneralChanged()
{
CString out;
out.Format("%d",m_app->m_numConnections);
m_connAttempts = out;
if (::IsWindow(this->GetSafeHwnd()))
{
::PostMessage(this->GetSafeHwnd(),UWM_STATUS_UPDATEGENERAL,0,0);
}
}
|
|
|
|
|
glweid wrote:
When I set this string to different value the value in the window does not get changed.
Even though you've assigned a value to a CString variable, you did not indicate how it was being displayed. Assuming it was an edit or static control, you simply need an appropriate control variable in the dialog's declaration (e.g., CEdit m_editnumConnections ). When it comes time to display the value, simply call m_editnumConnections.SetWindowText() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
My Dialog box only has the string variable (edit control - read only) box displayed, how do you declare a CEdit variable associated with that ?
I added a CEdit m_editnumCOnnections compiled it and passed the new string value to m_editnumConnections.SetWindowText() and it cores not finding a main window handle.
Thanks !
-----------
Code snip
// Dialog Data
//{{AFX_DATA(GeneralStatus)
enum { IDD = IDD_GeneralStatus };
CString m_connAttempts;
//}}AFX_DATA
|
|
|
|
|
Anonymous wrote:
how do you declare a CEdit variable associated with that ?
ClassWizard.
Anonymous wrote:
...and it cores not finding a main window handle
What does "cores" mean in this context? Did you add the appropriate entry to DoDataExchange() ? This is something that ClassWizard would do for you.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I want to suspent my display using a shortcut... no matter if vc++ or not.
Since I've never worked with power management I don't know how.
Any suggestions?
Thx
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
I want to suspent my display using a shortcut...
I don't quite understand what this means.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Have you looked at the Power Management API functions. eg. SetSystemPowerState() Should do the trick.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
thx
(I'm sorry for the wrong spelling of suspend )
Don't try it, just do it!
|
|
|
|
|
How do you stop an SDI application window from being resized?
Thanks
|
|
|
|
|
I think removing the client edge style will do the trick.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Thanks, that worked, but now I have another couple of problems.
First of all I have a status bar and I cannot get rid of the gripper on that.
Secondly there is now a 1 pixel wide transparent gap around the view (where I assume the thick border would have been)
You can see what I mean at http://a.domaindlx.com/sschilachi/snooker.JPG[^]
Thanks
|
|
|
|
|
humm, sorry cant help you with that prob.. post that porblem as seperate question may be someone else will help you.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
one way is to override OnGetMinMaxInfo(). In it, assign values to ptMinTrackSize and ptMaxTrackSize of the lpMMI variable. If the values are the same, the window will not be resizeable, although the arrow still changes to indicate that it can.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yet another way is to make a handler for WM_NCHITTEST in the app's mainframe class. You can "fool" by returning HT_CLIENT values for those on the edges. You can also override CStatusBar and do the same there. I have done this and it works well.
a two cent stamp short of going postal.
|
|
|
|
|
Does anyone know how to change the tab control color on the propertysheet? Overwrite CPropertySheet::OnCtlColor(...) doesn't quite work
|
|
|
|