473,654 Members | 3,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q on event-trapping during build-up of figure

I'm trying to find an equivalent of key-event trapping which is easy in
QBasic. Several of my programs build up a geometric figure with two
parameter line families, eg with two nested for..next loops; after that, the
process is redone, or moves on to a new position of the same figure. With a
slow system each build-up may take some time. But after, say the inner
for...next loop it's easy to scan for a key-event with an a$=inkey$ command
and a trapping-subroutine, so that the build-up may be short-cut.

In VB however I can't find any such quick event trapping procedure. I can
(try to) click any push-buttons I want whilst the figure is built up, it has
to be first completed before the program reacts. I read about a VB program
only responding to events in idle time, which can be "provoked" by some
function like DoEvents(). But nothing seems to work as I expect.

Can anyone suggest some way to achieve "immediate" event-trapping? Otherwise
it would make VB seem rather clumsy with respect to QB :( (-;

Guido
http://www.ping.be/wugi/qbasics.htm

Jul 17 '05 #1
4 2948
"Wugi" <gu*********@pl anetinternet.be > wrote in message news:<bs******* ***@reader08.wx s.nl>...
I'm trying to find an equivalent of key-event trapping which is easy in
QBasic. Several of my programs build up a geometric figure with two
parameter line families, eg with two nested for..next loops; after that, the
process is redone, or moves on to a new position of the same figure. With a
slow system each build-up may take some time. But after, say the inner
for...next loop it's easy to scan for a key-event with an a$=inkey$ command
and a trapping-subroutine, so that the build-up may be short-cut.

In VB however I can't find any such quick event trapping procedure. I can
(try to) click any push-buttons I want whilst the figure is built up, it has
to be first completed before the program reacts. I read about a VB program
only responding to events in idle time, which can be "provoked" by some
function like DoEvents(). But nothing seems to work as I expect.

Can anyone suggest some way to achieve "immediate" event-trapping? Otherwise
it would make VB seem rather clumsy with respect to QB :( (-;

Guido
http://www.ping.be/wugi/qbasics.htm


Put a doevents() cmd in your code, this allows all buttons, etc, to
respond to keypresses, clicks etc.

--Mike
Jul 17 '05 #2
On Fri, 26 Dec 2003 16:47:08 +0100, "Wugi"
<gu*********@pl anetinternet.be > wrote:
I'm trying to find an equivalent of key-event trapping which is easy in
QBasic. Several of my programs build up a geometric figure with two
parameter line families, eg with two nested for..next loops; after that, the
process is redone, or moves on to a new position of the same figure. With a
slow system each build-up may take some time. But after, say the inner
for...next loop it's easy to scan for a key-event with an a$=inkey$ command
and a trapping-subroutine, so that the build-up may be short-cut.

In VB however I can't find any such quick event trapping procedure. I can
(try to) click any push-buttons I want whilst the figure is built up, it has
to be first completed before the program reacts. I read about a VB program
only responding to events in idle time, which can be "provoked" by some
function like DoEvents(). But nothing seems to work as I expect.

Can anyone suggest some way to achieve "immediate" event-trapping? Otherwise
it would make VB seem rather clumsy with respect to QB :( (-;


The trick with that is to simulate the InKey$

Setting a Form's KeyPreview Property to True
- trapping and remembering any KeyPress
- then using DoEvents and returning and clearing any returned key
Should give you a reasonable simulation of InKey$

Personally I would stick all the Controls on the Form in a Frame, and
disable that, to prevent unwanted Clicks

Jul 17 '05 #3

"Wugi" <gu*********@pl anetinternet.be > wrote in message
news:bs******** **@reader08.wxs .nl...
I'm trying to find an equivalent of key-event trapping which is easy in QBasic. Several of my programs build up a geometric figure with two
parameter line families, eg with two nested for..next loops; after that, the process is redone, or moves on to a new position of the same figure. With a slow system each build-up may take some time. But after, say the inner
for...next loop it's easy to scan for a key-event with an a$=inkey$ command and a trapping-subroutine, so that the build-up may be short-cut.

In VB however I can't find any such quick event trapping procedure. I can (try to) click any push-buttons I want whilst the figure is built up, it has to be first completed before the program reacts. I read about a VB program only responding to events in idle time, which can be "provoked" by some function like DoEvents(). But nothing seems to work as I expect.

Can anyone suggest some way to achieve "immediate" event-trapping? Otherwise it would make VB seem rather clumsy with respect to QB :( (-;

Guido
http://www.ping.be/wugi/qbasics.htm


This sort of thing:

Option Explicit

Private mStop As Boolean

Private Sub Command1_Click( )
Dim n As Long
Dim j As Long
Dim x As Double

Command1.Enable d = False
Command2.Enable d = True
mStop = False
DoEvents

For n = 1 To 10000
For j = 1 To n
'do something
x = Sin(j / n)
Next j
DoEvents
If mStop Then
Exit For
End If
Next n

If mStop Then
MsgBox "Command1 cancelled"
Else
MsgBox "Command1 finished"
End If

Command1.Enable d = True
Command2.Enable d = False

End Sub

Private Sub Command2_Click( )
mStop = True
End Sub

Jul 17 '05 #4
Wugi :
I'm trying to find an equivalent of key-event trapping which is easy in
QBasic. (...)
Thanks to all repliers!
DoEvents is working fine, not by itself only because it does not branch by
itself (or quit the loop) to, eg, reinitialising the process.
But together with a control flag set at each control event, and unset at
(re-)starting the process, it works fine: "DoEvents" traps the events and
the flag then allows rebranching the process ....

Happy New Year to all!

(bis) Guido
http://www.ping.be/wugi/qbasics.htm


Jul 17 '05 #5

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

Similar topics

0
7035
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
18
2877
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
8
6083
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that uses message queues to pass pointers to Events between threads. In my app there are simple events that can be defined using an enum (for example an event called NETWORK_TIMEOUT) and more complex events that contain data (for example an event called...
6
14901
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function keypress() {
3
12120
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
6
1870
by: vbMark | last post by:
If I have a control, for example a CheckedListBox, how do I add and event to code, for example that a box has been checked by the user? Thanks
2
4984
by: Alex Sedow | last post by:
Why interface-event-declaration does not support multiple declarators like event-declaration? Grammar from C# spec: variable-declarators: variable-declarator variable-declarators "," variable-declarator variable-declarator:
7
390
by: Charles Law | last post by:
I may have asked this before, but what is the purpose of both these functions? Is there a time when one should be called over the other? Does one supersede the other, or do they both have their time and place? TIA Charles
15
21349
by: prabhdeep | last post by:
Hi, Can somebody explain, why in following code, i get "event not defined" error funcTest(sMenu) { doument.getElementById('id1').addEventListener('mousedown', function(){ click(sMenu, event); }, false); }
5
4528
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the onmouseleave / onmouseout event I've attached to my hidden drop down (in this case an <ul>), is not firing correctly. It seems that when the mouse enters the ul it fires the mouseleave event. The problem is in the hideMenu2(e) function. I'm copying...
0
8285
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.