|
I think there's no easier way, except maybe using CRichEditCtrl.
|
|
|
|
|
You can generate a project to do this in Visual Studio.
Almost all point and click (a tiny bit of typing).
Use the Add new project dialog -
Choose MFC application, give it a name
Do NOT choose Unicode option
Choose doc/view support and pick SDI or MDI.
Change the app file types/extensions to "Text", "txt", etc.
In the generated classes tab, change the view base class to CEditView
Build the project - you have a working text editor.
Edit the menu resource and add a "Find..." item to the "Edit" popup (give it the id "ID_EDIT_FIND")
Build the project - you now have text search capability.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I tried that, but the problem is that when i press the button search and let's say that searched word was "mfc", then in one click all mfc should be highlighted in the whole text.
I hope you understood what I need to achive. Me and my english language......
thanx
|
|
|
|
|
I thought so, but I thought I'd throw that out there just in case.
As others have mentioned, you'll need to render the text yourself or use a richedit control.
Either way you'll need to search the text and keep track of where the found items are.
If you use a richedit control, the control will do the rendering for you - all you need to do is
change the text color of all the found items.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How do I keep track of where the founded words are exactly?
I used the SetWindowText to display the text and it works.
Do you have any idea how ti keep track of the founded words?
p.s. yes, i use now RichEditBox
|
|
|
|
|
Mark Salsbery wrote: Do NOT choose Unicode option
Now that's a refreshing change.
And I thought I was the only one.
|
|
|
|
|
LOL I must admit, using a Unicode build in that case required extra steps that
I was way too lazy to figure out (for free).
It was just a 3 minute text editor solution.
Cheers!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I was little slow on the draw to offer solution but since I am working on similar stuff here is my 2 cents worth.
I ended up replacing CEditCtrl with CRichEditCtrl.
The color change is not too difficult. Here are my test functions straight from the MS documentation.
void CCC_RichEdit::OnReplaceAll( LPCTSTR lpszFind,
LPCTSTR lpszReplace, BOOL bCase, BOOL bWord )
{
int m_nNumReplaced;
CWaitCursor wait;
// no selection or different than what we are looking for
if (!FindText(lpszFind, bCase, bWord))
{
CRichEditView::OnTextNotFound( lpszFind );
return;
}
GetRichEditCtrl().HideSelection(TRUE, FALSE);
m_nNumReplaced = 0;
do
{
// change text color
OnCharUnderline();
//GetRichEditCtrl().SetBackgroundColor(FALSE, RGB(155,0, 0));
GetRichEditCtrl().ReplaceSel(lpszReplace);
m_nNumReplaced++; // Record the number of replacements
} while (FindTextSimple(lpszFind));
GetRichEditCtrl().HideSelection(FALSE, FALSE);
}
void CCC_RichEdit::OnCharUnderline ()
{
CHARFORMAT cf;
cf = GetCharFormatSelection ();
if (!(cf.dwMask & CFM_UNDERLINE) || !(cf.dwEffects & CFE_UNDERLINE))
{
cf.dwEffects = CFE_UNDERLINE;
}
else
cf.dwEffects = 0;
// change text color
cf.dwMask = CFM_UNDERLINE |CFM_COLOR ;
cf.crTextColor = RGB(255,0, 0);
SetCharFormat (cf);
}
This code does not change background color, work in progress.
Few observations - it seem that CFE_AUTOCOLOR is not set as default and does not have to be removed to make color changes.
Right now I cannot make "regular" pop up to work.
My question to the group - where is the documentation stating that double click on text selects it? Obviously I need to "override" that pretty useless action.
Thanks guys. Very helpful discussion.
|
|
|
|
|
hello,
How can i open a text file i excel using a schell command in c++.
if there is another it is ok.
10x regards
dghdfghdfghdfghdgh
|
|
|
|
|
ellllllllie wrote: How can i open a text file i excel using a schell command in c++.
Read the "Shell" API documentation. Note, it is NOT "Schell", you won't find it using that.
ellllllllie wrote: if there is another it is ok.
There is also the Excel Object Model. Again you should read the documentation
|
|
|
|
|
|
Isnt it "excel.exe" - sorry if I am wrong :p
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
BSoD during a Win98 presentation
|
|
|
|
|
it isn't important: using ShellExecute you can open what file you want with the application you want (if it can). Look to its help.
Or explain more details if it doesn't help.
Russell
|
|
|
|
|
Hello. I have this DLL that is used by three programs. Now, I was requested to modify program1.exe and the DLL, without --of course-- affecting program2.exe and program3.exe. Now, I made changes in both program1.exe and the DLL. To this one, I added other classes and functions. The question is, do I have to recompile program1.exe and program2.exe?
AFAIK, I don't have to recompile since it is a dynamic-linking library... but, just to be sure.
Thanks in advance.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
Generally, you do have to recompile if you want to be safe. However, unless you have changed the interfaces of those classes that used to be in the DLL before your modifications, you should run well without recompiling. Again, there are cases when this is not true. One example is if you access functions in that DLL by their ordinals - add or remove a function and you're probably in trouble.
Bottom line - you can never be 100% sure (that's why COM is better than regular DLLs), but you definitely may try leaving those executables as they are. Test empirically. If it works for you, it'll work for your users also.
|
|
|
|
|
Generally, no. If your changes added new function exports and did not change the ordinals of the existing ones, or if the other EXE's link functions by name and not ordinal, you should be OK.
Not so sure if you exported a new data item (variable), however...
Changing the binary layout of anything that is already being used by the DLL and EXEs may cause problems as well, because when the EXEs were compiled, they were built to expect a certain binary/size of any objects used in/by/from the DLL.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hello,
could someone help me to find a way to write an MDI application that draws lines with variable degree angle, the choice of the angle should be set in the same application?
Thanks a lot.
a novice in programming .
|
|
|
|
|
|
Thank you Maximilien!
ooops, really complicated...
I got older version of VS (vs2003.net), it is impossible to load the sample created with VS2005.net
|
|
|
|
|
if angle is given, the radius R and the start point too (X0,Y0) , then
X=X0+R*cos(angle);
Y=Y0+R*sin(angle);
where (X,Y) is the end of the segment.
CDC::MoveTo(X0,Y0);
then
CDC::LineTo(X,Y)
Russell
|
|
|
|
|
Thank You Russel for your reply,
in this way I should know which the radius for every set of angle?
I hope to be more clear, the application will be filled only with starting Y point and finish Y point, in the way that setting the angle e.g.30 degree, the line will be shown with unknown or variable X point on the graph, depending on the degree angle.
Is it affordable?
thanks again
|
|
|
|
|
omnimny wrote: Thank You Russel for your reply
omnimny wrote: in this way I should know which the radius for every set of angle?
Yes, I was thinking that the radius for you was constant (you haven't specify that) ....
omnimny wrote: the application will be filled only with starting Y point and finish Y point, in the way that setting the angle e.g.30 degree, the line will be shown with unknown or variable X point on the graph, depending on the degree angle.
Then simply you have fixed Y1 and Y2 , now you have to find X1 and X2 .
I assume that X1 is known, and it is given an angle .
Then simply:
X2=X1+(Y2-Y1)/tan(angle)
Russell
|
|
|
|
|
Thank you Russell,
I tried to apply your formula, but I know I need to study more c++, I am extremely novice, and really I m not able to get it out.
No problem with excel, it works, but I added X2=X1+(Abs(Y2-Y1))/tan(angle) in the way to get positive space consuming on the right of Y axes, because if I got a series of yn and I want to trace all the lines, in the case yn <= yn-1 , xn becomes less than xn-1 (without Abs value of y2-y1), giving out a bad picture.
Ciro
|
|
|
|
|
Russell
|
|
|
|
|
Hi,
In my applications images are displayed (and for example rotated) with the help of GDI+. I store the image (there is only 1 displayed ) like this:
Gdiplus::Image * m_image;
I draw it on the screen with this line:
graphics.DrawImage(m_image, x, y, size_x, size_y);
Now i wanted to zoom in and out of the picture with the help of a Slider Control. From 100% to 1600% (1x - 16x). I tried it in different ways but none had worked. Sometimes I don't see any change of the image on the screen at all and sometimes the application crashes.
Isn't that the correct way?:
Graphics * graphics = Graphics::FromImage(m_image);
graphics->ScaleTransform(3.0f, 1.0f);
Any ideas?
Thx, Shi
|
|
|
|