|
What does storagepointer point to; it should be the RichEditCtrl?
|
|
|
|
|
yep
this is at the start of my OninitDialog before Calling the CDailog::OnInitDialog
storagepointer = new CRichEditCtrl;
|
|
|
|
|
I have created a similar test (although not MFC), and it appears to work. Remember that the callback will not get called until the edit control is trying to reformat some text to fit in the window. I tested mine just by dragging the right hand edge to make the window narrower. As soon as a word needed to be broken, the callback got actioned.
|
|
|
|
|
Richard thanks for the help
let me explain my problem I am trying to dump data from my z/os machine on a editctrl the data has 0x0a ns 0x0d and 0x0c causing a break where I dont want to
I do have a 0x0a 0ad to break a line.
need to think If I can use the wordbreak to resolve this issue
thanks
|
|
|
|
|
I do not think that is what you need. The EDITWORDBREAKPROC function is only called at the point where the control needs to decide whether to split a word or not. Searching for line break characters is a different issue and will depend on exactly how you are trying to reformat it.
|
|
|
|
|
Richard
I have to think if there is a way to drive the callback proc before I display the data let me explain the data is in the following format
2E000 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX * * from the 2E000 till the first * is hex data in printable format so O know for sure there is no any 0x0a x0d or x0c line feed between the two * there might be
I am just trying to think if there is a way of drving the callback as from what I understand it gives the user the ability to decide when to line break need to think about it
thanks
|
|
|
|
|
But as I mentioned above, the callback is only actioned when the control is trying to update the display, and a word cannot fit in the existing space. If you do not register a callback then the control will use spaces between words and existing line break sequences.
Your issue quite different as far as I understand it, but it is not clear what you are trying to achieve in your text display.
|
|
|
|
|
I am trying to display storage from my Z/os Server in the following format a 32 bit address in printable format which is 8 bytes then 16 bytes of storage in printable format 4 groups 4 bytes separated by spaces then within * * the raw hex data at this point i would like to line break
I have to look at the streamin says
The control calls the callback function repeatedly, transferring a portion of the data with each call. just wondering if each call would be a line
need to think
|
|
|
|
|
|
Richard when while writing my debugger I was display the assembler source code in a richedit I marked off the end of line with /r/n Now I am at the point of display storage did the same
typically storage is displayed with printable portion to the left and raw hex data to the right I would mark off the end of each line with 0x0a 0x0d the problem when the raw hex data contains 0x0a 0x0d or 0x0c
I am not sure if you return to richedit with what you think is line if it will break that way have to think about this thanks for your help
|
|
|
|
|
Hi,
If you decide to modify the word/line breaking behavior then it might help to look at how Chromium does it[^].
Richard MacCutchan mentioned modification of the input stream to normalize the line breaks. I think it's worth exploring that idea.
Best Wishes,
-David Delaune
|
|
|
|
|
You should convert the raw data to its hex equivalent (like hex editors do it) so the line breaks do not affect the display.
|
|
|
|
|
thats what I am currently doing
thanks
|
|
|
|
|
Richard
Siad the wordline break is invoked only what he tried to resize it i.e. once It has been displayed and user narrows the richedit
If there is way to invoke the wordlinebreak proc before the display that would be helpful
thanks
|
|
|
|
|
I am not aware of any way you could do this, since there are no words that need breaking until they are displayed. You may need to consider other options, both of which require you to do all the display handling yourself:
1. Make your display a fixed width based on the font you are using and the amount of data you wish to display.
2. Rebuild the entire display whenever the Window is resized.
It may be possible to implement the above by subclassing the RichEdit control, although I have never done that in MFC.
|
|
|
|
|
Richard
My display is fixed width as it is Courier new I know that exact number of characters in the width of a line (wonder if ShowWindow(SW_HIDE) would drive edit editwordbreakproc)
I am just wondering if there is another way and causes line breaks other than 0x0a, 0x0d, 0x0c
I have to think about this
|
|
|
|
|
Hi friends! I am new to c++ and just went through the concept of Namespace.What I have understood about namespace till now is that "it is a region where identifiers can be declared in form of group".
But then I went through the following code somewhere on internet
Namespace identi
{
int a;
Class S
{
public:
int z;
float x;
}
}
So I am bit confused after seeing the definition of class S inside namespace.isn't it only a declarative region where we can only declare identifiers together in a group or can we define identifiers as well inside it? Just like we did with class S.Kindly someone please answer, would be so nice of you.
|
|
|
|
|
|
the main reason of why we use namespace identifier is classify our code in a bigger categories and parts. its useful to manage your libraries by "using namespaces". Imagine you can have many different name spaces in your code and every time you need you can use it. its helps you to choose smaller and more abstract names for your classes and functions.
for example you can have many Mathematic function and classes in a namespace like "Matrix". in that case you can have simple function names like "add" , "div", "mul" instead of "matrix_add" ,"matrix_dev" and ...
to use them in an specific part of your code you can use it in to ways ..
1:
Matrix.add(m1,m2);
Matrix.div(m3,m4);
2:
using Matrix {
add(m1,m2);
div(m3.m4);
}
also for defining classes and functions in a namespace you can do it like this ...
namespace Matrix {
void add(matrix a, matrix b){
...
}
void div(matrix a, matrix b){
...
}
void mul(matrix a, matrix b){
...
}
.
.
.
}
|
|
|
|
|
It seem like I remember that rich edit used to line break on CR/LF 0x0d + 0X0D now it seems either 0x0a 0x0c (form feed) of 0x0d (carriage return causes) causes a line break
Is there a way to look for a specific version of rich edit I means the class names for 1.0 thru 3.0 the doc says use RICHEDIT_CLASS which loads Riched20.dll
more so I remember that rich edit would only line break on CR AND LF not sure which version as I would like to use that version
|
|
|
|
|
|
Hi
here is my wordbreak function
int CALLBACK EditWordBreakProc(LPTSTR lpszEditText, int ichCurrent, int cchEditText, int code)
{
char FAR* lpCurrentChar;
int nIndex;
int nLastAction;
switch (code)
{
case WB_ISDELIMITER:
if (lpszEditText[ichCurrent] == 0x0a0d)
return TRUE;
else
return FALSE;
break;
}
}
Here is where I invoke it
fptrx = &EditWordBreakProc;
storagepointer->SendMessage(EM_SETWORDBREAKPROC, 0,(LPARAM) fptrx);
long numstream = storagepointer->StreamIn(SF_TEXT,STORAGESTREAM);
variable definition
funcptrx fptrx;
int CALLBACK EditWordBreakProc(LPTSTR lpszEditText, int ichCurrent, int cchEditText, int code);
typedef int (CALLBACK *funcptrx) (LPTSTR, int, int, int);
|
|
|
|
|
I am writing code in standard C for a microcontroller (STM32L) and I compile with GCC. I have a struct that contains a union and the union can be of different size:
struct MyStruct
{
int someInteger;
union
{
int smallMember[1];
int bigMember[1000];
} smallOrBigMember;
}; Is it possible for me to declare an object of MyStruct that only occipies 8 bytes of memory if I only intend to use the smallMember of that object?
|
|
|
|
|
No, you cannot. If you need a flexible size structure, the idiomatic solution is to add a zero size array at the end of the structure. Then, presumably, one of the fixed length fields tells you the size of the variable part. Something like this:
struct MyStruct
{
int small_or_big;
int variable_part[0]; };
struct MyStruct *ptr;
if (ptr->small_or_big == BIG_STRUCT)
{
ptr->variable_part[999] = some_value; }
When you allocate the structure you have to account for the variable part:
ptr_small = malloc(sizeof(MyStruct) + SIZE_OF_SMALL_PART);
ptr_small->big_or_small = SMALL_STRUCT;
ptr_big = malloc (sizeof(MyStruct) + SIZE_OF_BIG_PART);
ptr_big->big_or_small = BIG_STRUCT;
Mircea
modified 6-Mar-22 11:10am.
|
|
|
|
|
I have been using carriage return 0X0AD line feed 0A to break lines on Rich Edit using SF_TEXT until I noticed some of the data I am trying to Dump contains a 0x0d 0X0A causing an inadvertent line break
is there an another way to break lines
Thanks
|
|
|
|