Now I created a CRichEdit object, which is in single-line mode, what if I want to change it to multiline style, I wanna do all this in response to a ctrl message such as someone press one push-button.
Thx
A GetWindowLong()/SetWindowLong() combination maybe? Not sure if changing this specific style works though.
Use ModifyStyle:
richedit.ModifyStyle(0, ES_MULTILINE); // Adds multi-line style
richedit.ModifyStyle(ES_MULTILINE, 0); // Removes multi-line style
If it doesn't work, consider adding SWP_FRAMECHANGED as third parameter.
Related
It`s difficult to explain, better see images below.
When clicking within any part of empty line, cursor stays where I clicked:
And how it should behave:
Small notice, before updating it behaved normally, but after it changed.
Check what you have got here: Settings/Preferences | Editor | General. Make sure that Allow caret placement | After the end of line option is disabled.
I need a little help with my calculator program. I have created the code for the main buttons like the numbers 0-9 and the arithmetic operators to make it perform simple calculations.
What I'm having problems with right now is making the CE button work, after clicking the CE button I need the last entered character to be removed from the display label.
I have tried to adapt this code somehow, but it doesn't work:
lblResult->substr(0, lblResult->size()-1);
I know I'm doing somehting wrong here, can you please help me?
Thanks in advance
...Now that we know that lblResult is a System.Windows.Forms.Label, we can look at the documentation.
A Label has a Text Property, which is a String^ (i.e. a string reference).
For what you want to do, the Remove Method of String is appropriate. But note in the documentation it says that it "Returns a new string in which a specified number of characters from the current string are deleted." This means that it does not modify the string, but returns a modified copy.
So to change the label's text, we need to assign to its Text property what we want: the current string with all of the characters except the last:
lblResult->Text = lblResult->Text->Remove(lblResult->Text->Length - 1);
lblResult->resize(lblResult->size() - 1);
In this case you can use components Remove and Length methods.
Use the following code to access the components text:
component->Text
Than remove the last character of string by accessing Remove and component Length method
= component->Text->Remove(component->Text->Length - 1)
I hope you find this useful.
Just asking the obvious -- the whole statement is
*lblResult = lblResult->substr(0, lblResult->size()-1);
right?
I have looked at the following question:
How to comment out a block of Python code in Vim
But that does not seem to work for me. How do I comment code easily without resorting to plugins/scripts?
Use ctrl-V to do a block selection and then hit I followed by //[ESC].
Alternatively, use shift-V to do a line-based select and then type :s:^://[Enter]. The latter part could easily go into a mapping. eg:
:vmap // :s:^://<CR>
Then you just shift-V, select the range, and type // (or whatever you bind it to).
You can add this to your .vimrc file
map <C-c> :s/^/\/\//<Enter>
Then when you need to comment a section just select all lines (Shift-V + movement) and then press CtrlC.
To un-comment you can define in a similar way
map <C-u> :s/^\/\///<Enter>
that removes a // at begin of line from the selected range when pressing CtrlU.
You can use the NERD commenter plugin for vim, which has support for a whole bunch of languages (I'm sure C++ is one of them). With this installed, to comment/uncomment any line, use <Leader>ci. To do the same for a block of text, select text by entering the visual mode and use the same command as above.
There are other features in this such as comment n lines by supplying a count before the command, yank before comment with <Leader>cy, comment to end of line with <Leader>c$, and many others, which you can read about in the link. I've found this plugin to be extremely useful and is one of my 'must have' plugins.
There's always #ifdef CHECK_THIS_LATER ... #endif which has the advantage of not causing problems with nested C-style comments (if you use them) and is easy to find and either uncomment or remove completely later.
If I use Direct3D's DrawText, which behaves like the GDI counterpart, and I enable the DT_WORDBREAK formatting flag, it'll cut the text on apostrophes whenever the situation arises, which leaves many titles and text displays looking like a mess. For instance, it will appear as:
The Horseman'
s Head
When it should say:
The
Horseman's
Head
It seems unlikely considering the restrictive nature of the font handling functions, but is there any way of specifying it so that it only cuts text on white-space or when there's absolutely nothing that can be done?
You can wrap manually with the help of the GetTextExtentPoint32 function.
I've run in to this before, and the only solution is to write your own word wrapper, using DT_CALCRECT to measure the width of a given string. It's annoying and it does suck, but I've never seen an alternative.
I don't think so (i may be wrong). But you can set a "virtual" limit on a Width. Calculate line length (char_count*font_width) and make the jumps yourself. You can even add special char "\n", to insert your own jumps...
I am using a QTextEdit in my C++ GUI application, I use textEdit->append(byteArray); to add some text, unfortunately append() adds a new line character at the end that I would like to remove after each call of append(). I know I could use insertPlainText() which does not add a new line character but it uses a lot more memory when dealing with big documents.
Thanks for your help!
Since the documentation for QTextEdit::insertPlainText says
It is equivalent to
edit->textCursor().insertText(text);
I would assume that you can just do something like
edit->textCursor().deletePreviousChar();
If you need to you can first clear any selection with
edit->textCursor().clearSelection();