473,388 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to capture Mouse clicks and Keystrokes in a VB app

TC
Hello,

I need to build a very simple text editor. The requirement is that
the input screen should be divided into 'm*n' cells ('m' rows, 'n'
columns, with each cell of a fixed size). Whenever the user wants to
input text, he will click on one of these cells, and then enter the
text. The text should then be visible inside the cell.

From my very limited knowledge of VB, I plan to use the 'group box'
construct to denote one cell. Now, here is where I need your help.

1. How do I create 'm*n' 'group boxes' on the fly (some kind of a
nested for loop ?)

2. How do I know when a user has clicked on a 'group box' ?

3. For every 'group box', I need to allocate a buffer to store the
characters that the user has entered for that particular cell. How
can this be done ?

Thanks.

Oct 25 '06 #1
2 4999
In article <FE**********************************@microsoft.co m>,
TC@discussions.microsoft.com says...
Hello,

I need to build a very simple text editor. The requirement is that
the input screen should be divided into 'm*n' cells ('m' rows, 'n'
columns, with each cell of a fixed size). Whenever the user wants to
input text, he will click on one of these cells, and then enter the
text. The text should then be visible inside the cell.

From my very limited knowledge of VB, I plan to use the 'group box'
construct to denote one cell. Now, here is where I need your help.
A group box is for "grouping" related controls in a pretty frame. It
doesn't provide any support for text input. I think you want a textbox.
Or, if you want a "grid" of cells, use the DataGridView (.NET 2.0 only).
1. How do I create 'm*n' 'group boxes' on the fly (some kind of a
nested for loop ?)
Yeah, a nested for loop would work:

for x = 1 to m
for y = 1 to n
dim tb as TextBox = New TextBox()
tb.Location = new Point(20*x, 30*y)
tb.Size = new Size(20,30)
Me.Controls.Add(tb)
next y
next x
2. How do I know when a user has clicked on a 'group box' ?
The groupbox doesn't support a "clicked" event since it's just a
container control. If you had a textbox, capture the "Click" event.
3. For every 'group box', I need to allocate a buffer to store the
characters that the user has entered for that particular cell. How
can this be done ?
Just use a textbox and let the control hold on to the text. :)

--
Patrick Steele
http://weblogs.asp.net/psteele
Oct 26 '06 #2
TC
Thanks for the reply. Based on it, I have the following question.

"Patrick Steele" wrote:
In article <FE**********************************@microsoft.co m>,
TC@discussions.microsoft.com says...
Hello,

I need to build a very simple text editor. The requirement is that
the input screen should be divided into 'm*n' cells ('m' rows, 'n'
columns, with each cell of a fixed size). Whenever the user wants to
input text, he will click on one of these cells, and then enter the
text. The text should then be visible inside the cell.

From my very limited knowledge of VB, I plan to use the 'group box'
construct to denote one cell. Now, here is where I need your help.

A group box is for "grouping" related controls in a pretty frame. It
doesn't provide any support for text input. I think you want a textbox.
Or, if you want a "grid" of cells, use the DataGridView (.NET 2.0 only).
I need to write my own text handling controls. That's because I am
designing this editor to input text that can come in any combination. For
example, when the user types 'a', followed by a '/', followed by a 'b', my
editor should display it as 'a' sitting vertically above 'b'. I think the
Microsoft GDI routine DrawString() can be used to do this. So, basically for
each cell I will have to store a sequence of tuples of the form <x,y,cwhere
x and y are the coordinates of the point, and c is the character at that
point. A text box might not support this kind of a feature. If the
'groupbox' control does not allow me to capture keyboard/mouse interrupts
then what do I use. Is there any control which would offer me this free form
writing anywhere within a given cell.
1. How do I create 'm*n' 'group boxes' on the fly (some kind of a
nested for loop ?)

Yeah, a nested for loop would work:

for x = 1 to m
for y = 1 to n
dim tb as TextBox = New TextBox()
tb.Location = new Point(20*x, 30*y)
tb.Size = new Size(20,30)
Me.Controls.Add(tb)
next y
next x
2. How do I know when a user has clicked on a 'group box' ?

The groupbox doesn't support a "clicked" event since it's just a
container control. If you had a textbox, capture the "Click" event.
3. For every 'group box', I need to allocate a buffer to store the
characters that the user has entered for that particular cell. How
can this be done ?

Just use a textbox and let the control hold on to the text. :)

--
Patrick Steele
http://weblogs.asp.net/psteele
Nov 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Zaidan | last post by:
I am running Excel2000 under WIN98 2nd edition, and I am writing a VBA code (I will consider using javascript if I have to) that does the following, at the user command: 1- Start MS Explorer and...
3
by: Per | last post by:
Hi all, This may be a newbie question, but I can't find the answer anywhere. I want to make a capture of the screen, or a part of the screen, that contains the main portion of the form. Detecting...
1
by: Sakharam Phapale | last post by:
Hi All, How to capture Mouse Single click and mouse double click event on Commnad Button. I am doing as follows. Private void Button1_MouseUp(Object sender,...
3
by: Gunnar Syren | last post by:
I'm trying to implement a macro feature in my application by recording and playing back keystrokes. At first I thought it would be enough to catch KeyDown in my main form, but I soon realized that...
4
by: Venkatesh | last post by:
Hello All, I have an iframe in my main html and within iframe, I'm loading another HTML webpage. In my main html page, I've captured the mouse click event, by setting the "onclick" for <bodyof...
2
by: =?Utf-8?B?c25naWxi?= | last post by:
The WebBrowser control is described as exposing numerous public mouse events. See: http://msdn2.microsoft.com/en-us/library/ayestehw.aspx. many of the event are described as: "This event is not...
10
by: bern11 | last post by:
If Form1 opens Form2 modally, how do I capture clicks on Form1 when Form2 is open? I want to click on Form1 and read the mouse co-ordinates into Form2. Since Form2 is open modally, Form1...
1
by: P-GPS | last post by:
Hi, 1. I have a webbrowser control in a VB .NET (3.5) application. 2. I want to capture the event and call a function whenever the mouse is hovering over a hyperlink. How do I do this? 3. I...
4
by: Vighneswar | last post by:
Hi All Can anybody please suggest me in this regard that I need to capture the keystrokes on all the word processors (Ms Word, Excel .. Etc), text editors (Notepad .. Etc) and suggest nearer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.