|
This always worked well for me:
void CEditBoxText::SetEditBoxText(CEdit* pEdit, ifstream* pDatain)
{
char buf[506];
CString strOut, tmpstr;
int iLineCount, n;
pDatain->getline(buf, 250); iLineCount = atoi(buf);
for (n=0; n<ilinecount; n++)
="" {
="" pdatain-="">getline(buf, 500); tmpstr=buf;
strOut += (n == 0 ? "" : "\r\n") + tmpstr;
}
pEdit->SetWindowText(strOut); strOut.Empty();
}
void CEditBoxText::GetEditBoxText(CEdit* pEdit, ofstream* pDataout)
{
CString csEditText, strOut, tmpstr;
int iLineLength, iLineCount, n;
LPTSTR lpTmp = NULL;
pEdit->GetWindowText(csEditText);
if (csEditText.IsEmpty())
*pDataout << 0 << "\n";
if (!csEditText.IsEmpty())
{
iLineCount = pEdit->GetLineCount();
for (n = 0; n < iLineCount; n++) // get each line, one at a time
{
lpTmp = tmpstr.GetBuffer(pEdit->LineLength(pEdit->LineIndex(n))+1);
iLineLength = pEdit->GetLine(n, lpTmp);
tmpstr.ReleaseBuffer();
tmpstr = tmpstr.Left(iLineLength);
strOut += (n == 0 ? "" : "\n") + tmpstr;
}
*pDataout << iLineCount << "\n" << strOut << "\n"; strOut.Empty();
}
}
|
|
|
|
|
Hi,
How do I make a library class (.lib or .dll) for a dialog box, that also includes this class's resources.
What I want is a dialog box class with complete functionality, that I can use in many projects. I do not know how to make a library with this class so as to include the resources (controls etc.) of the dialog. All my attempts failed.
Please help me,
Thanks,
Adi
|
|
|
|
|
You can't put the resources into .lib. This leaves only .dll option - just create a .dll with resources. Choose carefully between 'MFC regular' and 'MFC extension' dll versions if you're playing with MFC.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
"...Choose carefully between 'MFC regular' and 'MFC extension' dll versions if you're playing with MFC."
What's the difference?
Adi
|
|
|
|
|
you can move you resources into a separate resource file (.rc)and the associate header file and create a library from that.
e.g. MyLib.rc and MyLib.h (extracted from resource.rc and resource.h)
then in your project add the rc and header file via
view->resource include..
Add #include "MyLib.rc" to the compile time directive edit box
Add #include "MyLib.h" to Read Only symbol directive edit box
|
|
|
|
|
Hi
I used logical coordinates in my program,in such functions as MoveTo() ,LineTo()etc.But if I scroll the client are i am not able to get those points.i am using CScrollView only.how to convert the coordinates and get the points?
thanks in advance.
Pathi
bhikshapathi_g@semanticspace.com
|
|
|
|
|
Assuming that you're writing a method of CScrollView-derived class, you'd code like this:
CClientDC dc(this);
OnPrepareDC(&dc);
dc.LPtoDP(&point);
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I am using an CHtmlView in my application and was just wondering whether you could do something or not. Is it possible to know when a user clicks on a hyperlink?
I'll explain why I wish to do this for a bit more background. The user open's up a record which is an html page generated from a text file that is stored on the local disk. Depending on certain criteria, hyperlinks are built in to this record. Because this page is generated automatically I want to be able to track which hyperlink is clicked on so I can generate the relevant destination page automatically so I don't have to store (potentially) lots of html files on the local disk. Any ideas?
Thanks for any help or suggestions in advance,
Nick
|
|
|
|
|
You need to look at the IE4 Event "BeforeNavigate2". Look at the help for this and then work out how to get the code to work for CHtmlView...
|
|
|
|
|
yep just found it, cheers anyway
Nick
|
|
|
|
|
I have an ATL database program which I *think* I understand how to create a connection point for, but I can't find any examples for creating a sink in MFC from an ATL server. Could someone point me in the direction of a tutorial ? It seems to me too complex to explain in a post, although if you feel you can, I'll appreciate that also. I have a book that shows me how to use a connection point from VB or ATL, but not MFC, and I tried to MFCise the ATL exmaple to no avail.
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.
|
|
|
|
|
|
Fantastic - thank you so much. I've not written a line of useful code tonight, although between what I found to read, and the article you linked me to ( plus the MSDN CD I'll bring home from work tomorrow night !! ), I reckon I'll make up for it tomorrow night
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.
|
|
|
|
|
1) I'm using CopyFile, which does what I need, but it does not copy the security attributes of the file (owner information particularly). I've rooted around in the documentation, but cannot seem to find how I can set the file security attributes of the copied file to match source file.
2) Also, I'd like to know how to set a file to 'my' owner name when I've copied it to a local machine. (Hopefully Q:1 will answer Q:2)
I'm hoping there is something easy and obvious I've overlooked. If you can point me to the right name I'd appreciate it.
Thanks in advance!
--Mark Terrano
www.ensemblestudios.com
(Creators of the Age of Empires series)
|
|
|
|
|
I believe SHFileOperation copies security attributes, unless you specify FOF_NOCOPYSECURITYATTRIBS flag. If you don't want a progress dialog, use FOF_SILENT.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi !,
Is it possible to get the content of a RichEditCtrl in a CString ( with all the formatting escape sequences..), and paste it then to a word table through automation.
Thanks, Bye !
Braulio
|
|
|
|
|
Is there a way to find out how long the system was idle (time since last keyboard or mouse action)?
Any help appreciated.
|
|
|
|
|
On Win2000 you can use GetLastInputInfo. On other systems you'll need to create a global keyboard/mouse hooks. Have a look at Feb'2000 issue of Microsoft Systems Journal, C++ Q&A column. It should be in the 'Periodicals' section of your VC++ help, if it's not there, go to msdn.microsoft.com, then MSDN Magazine.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello,
I need to create the following structure, I am sure that STL is the best to use, however, I am confused on how I should do it. Maybe someone could offer suggeststions.
My structure will look like this:
CMyClass
|
|
CMyClass
| |
| ----->CMyClass
| | |
| | ------->CMyClass
| | . .
| | . .
| | . .
| ----->CMyClass
| .
| .
| .
.
.
.
Any suggestions on how I could use STL in the best way for this?
Thanks!
Jeremy.
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
Are you going to implement a tree? There's no standard tree container (map and set use trees, but this is an implementation detail). I think the easiest way is to add a vector<CMyClass *> to CMyClass - this vector will hold pointers to children objects. You can also add a parent pointer, which will be NULL in the root object.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have an application on iPAQ that needs to communicate to a device through the comm port. I use GetCommState(...) to get the DCB values and then modify its baudrate, bytesize, stopbit and parity values. Later when i try to apply these changes using SetCommState(...), it just hangs there.
When i switch off the device, it returns with no error. Does anyone know what is causing this problem?? Thanks.
Wee Giap
|
|
|
|
|
Hi
As far as I know it is possible for other applications to
get a handle of the window from my application (e.g.: FindWindow), and then it is possible for this application to write into my window. Does anyone know a method to prevent this?
Thanks in advance
|
|
|
|
|
It's not possible to hide a HWND. You may try to make FindWindow harder to use - for example, by generating class name randomly each time your program starts, but this doesn't give you 100% protection - it's possible to iterate over all windows in the system.
BTW: What are you afraid of?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm writing a high security digital signature ActiveX control. And I thought it would be bad if another program writes into my window and then the signer thinks he signs something different then he really signs.
I try know with Win32 Hooks. I hope this helps.
|
|
|
|
|
What if another program displays its own window looking like yours? Assuming that users's machine is infected by worm or virus targeting your ActiveX, there's not much you can do.
I'd keep a checksum (or even a verbatim copy) of displayed text somewhere. Even if this program writes its own text, you'd be able to detect data corruption.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|