|
Hi again.
I've included the sleep functions in all threads I'm using and that's done the job! Back to 0-1% again!
Thanks all for your great help!
"create a global event handle and wait on it, exiting when it becomes signaled."
I'll look into that as well. Thanks very much.
OCrowley.
|
|
|
|
|
Hi,
How can I display an .eml message in my application similar to outlook express?
|
|
|
|
|
I could found functions that solve the problem, but there is some problem with the kind of variables, first I made a cast of the name the archive, it solve but it did't with CStringArray line; to LPCTSTR
tried:
AppendLineToMultilineEditCtrl(m_Edit,LPCTSTR(line::GetData()));
It gave the error:
Error 1 error C2510: 'line' : left of '::' must be a class/struct/union c:\Users\henitz\Documents\Visual Studio 2005\Projects\CodeDecodeCPlus2\CodeDecodeCPlus2\CodeDecodeCPlus2Dlg.cpp 108
Error 2 error C3861: 'GetData': identifier not found c:\Users\henitz\Documents\Visual Studio 2005\Projects\CodeDecodeCPlus2\CodeDecodeCPlus2\CodeDecodeCPlus2Dlg.cpp 108
Thanks
void CCodeDecodeCPlus2Dlg::OnBnClickedCode()
{
// TODO: Add your control notification handler code here
if (m_Code)
{
CStringArray line;
ReadTextFile(LPCTSTR("Teste2.txt"),line);
AppendLineToMultilineEditCtrl(m_Edit,line);
}
}
void AppendTextToEditCtrl(CEdit& edit, LPCTSTR pszText)
{
// get the initial text length
int nLength = edit.GetWindowTextLength();
// put the selection at the end of text
edit.SetSel(nLength, nLength);
// replace the selection
edit.ReplaceSel(pszText);
}
void AppendLineToMultilineEditCtrl(CEdit& edit, LPCTSTR pszText)
{
CString strLine;
// add CR/LF to text
strLine.Format(_T("\r\n%s"), pszText);
AppendTextToEditCtrl(edit, strLine);
}
void ReadTextFile(LPCTSTR pszFileName, CStringArray& arrLines)
{
arrLines.RemoveAll();
CString strLine;
TRY
{
CStdioFile file(pszFileName, CFile::modeRead);
while(file.ReadString(strLine))
arrLines.Add(strLine);
}
CATCH_ALL(e)
{
e->ReportError(); // shows what's going wrong
}
END_CATCH_ALL
}
|
|
|
|
|
why are you writing LPCTSTR(...) ?
you're not calling a new type's constructor, you're calling a cast operator from an existing type.
so change into this: (LPCTSTR)... .
BTW, dunno if it's related to you issue though.
also, how is defined line ?
|
|
|
|
|
toxcct wrote: also, how is defined line ?
Locally as CString array CStringArray
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
modified on Thursday, June 5, 2008 1:57 PM
|
|
|
|
|
I corretecd first cast:
ReadTextFile((LPCTSTR)"Teste2.txt",line);
What I can do with line
It's defined like:
CStringArray line;
But the function ask: CStringArray& arrLines
AppendLineToMultilineEditCtrl(m_Edit,(LPCTSTR) line);
Ask line like: LPCTSTR pszText
|
|
|
|
|
Your function is expecting a reference
Henitz wrote: void ReadTextFile(LPCTSTR pszFileName, CStringArray& arrLines)
and you are giving
Henitz wrote: CStringArray line;
ReadTextFile(LPCTSTR("Teste2.txt"),line);
an object.
Does it helps?
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Henitz wrote: tried:
AppendLineToMultilineEditCtrl(m_Edit,LPCTSTR(line::GetData()));
It gave the error:
The problem is in the signature of AppendLineToMultilineEditCtrl() . See its signature below.
Henitz wrote: void AppendLineToMultilineEditCtrl(CEdit& edit, LPCTSTR pszText)
From name, i guess, you want to add multiple strings to edit control and you're calling the function with string array, but that function takes only a string as param. I think, you need the following one.
void AppendLineToMultilineEditCtrl(CEdit& edit, CStringArray& arrLines)
{
}
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
If did, I have to change all code of the function.
Do you how to do ?
|
|
|
|
|
I don't want to offend you, but the solution given is from basic level, if you dont know how to iterate an array... I strongly recommend you to start reading a basic manual and trying easy things at the beggining to go complicating them incrementally.
One hint:
for (intial condition; while condition; iteration)
{
//here the things that have to be repeated
}
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Stop trying to cast your problems away, it just makes things worse!
Steve
|
|
|
|
|
Henitz wrote: line::GetData()
Shouldn't this be line.GetData()?
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Hi, I am looking for some information on how to enumerate through the list of available drives on the local machine to be displayed to the user. I remember coming across something similar on CP sometime back, but I am unable to locate it now. If someone could point me in the right direction on where to find some sample code or demo progs., it would be greatly apperciated.
I am going to be doing this in VC++ (2003), MFC, on Windows.
Thanks
|
|
|
|
|
Have you tried GetLogicalDrives() or GetLogicalDriveStrings() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Try something like this:
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
DWORD mask = GetLogicalDrives();
for (char letter='A'; mask!=0; mask=mask>>1, letter+=1)
{
if (mask & 1)
{
cout << letter << ":" << endl;
}
}
return 0;
}
Steve
|
|
|
|
|
|
|
I have a Rich Edit Control Box in my dialog based visual c++ 6 application. The Text Displayed in the REditctl is in myfont.ttf. I want to :->
1)Format Different Lines of the text in different point size.
2)The text of the REditctl should be saved alongwith formatting.
(.doc,.txt file extensions)
3)The multiline text should be printed as formatted with myfont.ttf.
I tried that so much available Printing code for dialog based application.
Can some body help and give me a simple but correct insertable code for the
above narrated 3 problems.
|
|
|
|
|
Why don't you get every different format as a different text? and in each of them say which font are you using, that will make easier to save/print datas. One suggestion (I don't even know if it is a good way to do it, but just an idea).
You can declare a class with a "header" where the font is saved and use different instances of that class according to how the text is formated
I mean... suppose a text of 10 lines, and you want to change font in lines 4 to 6, then brake your 10 lines text into 3lines (1-3), 3lines(4-6) and 4lines(7-10) text parts. So when you save the datas into a file you save the header at first place, then the content of that text part and then the next one. By printing you can use it as well, by getting the first part, looking the header and configurating the DC with that info, then send the text included to the printer and continue with the next part.
Other member will most probably have better options, but this at least is a possibility.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hi all
I try to display current time in static control but its not given me the time its show me something
unicode values although i have changed the setting but still i did get result
Thanks
|
|
|
|
|
So why are you not showing us the code you are using, or do we just guess as to what you are doing wrong?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
<br />
void CDigitalclockDlg::OnPaint()<br />
{<br />
if (IsIconic())<br />
{<br />
CPaintDC dc(this);
. ........<br />
............<br />
............<br />
<br />
}<br />
else<br />
{<br />
<br />
<br />
<br />
<br />
CDialog::OnPaint();<br />
<br />
GetLocalTime(&time);<br />
<br />
<br />
char str[256];<br />
sprintf_s(str,"02d%:02d%:02d%",time.wHour,time.wMinute,time.wSecond);<br />
int len;<br />
int slength = (int)str.length() + 1;<br />
len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), slength, 0, 0);<br />
wchar_t* buf = new wchar_t[len];<br />
MultiByteToWideChar(CP_ACP, 0, str.c_str(), slength, buf, len);<br />
SetDlgItemText(IDC_STATIC,(LPCTSTR)str); <br />
<br />
}<br />
}<br />
|
|
|
|
|
amistry_petlad wrote: sprintf_s(str,"02d%:02d%:02d%",time.wHour,time.wMinute,time.wSecond);
This should not even compile (bad format string).
amistry_petlad wrote: int slength = (int)str.length() + 1;
This should not even compile (integral types have no methods).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
When I had simply used sprintf complier generated warning for sprintf AND give suggestion fo sprintf_s
i am using MSVS2008 ON VISTA
I have change the code following way it compile succesful but rund time break the application
<br />
GetLocalTime(&time);<br />
char str[256]; <br />
<br />
<br />
sprintf_s(str,"02d%:02d%:02d%",time.wHour,time.wMinute,time.wSecond);<br />
<br />
std::string str1(str);<br />
int len;<br />
int slength = (int)str1.length() + 1;<br />
len = MultiByteToWideChar(CP_ACP, 0, str1.c_str(), slength, 0, 0);<br />
wchar_t* buf = new wchar_t[len];<br />
MultiByteToWideChar(CP_ACP, 0, str1.c_str(), slength, buf, len);<br />
SetDlgItemText(IDC_STATIC1,buf);<br />
|
|
|
|
|
amistry_petlad wrote: ...but rund time break the application
And rightfully so since you did not change sprintf_s() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|