Cursor control in Text Box
-
I like to simulate Mobile UI using Windows Forms. I want some pointer to implement following features, 1. How to display cursor(horizontal cursor "_" and vertical cursor "|") inside text box control 2. How to get cursor position and move the cursor. Some one can also suggest whether TextBox control is enough for the above implementation or whether i should go with RichTextBox control thanks
-
I like to simulate Mobile UI using Windows Forms. I want some pointer to implement following features, 1. How to display cursor(horizontal cursor "_" and vertical cursor "|") inside text box control 2. How to get cursor position and move the cursor. Some one can also suggest whether TextBox control is enough for the above implementation or whether i should go with RichTextBox control thanks
Is bing broken where you are?
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Is bing broken where you are?
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
bing = search engine Your questions have been asked 1000s of times before and a search will get you the answers quicker that asking a question in the forum. If you have not tried a search engine in the last 14 hours I suggest you do so. If bings is not working you may want to try google.
Never underestimate the power of human stupidity RAH
-
bing = search engine Your questions have been asked 1000s of times before and a search will get you the answers quicker that asking a question in the forum. If you have not tried a search engine in the last 14 hours I suggest you do so. If bings is not working you may want to try google.
Never underestimate the power of human stupidity RAH
Thanks for your reply. I posted this query after searching through net and going through codeproject. There are many features available for WindowsCE! I am working on WindowsForms. I am hardcore C Programmer, I am introduced to C++ because of MFC/Visual Studio to create gui to my back end C program library. I am switching over from MFC to windows forms as i am informed that WF is easy than MFC. I am learning Windows Form now, and i see examples for VB, C# and C++. I prefer to use C++ as i can manage and understand the same compare to other. I created Windows Forms project using following options: File->New->Project->VC++(main option)->Windows Forms Application in Visual Studio 2008 professional edition. I really dont know whether C# or C++ is used by default by the VS2008 while creating the template! I looked into this site http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor(VS.71).aspx my requirement is I wish to change the cursor based on button press inside the text control and back to default on clicking another button. I used following code. private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { // creating new cursor System::Windows::Forms::Cursor= gcnew System::Windows::Forms::Cursor("MyCur.cur"); // this should set a cursor for all TextBox inside the form System::Windows::Forms::TextBox::Cursor::set(mycur); //setting the focus to textBox1 textBox1->Focus(); } // to get default cursor private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { System::Windows::Forms::Cursor::Current = System::Windows::Forms::Cursors::Default; } Result: on button4 press, the whole form gets the new cursor. And the focus given to textBox1, with default cursor! on button5 press, it is not reverting back to default cursor.
modified on Tuesday, June 2, 2009 8:51 AM
-
Thanks for your reply. I posted this query after searching through net and going through codeproject. There are many features available for WindowsCE! I am working on WindowsForms. I am hardcore C Programmer, I am introduced to C++ because of MFC/Visual Studio to create gui to my back end C program library. I am switching over from MFC to windows forms as i am informed that WF is easy than MFC. I am learning Windows Form now, and i see examples for VB, C# and C++. I prefer to use C++ as i can manage and understand the same compare to other. I created Windows Forms project using following options: File->New->Project->VC++(main option)->Windows Forms Application in Visual Studio 2008 professional edition. I really dont know whether C# or C++ is used by default by the VS2008 while creating the template! I looked into this site http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor(VS.71).aspx my requirement is I wish to change the cursor based on button press inside the text control and back to default on clicking another button. I used following code. private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { // creating new cursor System::Windows::Forms::Cursor= gcnew System::Windows::Forms::Cursor("MyCur.cur"); // this should set a cursor for all TextBox inside the form System::Windows::Forms::TextBox::Cursor::set(mycur); //setting the focus to textBox1 textBox1->Focus(); } // to get default cursor private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { System::Windows::Forms::Cursor::Current = System::Windows::Forms::Cursors::Default; } Result: on button4 press, the whole form gets the new cursor. And the focus given to textBox1, with default cursor! on button5 press, it is not reverting back to default cursor.
modified on Tuesday, June 2, 2009 8:51 AM
I have not used C++ since before the advent of Windows Forms, so I would not venture to attempt to offer you any code snippets. However speaking in Windows Forms terms, each
TextBox
instance has its ownCursor
property and it is this that needs to be set. If you need to change the cursor for allTextBoxes
on aForm/Control
you will need to iterate over theControls
property of theForm/Control
and test if thecontrol
is aTextBox
and then set theCursor
property to the desired cursor. SinceTextBox
inherits theCursor
property fromControl
there is no need to cast before doing so. I hope that this helps, but if not perhaps someone with C++ skills will help you.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
I like to simulate Mobile UI using Windows Forms. I want some pointer to implement following features, 1. How to display cursor(horizontal cursor "_" and vertical cursor "|") inside text box control 2. How to get cursor position and move the cursor. Some one can also suggest whether TextBox control is enough for the above implementation or whether i should go with RichTextBox control thanks
It is called "caret", not "cursor".
• My personal 24/7 webcam • Zeta Test - Intuitive, competitive Test Management environment for Test Plans and Test Cases. Download now! • Zeta Producer Desktop CMS - Intuitive, very easy to use. Download now!
-
Is bing broken where you are?
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
It is called "caret", not "cursor".
• My personal 24/7 webcam • Zeta Test - Intuitive, competitive Test Management environment for Test Plans and Test Cases. Download now! • Zeta Producer Desktop CMS - Intuitive, very easy to use. Download now!