I cannot let to run OnKillFocus if control has no valid value, because OnKillFocus is too late. It is out of my control.
Let me show you some example:
I have a toolbar also. If somebody presses toolbar button OnCommand is running. Let say it is saving the document. Before saving I have to recalculate it and then save. Recalculating depends on the values in Edit. If Edit is not valid I have wrong calculations. Unfortunately pressing this toolbar buton doesn't cause KillFocus for my Edit. I have to use SetFocus to the edit's parent in order to make KillFocus for my edit to run, before I make recalculation. I don't like this solution.
I have many similar problems with validating data in OnKillFocus, so I need to handle all actions before OnKillFocus and before OnLButtonDown, OnCommand, etc of given buton. I do not want to change all possible handlers in my app so I choose PreTranslateMessage.
Sometime I return TRUE in PreTranslateMessage for example in order to not let the app for saving document, if user is in serious trouble with his already typed data.
Unfortunately I cannot use OnChange. It is to early to disturb user. I have to wait untill user finishes typing. EN_CHANGE is sent after each pressed key and I cannot save data from control to internal buffer during typing. I want to do it, if user decides to leave edit control.
I have also investigated this MSG *pMsg deeper and it occured that: If I let pumping messages (f.e with modal messagebox), I always have to return TRUE in PreTranslateMessage. Saving first message and forwarding it at the end has no sence, because the whole messaging process is disturbed any way.
Here is example of situation, for which my solution with saving *pMSG won't help:
WM_LBUTTONDOWN -> WM_LBUTTONUP pair is very sensitive here.
If I put messagebox between WM_LBUTTONDOWN and WM_LBUTTONUP in PreTranslateMessage it causes WM_LBUTTONUP to run for mouse point from the [OK] button on the messagebox and not for the original coordinates. So code from CFirstClickedArea::OnLButtonUp() will not be run.
So I think, I have to return always TRUE and I have no choice, if I want to use PreTranslateMessage with DoModal.
I think you are just making your program far more complicated than necessary. Using either EN_CHANGE or EN_UPDATE means that you can trap illegal content at any point. This will not have any effect on the user's typing unless they enter an incorrect character.
This program is already complicated Now I am trying to avoid crashes xD
I could use EN_CHANGE, if I could prevent just typing.
But what about pasting with ctrl + v illegal text? Should I delete it in EN_CHANGE automatically?
Other case is, that I have to also read data from editable controls, put it to internal buffer and set "Modified" flag for saving database record later. If data is illegal, I cannot put it to the buffer and set this flag. For simple edits it os ok. But there are also RichEditCtrl controls with OLE and a lot of text. I do not want to copy all text with OLE to the buffer each time EN_CHANGE comes.
In my opinion there is no simple lightweight and nice MVC gui library for C++ in general, but if you want one Qt is probably the best in terms of design and tooling. What I don't like in Qt that it needs code generation and uses the over-hyped signal-slot mechanism (why don't we just use pure listener interfaces for events?) and Qt is much more than a simple gui library, its a large application framework with lots of libraries. When I used it a few years ago the layout mechanism was more complicated than that of Delphi/.Net (I think simple anchoring does the job in 99% of cases).
We used in the past Crystal Reports 8.5 with Dev Studio 2003, but because of our customer we must change now to CR 2011 and Dev Studio 2010, but CR 2011 doesn't support the API. We already downloaded the files which a necessary for the Integration from the SAP Homepage and installed it.
But there doesn't exist any example how to use it in C++/MFC. Has anyone already expierience with this and can give us some informations or an example source code?
I want to create 4 dimensional array, in that first three dimenstional are fixed size and the final index will be on 0 to N-numbers.
For eg, double array[NOT FIXED].. So I cant create statically, because the index size are more. Also I have tried 4 dimenstional vector, but its giving 2 problem.
(i) I am storing 4th dimenstion size is more than vector.max_size()
(ii) Storing and Retrieving its more time in vector
So Please let me know, if any other solution to store large array which is 3 index is FIXED and final one is not FIXED?
Looking for answer from anyone..
Where '#' means a change in the first index and '|' is a change in the second index, while the 3rd index just moves 1 byte. Because of this memory layout you can make only the first dimension resizable if you are using a pointer instead of a fixed size static array. If you wanted to resize some other dimensions then you should insert bytes in many places but resizing the first dimension means just adding memory at the end of you currently allocated memory, or maybe shrinking the current storage. The above char my_array could be allocated dynamically in the following way:
ArrayType* p = new ArrayType;
p = 0;
// If you want to resize the first dimension later:
ArrayType* q = (ArrayType*)malloc(sizeof(ArrayType)*4);
q = (ArrayType*)realloc(q, sizeof(ArrayType)*5);
q = 1;
Note that indexing into p and q are very fast like it is in case of static arrays and the occupied memory is 1 big chunk of continuous area. If you need just 1 resizable dimension then you can go with this technique because it really doesn't matter which dimension has this resizable trait. Lets say you make a 2 dimensional array because you want to store additional data to specific X and Y coordinates. If you need resizable 'Y' dimension then you address the array this way: [Y][X] but if you need resizable 'X' dimension then you simple index this way: [X][Y]. The same applies to multiple dimensions, it really doesn't matter which index do you use for different things, the only 2 things it can screw up is the memory layout of items (cache misses) and the readability of the source code - but sometimes you have to sacrifice readability if you are optimizing because this kind of thing is something that smells like optimization.
I am achieving this using vector(vector(vector(vector(double)))) dBuffer(....);
As of now I am using vector[UnknownSize].
UnknownSize will be decided on run time. I cant create the memory for final size. Because the final index value it will come splited way. For eg, one iteration it will come 100 values, after some iteration it will come 150 values.. For that I cant create the pointer to store for 100,150,etc... So i need use some STL..
Pls suggest me which STL is useful... Currently i am using 4D vector. But its execution time is more.
If your only problem would be an array with one dynamic dimension, you could try this:
That will create an array of 125000 double vectors of dynamic size. The statical allocation will not be a problem, and the time required for the dynamic allocation will be proportional to the actual number of elements. The only performance problem will be the deallocation - whenever that array runs out of scope, your program will take a considerable amount of time. With 125000 arrays, expect the deallocation to run for anything between a couple of seconds and a few minutes!
jothivel k wrote:
(i) I am storing 4th dimenstion size is more than vector.max_size()
If I understand this comment correctly, you are trying to statically store data that exceed the address space of your application! If so, the answer is simple: you can't do that! What you need is a database! Try your luck with MySQL or google for another database library.
when i extracted bit fields from bit map i got the fields 3,11,24,41,42 in which field 3 and 11 are in N6 format, field 24 is in N3 format and field 41,42 are in ANS format..
I have gone through many reference sites of iso 8583 message format but i did not how can send the data..
whether i should convert the fields which are in N6 to BCD.
whether i will have to send bit field as it is or i need to change it also in BCD..