|
Is there any problem in reading line by line or character by character,
while (input.good())
{
input.getline(tmp ,255);
cout<<tmp <<end;
}
|
|
|
|
|
Hi,
In case of >> operator, string is extracted up to the first whitespace character, and that's why you can't read entire string.
Use getline instead.
working example:
const int slen = 256;
char tmp[slen] = "Sit on my face...";
ofstream ofile("c:\\test.txt", ios::out);
ofile << tmp << endl; ofile.flush();
ofile.close();
char tmp2[slen];
ifstream ifile("c:\\test.txt", ios::in);
ifile.getline(tmp2, 256);
cout << tmp2 << endl;
ifile.close();
Regards
|
|
|
|
|
hi all i want to make permission on the folders through vc++ code so that any user does not access those folders and delete their files,basically i m making the document Management System and want for that any help is welcomed.
Tasleem Arif
|
|
|
|
|
|
I was trying to change the font of some labels on a dialog, I used the following code:
HBRUSH CTabOne::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)<br />
{<br />
<br />
<br />
HBRUSH hbr = NULL;<br />
CFont LabelFont;<br />
if(nCtlColor == CTLCOLOR_DLG || nCtlColor == CTLCOLOR_STATIC)<br />
{<br />
if(pWnd->GetDlgCtrlID() == IDC_STATIC_COMMAND)<br />
{<br />
LabelFont.CreateFont (14,14,0,0,FW_BOLD, FALSE, FALSE, 0, DEFAULT_CHARSET,<br />
OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY,<br />
DEFAULT_PITCH, NULL);<br />
pWnd->SetFont (&LabelFont, TRUE);<br />
}<br />
}<br />
return hbr;<br />
}
And included
ON_WM_CTLCOLOR()
in the message map.
But looking at the processing that is being done ~ 50%, I have got something wrong! Also the labels 'flicker'.
As these are static labels, just need the Font set during dialog initialsation.
A bit confused as to how to set up the OnCtlColor parameters if thats the way to do it.
Any suggestions please.
Andy.
|
|
|
|
|
Why dont you use CWnd::SetFont() for this purpose? Instead of above code.
|
|
|
|
|
Hi,
instead: pWnd->SetFont (&LabelFont, TRUE);
use: pDC->SelectObject( LabelFont );
and don't forget about delete font object
LabelFont->DeleteObject();
Works pretty good
-----------
Mila
|
|
|
|
|
Mila025 wrote: use: pDC->SelectObject( LabelFont );
Why?
SetFont can be called from OnInitDialog . As it needs to be set once. Why you want to set it again and again.(it will be called each time window is painted).
|
|
|
|
|
OK, that sounds good just setting it once.
But how do I select the control I want to change the Font in OnInitDialog?
I was selecting the ones in the OnCtlColor procedure.
Andy.
|
|
|
|
|
Hi,
GetDlgItem( IDC_STATIC_COMMAND )->SetFont( &LabelFont, TRUE );
-----------
Mila
|
|
|
|
|
Andy202 wrote: But how do I select the control I want to change the Font in OnInitDialog?
CWnd *pWnd=GetDlgItem(IDC_STATIC);
pWnd->SetFont();
|
|
|
|
|
Thanks Prasad, all working as required.
Using this I can make my Dialogs a bit more interesting.
est wishes,
Andy.
|
|
|
|
|
|
Hi,
Yes you're right, it can be used with CWnd::SetFont.
I wrote only a little correction to Andy202s code
-----------
Mila
|
|
|
|
|
If you have a variable for their you can use of m_Static.SetFont(GetFont());
|
|
|
|
|
See the Extras section of this article.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The situation is :
-launch of release application using my COm object => memory leaks when I use Function to get data with an SafeArray.
- launch of release application in VC++ 6.0 with debug => no memory leak.
What is the difference, what are dll that are used? Have someone an explication?
Thank you for a response and help
LOUIS Christian
|
|
|
|
|
Post code, that giving this problem.
|
|
|
|
|
|
Hi,
For some odd reason, I am not able to Register the COleDropTarget.
I have been working with my project for a while, so I suspect it is
something within my project.
I do have the member variable COleDropTarget m_dropTarget in the header.
Then, in the OnInitialUpdate, I call m_dropTarget.Register(this).
// register drop target
BOOL b = m_dropTarget.Register(this);
It keeps failing at the if(CoLockObjectExternal()) shown below.
Does anybody know what CoLockObjectExternal means?
BOOL COleDropTarget::Register(CWnd* pWnd)
{
ASSERT_VALID(this);
ASSERT(m_hWnd == NULL);
ASSERT_VALID(pWnd);
LPUNKNOWN lpUnknown = (LPUNKNOWN)GetInterface(&IID_IUnknown);
ASSERT(lpUnknown != NULL);
if (CoLockObjectExternal(lpUnknown, TRUE, FALSE) != S_OK)
return FALSE;
|
|
|
|
|
Hi,
I write a dll which will be loaded by different application. Currently, I need to share some data between the same dlls loaded in different processes. How can I do? Is there a simple way?
I consider to use a file to stored the data shared. But I must write/read the data frequently. So I think use file is not a good way.
|
|
|
|
|
|
You can place the data into a shared data segment.
Be sure to protect access to it with some sort of thread-safe synchronization mechanism.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Good day everyone,
I'm doing a project with Vc++6.0 database MS Access
I'm struggling with the connection and coding with database.
Does anyone know where I can get a tutorial of how to connect to database and manipulate with data?
Thanks for your help in advance.
|
|
|
|
|
abrakadbra wrote: Does anyone know where I can get a tutorial of how to connect to database and manipulate with data?
Here[^]
|
|
|
|