|
Sure, it is code already in the control, but not exposed to the developer. (Unless I missed it.)
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Hi Tim,
I followed your suggestion and used GetTextExtentPoint32() but something's not quite right. Can you help out please?
This is my code:
CString line;
// Code to populate ``line''
m_edit3.SetWindowText(line);
RECT rect;
m_edit3.SendMessage(EM_GETRECT, 0, (LPARAM)&rect);
CDC *cdc = m_edit3.GetWindowDC();
HDC hdc = cdc->GetSafeHdc();
SIZE Size;
GetTextExtentPoint32(hdc, (LPCTSTR)line, line.GetLength(), &Size);
but the following values are returned:
rect.left 4
rect.top 1
rect.right 394
rect.bottom 14
so the formatting rect of the edit control is 390 x 13, but Size contains the following:
Size.cx 552
Size.cy 16
The string (line) contains 72 chars and only the last 3 chars are outside the edit box.
Do these 2 values (rect & Size) use different units?
Any help would be greatly appreciated.
Regards,
Parish
while (!asleep)
code();
|
|
|
|
|
I'm trying to put strings in a richedit box I made with the Microsoft's Active X control in MFC, but it just won't work. Hope somebody can help me.
Thx. Lio.
|
|
|
|
|
Post your code.
--Mike--
http://home.inreach.com/mdunn/
"Listen you footwarriors, can you hold down a bit with the firing? I've just got three impromptu weddings breaking out behind me!" -- Arthur Dent
your with and
|
|
|
|
|
"Listen you footwarriors, can you hold down a bit with the firing? I've just got three impromptu weddings breaking out behind me!" -- Arthur Dent
When did he say that ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
That's from the last radio show, when the Lintillas and the anticlones get married so the anticlones can kill the Lintillas.
--Mike--
http://home.inreach.com/mdunn/
"Listen you footwarriors, can you hold down a bit with the firing? I've just got three impromptu weddings breaking out behind me!" -- Arthur Dent
your with and
|
|
|
|
|
??
I have an owner drawn control. It calls SetFont, then MeasureItem, then DrawItem for each item. Is there any way of calling MeasureItem each time DrawItem is called? Or is there a way to get a handle on
LPMEASUREITEMSTRUCT lpMeasureItemStruct
So that I can call MeasureItem again.
Please, please any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
I was wondering if anyone could recommend an array class\template that would work with the following array classes within classes?
class Third
{
public:
int m_data;
double m_price;
};
typedef CArray< Third > ThirdArray;
class Second
{
public:
int m_data;
ThirdArray m_ThirdArr;
};
typedef CArray< Second > SecondArray;
class First
{
public:
SecondArray m_SecArr;
};
CArray does not like this because of the protected copy constructor. I need to be able to make copies easily of the class First.
Any ideas?
Giles
|
|
|
|
|
|
Hi Tomasz,
Yep, I guessed I would get the STL vector class as a reply. I have implemented it for the time beinf, but I find it such a horrible thing to debug with. The person who wrote it did not seem to know what tabs and carrige returns are.
I was kind of hoping that someone had written something a bit nicer. I had a go at writing my own. It workde okay until the but about an array inside an array part. I could not seem to get the copy constructor to be happy.
Thanks,
Giles
|
|
|
|
|
Yes, the STL implementation that ships with VC++ 6.0 is hard to debug. You can switch to free STLPort (www.stlport.org), it's source is orders of magnitude more readable and even has debug diagnostics.
Anyway, if you'd like to stick with MFC containers, you create new template derived from CArray and make its copy constructor public.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks for the tip. I think I will give STL a go. Have not touched it in about 5 years, but this gives me the excuse.
Giles
|
|
|
|
|
Following recomendations of some friends who says that standard C++ is more efficient and fast than non standard, I have a case that demonstrates it is not true....UNLESS I AM NOT CONSIDERING SOME OTHER C++ STANDARD FUNCTIONALITIES THAT ENCHANCE THE SPEED SUCH AS AN EFFICIENT BUFFERING.
The next program shows two ways of copying one file to another, the first one (CODE A) is very, very slow but the second (CODE B) is very fast. CODE A uses standard C++ (do not consider CTIME ), CODE B uses MFC.
Try this, copy/paste this program to your powerful computers and create a input text file of 40MB, run it and and you will see the amazing results.
By the way, I have necessity to read lines, that is why I show this case with this functionality.
Please comment me your points of view.
#include <afxwin.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main()
{
// CODE A
// This code................
CTime startTime = CTime::GetCurrentTime();
string sReg;
ifstream entrada; entrada.open("prov.txt");
ofstream salida("prov1.txt");
while(getline(entrada, sReg))
salida << sReg << endl;
salida.close();
entrada.close();
CTime endTime = CTime::GetCurrentTime();
CTimeSpan ts = endTime - startTime;
cout << (LPCTSTR)ts.Format("Time consumed: Mins: %M, secs: %S" ) << endl;
// is extremely lower than ...
// CODE B
// this code......
startTime = CTime::GetCurrentTime();
CString stReg;
CStdioFile ent;
CStdioFile sal;
ent.Open("prov.txt", CFile::modeRead);
sal.Open("prov2.txt", CFile::modeCreate | CFile::modeReadWrite);
while (ent.ReadString(stReg)) {
sal.WriteString(stReg);
sal.WriteString("\n");
}
endTime = CTime::GetCurrentTime();
ts = endTime - startTime;
cout << (LPCTSTR)ts.Format("Time consumed: Mins: %M, secs: %S" ) << endl;
sal.Close();
ent.Close();
}
|
|
|
|
|
I beg your pardon . The #included files are:
afxwin.h, iostream, fstream and string.
For some reason, the angular brakets have some problems.
|
|
|
|
|
> For some reason, the angular brakets have some problems
I had similar problem yesterday too while posting a message. It looks like HTML was probbaly confusing with its tagging mechanism.
Later I figured if you provide a space after and before the brackets, it works fine. Here is how I did..
#include < afxtempl.h >
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Maybe you should check out how CStdioFile class actually does the copying of the file. This is how it does it, and it seems to me like it's using what your friend calls "standard C++". (With the exception of CString)
BOOL CStdioFile::ReadString(CString& rString)
{
ASSERT_VALID(this);
rString = &afxChNil;
const int nMaxSize = 128;
LPTSTR lpsz = rString.GetBuffer(nMaxSize);
LPTSTR lpszResult;
int nLen = 0;
for (;; )
{
lpszResult = _fgetts(lpsz, nMaxSize+1, m_pStream);
rString.ReleaseBuffer();
if (lpszResult == NULL && !feof(m_pStream))
{
clearerr(m_pStream);
AfxThrowFileException(CFileException::generic, _doserrno,
m_strFileName);
}
if (lpszResult == NULL ||
(nLen = lstrlen(lpsz)) < nMaxSize ||
lpsz[nLen-1] == '\n')
break;
nLen = rString.GetLength();
lpsz = rString.GetBuffer(nMaxSize + nLen) + nLen;
}
lpsz = rString.GetBuffer(0);
nLen = rString.GetLength();
if (nLen != 0 && lpsz[nLen-1] == '\n')
rString.GetBufferSetLength(nLen-1);
return lpszResult != NULL;
}
void CStdioFile::WriteString(LPCTSTR lpsz)
{
ASSERT(lpsz != NULL);
ASSERT(m_pStream != NULL);
if (_fputts(lpsz, m_pStream) == _TEOF)
AfxThrowFileException(CFileException::diskFull, _doserrno, m_strFileName);
}
Sprudling
|
|
|
|
|
Anybody who would make a blanket statement like that should just get a pat on the head and the response, "Oh, isn't that sweet".
Standard anything based on the lowest common denominator is usually slower than something designed for the platform in question. The important phrase being "is usually".
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
OK, I accept the title is really a good way to receive the pat and response "Oh, isn't that sweet". Sorry, I was referring to the libraries.
I only intended to recieve an answer such as: If you want to speed the "code A" using C++ standard libraries (not C and not MFC) use option1, option2, ...etc.
Actually, I need a very fast reading/writing process because I manage big files and I do not only read files, I make other complex memory manipulations for every line I read.
According to your answer, it means that the only solution is to use MFC, because I could demonstrate it is faster than C++ standard libraries. I do not feel happy because my intention to use standard C++ libraries for manipulating files (GUI is not important) will be deferred. May be, in a LINUX or UNIX environment it works faster but, in my work, we use Windows platform.
Thank you for your comments.
|
|
|
|
|
How to convert char * to LPWSTR for func. NetWkstaUserEnum??
|
|
|
|
|
Try MultiByteToWideChar function
regards
|
|
|
|
|
If you have ATL installed, take a look at AtlA2WHelper.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
If you're using MFC, you can use CString to do it, just call AllocSysString.
Either way, you can cast to _bstr_t in order to do this conversion. Just #include <comdef.h>
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
search for "String Conversion Macros" in MSDN
or locate in Visual C++/Reference/ATL/Reference
|
|
|
|
|
Hello,
I want to Know the Events that called, when i press the Close button from the Print Preview Button......
As if user presses both Print and Close button from the Print Preview window toolbar. the event that is called named
OnEndPrintPreview
and
OnEndPrinting
Actuallyu i want to differentiate both Events....
Thanks in Advance...
|
|
|
|
|
Hi,
I am facing a problem in Printing. That I have to make the pages of the data that i want to display in the form of the CStringList. Now when the Actual Printing Functions is called I check this by Using afxMessagebox that do textout the exactly string that i want to display and one more intertersting thing is that the print preview data is also diplaying but on the printer when I gave the print command neither from Print preview data is comming out on the printer page nor from Print method.
Can Any one help me...
|
|
|
|