|
I'm looking for suggestions for a Source Code Editor control, for quick & easy reuse.
I am not looking for an editor, I am looking for a control to embed in my application.
My environment is C++ - Win32/ATL/WTL; MFC might be OK.
The typical use case is small scripts (3rd party scripting language) to quickly try out something. I'm looking for basic features such as syntax coloring, Search&Replace, optional line numbers and whatever makes life handy. It does not need to be a fully fledged editor (we support external editors well enough already.)
Any suggestions?
modified 7-Oct-11 8:29am.
|
|
|
|
|
|
I'm looking for an embeddable control, not a standalone editor. I couldn't find anything on their site indicating that it's a reusable control.
|
|
|
|
|
|
Scintilla[^] is perfect for what you want
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
The one I posted about here[^] is just that.
"Scintilla is a free source code editing component. It comes with complete source code and a license that permits use in any free project or commercial product."
Here's the link again: Scintilla[^]
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
i have create the progress ctl in CwingSave class
and i have csave class for saving the data behind using another class Repair.
i have created the thread in Csave class .
the probles is that i am not able to update the progreass bar .
|
|
|
|
|
sarfaraznawaz wrote: the probles is that i am not able to update the progreass bar .
What progress bar? What thread owns it? If the primary thread owns the progress bar and the saving is being done in a secondary thread, then you simply need to post a message from the secondary thread to primary thread telling it to update the progress bar.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Pretty much sums it up... +5
|
|
|
|
|
Here is the bug report of the error.
main thread ($12e8):<br />
00508898 +010 accountant.exe Controls 4164 +1 TControl.SetVisible<br />
00410046 +05a accountant.exe firmatanimlari.cpp 42 +6 TForm3.Button2Click<br />
0050a87d +335 accountant.exe Controls 5143 +83 TControl.WndProc<br />
0050ae3a +086 accountant.exe Controls 5226 +9 TControl.Click<br />
004b5019 +031 accountant.exe StdCtrls 3574 +3 TButton.Click<br />
00414b4e +0b6 accountant.exe firmatanimlari.cpp 297 +9 TForm3.FormShow<br />
004e88bd +021 accountant.exe Forms 2994 +1 TCustomForm.DoShow<br />
004ed498 +0ac accountant.exe Forms 5002 +11 TCustomForm.CMShowingChanged<br />
0050a87d +335 accountant.exe Controls 5143 +83 TControl.WndProc<br />
0050f585 +49d accountant.exe Controls 7242 +101 TWinControl.WndProc<br />
004e9345 +551 accountant.exe Forms 3284 +125 TCustomForm.WndProc<br />
00717cb9 +059 accountant.exe DBAdvGrid 7730 +13 TDBAdvGrid.WndProc<br />
0050a42a +036 accountant.exe Controls 5018 +5 TControl.Perform<br />
0050eab4 +100 accountant.exe Controls 6970 +17 TWinControl.UpdateShowing<br />
0050eb41 +059 accountant.exe Controls 6989 +8 TWinControl.UpdateControlState<br />
00511a61 +03d accountant.exe Controls 8269 +3 TWinControl.CMVisibleChanged<br />
0050a87d +335 accountant.exe Controls 5143 +83 TControl.WndProc<br />
0050f585 +49d accountant.exe Controls 7242 +101 TWinControl.WndProc<br />
004e9345 +551 accountant.exe Forms 3284 +125 TCustomForm.WndProc<br />
0050a42a +036 accountant.exe Controls 5018 +5 TControl.Perform<br />
005088c4 +03c accountant.exe Controls 4168 +5 TControl.SetVisible<br />
004e8c39 +055 accountant.exe Forms 3099 +8 TCustomForm.SetVisible<br />
004eddbc +00c accountant.exe Forms 5331 +1 TCustomForm.Show<br />
0040544c +074 accountant.exe anamenu.cpp 124 +8 TForm2.FirmaTanmlar1Click<br />
0050ae3a +086 accountant.exe Controls 5226 +9 TControl.Click<br />
008c5615 +051 accountant.exe AdvGlowButton 2563 +5 TAdvCustomGlowButton.Click<br />
0050b3c4 +078 accountant.exe Controls 5362 +6 TControl.WMLButtonUp<br />
008c6214 +308 accountant.exe AdvGlowButton 2985 +102 TAdvCustomGlowButton.WMLButtonUp<br />
0050a87d +335 accountant.exe Controls 5143 +83 TControl.WndProc<br />
0050f585 +49d accountant.exe Controls 7242 +101 TWinControl.WndProc<br />
0050ec74 +034 accountant.exe Controls 7021 +3 TWinControl.MainWndProc<br />
0055f54c +014 accountant.exe classes 11572 +8 StdWndProc<br />
77762e3c +00a USER32.dll DispatchMessageA<br />
004f29ce +136 accountant.exe Forms 7651 +23 TApplication.ProcessMessage<br />
004f2a13 +00f accountant.exe Forms 7670 +1 TApplication.HandleMessage<br />
004f2cae +0a6 accountant.exe Forms 7754 +16 TApplication.Run<br />
004028b1 +111 accountant.exe accountant.cpp 99 +20 WinMain<br />
00a61918 +14c accountant.exe __startup<br />
7615ed6a +010 kernel32.dll BaseThreadInitThunk
cpu registers:
eax = 00000000
ebx = 03c64d80
ecx = 03cc0e10
edx = 00000000
esi = 004e889c
edi = 0012fdfc
eip = 00508898
esp = 0012f48c
ebp = 0012f498
stack dump:
0012f48c 9c 88 4e 00 06 00 00 00 - 00 00 00 00 b8 f5 12 00 ..N.............
0012f49c 4b 00 41 00 07 00 00 00 - 22 01 00 00 10 fb 4c 00 K.A.....".....L.
0012f4ac a0 58 c2 03 00 00 00 00 - 16 00 00 00 80 4d c6 03 .X...........M..
0012f4bc 10 0e cc 03 fc f5 12 00 - db 89 a5 00 f8 03 ad 00 ................
0012f4cc a0 f4 12 00 00 00 00 00 - 00 00 00 00 60 fb 4c 00 ............`.L.
0012f4dc 00 00 00 00 a0 58 c2 03 - a0 58 c2 00 f8 f4 12 00 .....X...X......
0012f4ec 53 11 4d 00 64 f8 12 00 - a0 58 c2 03 28 f6 12 00 S.M.d....X..(...
0012f4fc 80 a8 50 00 44 8c 4e 00 - a0 58 c2 03 d6 0b 01 00 ..P.D.N..X......
0012f50c 5f 18 00 00 6c f5 12 00 - d9 1f a2 74 00 00 00 00 _...l......t....
0012f51c 90 f6 12 00 47 00 00 00 - 90 f6 12 00 cc f5 12 00 ....G...........
0012f52c 01 00 00 00 90 f6 12 00 - 47 00 00 00 00 00 00 00 ........G.......
0012f53c 90 f6 12 00 00 00 00 00 - 70 f5 12 00 e7 c4 76 77 ........p.....vw
0012f54c d6 0b 01 00 47 00 00 00 - 00 00 00 00 90 f6 12 00 ....G...........
0012f55c 47 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 G...............
0012f56c e8 f5 12 00 80 f5 12 00 - 9c f5 12 00 d8 98 7b 77 ..............{w
0012f57c ef 61 76 77 e8 f5 12 00 - 54 f6 12 00 6e 12 58 00 .avw....T...n.X.
0012f58c 31 3e 58 00 10 00 00 00 - 06 00 00 00 a3 2f 58 00 1>X........../X.
0012f59c 9c 88 4e 00 e8 4f 4b 00 - 4a 59 4e 00 10 0e cc 03 ..N..OK.JYN.....
0012f5ac 10 0e cc 01 00 00 00 00 - 80 4d c6 03 c8 f5 12 00 .........M......
0012f5bc 40 ae 50 00 e8 4f 4b 00 - 80 4d c6 03 d8 f5 12 00 @.P..OK..M......
disassembling:
[...]
0050888b add esp, -8
0050888e push esi
0050888f mov [ebp-5], dl
00508892 mov [ebp-4], eax
00508895 4164 mov eax, [ebp-4]
00508898 > mov al, [eax+$57]
0050889b cmp al, [ebp-5]
0050889e jz loc_5088d1
005088a0 4166 mov eax, [ebp-4]
005088a3 mov si, $ffcd
005088a7 call +$7a754 ($583000) ; system.@CallDynaInst
[...]
The problem occurs while setting visible of Button6 I guess it says I try to use Button6 before it's created. While compiling the application there is no problem.This is a runtime error. Here is the surprise, if I change the header C++ Builder recogizes that the header is changed and if compile again after changing the headers the error goes away. There are a few VCL forms in my application which have changed recently. Every time I started the IDE I need to make a fake editing on their header files to get a problemless exe file. I guess there is bug but how do I get saved from this.
|
|
|
|
|
hello Friends
What is Best way to store Array of Dynamic Objects
I am creating a pointer for class A and Initializing 100 objects
And then again I am Initializing 200 objects.
What is Best way to store these arrays.
i used map like map<int,a*> But problem is coming that deleting array pointer is deleting from map also.
My Design Structure is like this
int size =2;
for(int i=0; i<size;i++)
{
A* objA = new A[100]
for(int j = 0 ; j<100;j++)
{
objA[j].var = TempVar;
}
mapA.insert(make_pair(i,objA));
}
But,i am not happy with this way to store array of objects in map .As I am using map as a storage that I can use anywhere in application,and bcoz of not deleting pointer it crashes sometimes.
Suggest me some better way.
Thanks & Regards
Yogesh
|
|
|
|
|
yogeshs wrote: and bcoz of not deleting pointer it crashes sometimes.
The first thing you need to do is find out why your program crashes and fix that problem. I have explained why you cannot delete the objects in your map and the same will hold true if you put them in a fixed array.
|
|
|
|
|
|
Can you use a vector object?
vector class reference[^]
Vector is sequence container.i need some key,data Container.
Linked list is also another option but i dont want to involve in that.
Any Other Ideas?
regards
Yogesh
|
|
|
|
|
I think what AnsHUMAN was implying is that the class std::vector would take care of the allocation and deallocation - it encapsulates the array object and thereby takes away the responsibility from you. You can achieve the same however by defining your own encapsulation: see my response for details.
|
|
|
|
|
yogeshs wrote: bcoz of not deleting pointer it crashes sometimes
Can you clarify that statement, please? Normally, the only abnormal behaviour you can get from not deleting stuff is memory leaks, and, as a result exceptions of the type std::bad_alloc , once you run out of memory. The former will not crash your program though, so may I assume it is the latter? if so, the first thing to do would be to catch that exception.
Apart from that, there's a couple of things you could improve:
1. Storing a map that uses an consecutive integer value as a key indicates that a simple array would do the job just as well, and probably better. The only exception would be if you need to be able to insert values at the start or in the midst of your set later, and you stored key values to specific objects that you want to be able to retrieve later. You haven't mentioned such a requirement, so my advice is to use a C-style array instead. Or, if you need to be able to later add or remove entries, use a std::vector .
2. The objA variable you use to create each entry does contain only one thing, but that thing is being allocated dynamically, on the heap. As you need to make sure this memory gets properly freed again when you no longer need this object, the best way is to make a simple class to hold that variable, and define it's constructor and destructor to automatically allocate and deallocate the memory, as appropriate. That way you no longer need to take care of that anywhere else in your code. See below for an example.
#include <iostream> // for std::cerr
#include <new> // for the definition of std::bad_alloc
class MyData {
private:
A* myobj;
public:
MyData(int size = 100) {
try { myobj = new A[size];
}
catch (std::bad__alloc& ba) {
myobj = 0; throw ba; }
}
~MyData() { if (myobj != 0) { delete [] myobj; }
}
};
int main() {
int error = 0;
MyData *arrayData = 0;
try { arrayData = new MyData[200]; }
catch (std::bad_alloc& ba) {
std::cerr << "Error - bad alloc: " << ba.what() << std::endl;
error = 1;
}
if (arrayData != 0) {
delete [] arrayData; arrayData = 0;
}
return error;
}
P.S.: As I've seen from a more recent response the first point I've raised may not apply to your problem, i. e. you may need a map after all. My point about creating a class to wrap that 100-A array still holds though.
Moreover, you've used a loop to initialize all your A objects. This is another thing you could improve: use your constructor A::A() to do that! If you didn't define one already, do so now:
class A {
A() {
var = TempVar; }
};
|
|
|
|
|
Thanks A lot,I will try as u suggest.
Regards
Yogesh
|
|
|
|
|
Hello
I want to ask one more Question regarding "Moreover, you've used a loop to initialize all your A objects. This is another thing you could improve: use your constructor A::A() to do that!"
I did this in the loop bcoz I am retreiving the size only in that loop.That object array size is not constant. that can also change for each loop.So,thats why i Initialized in the loop inspite of doing in constructor.
Is there any other idea to do this?
Regards
Yogesh
|
|
|
|
|
I suppose in that case, using a loop will be the most obvious solution. You should still define a constructor for A, but instead of allocating the array, just initialize the array pointer to 0, so you can be sure that pointer is at least valid.
You could still avoid the loop and do the allocation in your constructor, but that will take a bit more effort:
#include <iostream> // for std::cerr
#include <new> // for the definition of std::bad_alloc
class MyAllocatorHelper {
public:
virtual void* allocate() const = 0;
}
class MyArrayAllocator {
public:
static MyAllocatorHelper const* p;
static void* makeArray() {
return p ? p->allocate() : 0;
}
}
class MyData {
private:
A* myobj;
public:
MyData();
~MyData() { if (myobj != 0) { delete [] myobj; }
}
};
MyData::MyData() {
try { myobj = MyArrayAllocator::makeArray();
}
catch (std::bad__alloc& ba) {
myobj = 0; throw ba; }
}
class MyDataArray : public MyAllocatorHelper {
private:
MyData* the_array;
std::size_t current_index;
void* allocate() const; public:
MyDataArray(std::size_t size);
MyData* get(std::size_t index);
};
MyDataArray::MyDataArray(std::size_t size) : the_array(0), current_index(0) {
try { the_array = new MyData[size];
}
catch (std::bad_alloc& ba) {
if (the_array != 0) {
delete[] the_array;
the_array = 0;
}
throw(ba); }
}
void* MyDataArray::allocate() const {
A* result = 0;
std::size_t alloc_size = 0;
++current_index;
try {
result = new A[alloc_size];
}
catch (std::bad_alloc& ba) {
throw(ba);
}
return result;
}
int main() {
int error = 0;
MyDataArray* arrayData = 0;
try { arrayData = new MyDataArray(200);
}
catch (std::bad_alloc& ba) {
std::cerr << "Error - bad alloc: " << ba.what() << std::endl;
error = 1;
}
if (arrayData != 0) {
delete arrayData;
arrayData = 0;
}
return error;
}
I wrote this a bit in a hurry and didn't take the time to test it, there may even be typos. However, I hope even if this doesn't compile it might give you an idea of what I did here:
1. An abstract interface for allocating some unspecified data, which later gets implemented by the wrapper to your data array.
2. A 'static class' that your constructors can access without having to rely on parameters.
3. A local counter variable 'current_index' that keeps track of the number of allocations that have already taken place, implying the index of the data object within your array. You can use this counter to determine the correct size for that particular object in your array.
|
|
|
|
|
Hi!! I'd like to know if function WriteAllText is avalaible in a MFC project.
If not, ¿which other options are to save a text file? So that you can't use:
escritura << "Example";
Thanks!!
|
|
|
|
|
I'd like to help, but I'm not sure what you're asking. What is "WriteAllText"?
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
|
i52camam wrote: Okay, I'm sorry. WriteAllText is a function of the namespace System.IO:
And System.IO is part of the .NET framework, but MFC uses only native code.
If you need to work with files, MFC has the CFile[^] class.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
yes, there is such a thing.
the << operator can be used for such.
or you can use the "standard c" library. There are many ways to accomplish what is wanted.
I'll give you the C++ way.
#include "stdafx.h"
#include <fstream>
using namespace std;
int main() {
fstream file;
file.open("filename.txt");
string foo = "here's some text";
file << foo;
file.close();
return 0;
}
See fstream[^] docs.
If you want to use "MFC" there is CFile[^]
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Hi,
I've been using the CFile class unsuccessfully, cause the file doesn't get created. Here is my code:
void Guardar::OnBnClickedGuardar()
{
SaveToFile();
}
void Guardar::SaveToFile()
{
CString nombre=_T("\D:\Write_File.dat");
CFile cfile;
cfile.Open(nombre , CFile::modeCreate | CFile::modeReadWrite);
char pbufWrite[100];
memset(pbufWrite, 'a', sizeof(pbufWrite));
cfile.Write(pbufWrite, 100);
cfile.Flush();
}
Also, I have debugged the program and all the functions are called step by step.... so I don't know where is the problem
Thanks for all.
|
|
|
|