1. ? re: Win32lib an onClick (+fan mail)

Hello,
New to Euphoria, and I have to say I'm very impressed. Not only is it easy
to learn and fast, it is also small (very). And did I mention easy to learn?
Also, thanks to David Cuny for his outstanding Win32lib, even if it did cost
me the hours of midnight to 4 am last Saturday. Here's the ?......

I'm trying to write a program that puts lots of bitmaps in a W32 window. To
do this, I call a procedure when a button is clicked. Just for fun, I
decided to let it put 10k 16X16 BMPs in the window. That only takes a couple
of minutes, but I decided that I might like to stop it by clicking a second
button while it's calculating the 10k random positions and posting them to
the window.

Unfortunately, that doesn't work. The button sends the onLeftClick (or
whatever)  message to Windows, but it doesn't respond (it doesn't "click"),
and I have no idea what kind of code to use to interrupt this 10k iteration
WHILE loop. Can anyone help? (In the interest of space I won't post the code
unless it's needed. I know that seems dumb after the unabashed gushing
above, but I did want to say thanks. Too often thought, but too little
performed.)

Sherm

new topic     » topic index » view message » categorize

2. Re: ? re: Win32lib an onClick (+fan mail)

Hello SR Williamson (Sherm),


>Hello,
>New to Euphoria, and I have to say I'm very impressed. Not only is it easy
>to learn and fast, it is also small (very). And did I mention easy to
>learn?
>Also, thanks to David Cuny for his outstanding Win32lib, even if it did
>cost
>me the hours of midnight to 4 am last Saturday. Here's the ?......
>
>I'm trying to write a program that puts lots of bitmaps in a W32 window. To
>do this, I call a procedure when a button is clicked. Just for fun, I
>decided to let it put 10k 16X16 BMPs in the window. That only takes a
>couple
>of minutes, but I decided that I might like to stop it by clicking a second
>button while it's calculating the 10k random positions and posting them to
>the window.
>
>Unfortunately, that doesn't work. The button sends the onLeftClick (or
>whatever)  message to Windows, but it doesn't respond (it doesn't "click"),
>and I have no idea what kind of code to use to interrupt this 10k iteration
>WHILE loop. Can anyone help? (In the interest of space I won't post the
>code
>unless it's needed. I know that seems dumb after the unabashed gushing
>above, but I did want to say thanks. Too often thought, but too little
>performed.)
>
>Sherm

Well, if all you need to do is interupt a while loop then
all you need is the "exit" command which will immediately
exit any "while" or "for" loop. Now if the trouble is just
getting a button click to happen inside the loop that might
be a little harder, I guess you'll have to check for button
status in the loop. I dont know if Win32Lib provides a way
to check for a button's status other than by events or not.
I guess David Cuny would know.

later,
Lewis Townsend
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: ? re: Win32lib an onClick (+fan mail)

Hi Sherm,

The problem is that Win32Lib's main Windows Message Processing loop is
calling your routine to put up the bitmaps.  Since Euphoria isn't
multithreaded, you can't have another process watch for a cancel button, and
your "put up the bitmaps" routine can't watch out for the cancel button
because Win32Lib won't receive and process another windows message until
your routine returns. (That's my basic understanding of Win32Lib, David Cuny
please correct me if I am in error).  I think Win32Lib is excellent, but not
well suited to this sort of task.

The classic solution is to use timers; i.e. divide your routine to "put up
the bitmaps" into even chunks and put it in a routine called by a timer, so
that processing is periodically going back to Win32Lib.  Personally, I think
a more elegant solution would be to create your own Windows Message
Processing loop (see Bernie's Win32API in the archive) and run your routines
within it.

Best of Luck,
Wes

-----Original Message-----
From: Euphoria Programming for MS-DOS
[mailto:EUPHORIA at LISTSERV.MUOHIO.EDU]On Behalf Of Williamson, SR
Sent: Tuesday, February 15, 2000 1:22 PM
To: EUPHORIA at LISTSERV.MUOHIO.EDU
Subject: ? re: Win32lib an onClick (+fan mail)
Sensitivity: Private


Hello,
New to Euphoria, and I have to say I'm very impressed. Not only is it easy
to learn and fast, it is also small (very). And did I mention easy to learn?
Also, thanks to David Cuny for his outstanding Win32lib, even if it did cost
me the hours of midnight to 4 am last Saturday. Here's the ?......

I'm trying to write a program that puts lots of bitmaps in a W32 window. To
do this, I call a procedure when a button is clicked. Just for fun, I
decided to let it put 10k 16X16 BMPs in the window. That only takes a couple
of minutes, but I decided that I might like to stop it by clicking a second
button while it's calculating the 10k random positions and posting them to
the window.

Unfortunately, that doesn't work. The button sends the onLeftClick (or
whatever)  message to Windows, but it doesn't respond (it doesn't "click"),
and I have no idea what kind of code to use to interrupt this 10k iteration
WHILE loop. Can anyone help? (In the interest of space I won't post the code
unless it's needed. I know that seems dumb after the unabashed gushing
above, but I did want to say thanks. Too often thought, but too little
performed.)

Sherm

new topic     » goto parent     » topic index » view message » categorize

4. Re: ? re: Win32lib an onClick (+fan mail)

Hi Sherm,

I guess there must be some reason this won't work, or someone would have
suggested it, but here's what I would have tried:

Make an integer variable to serve as a true/false flag,
("Flag_StopDisplay"), & initialize it to 0; make a procedure to respond to
the "stop" button click event that sets the flag to 1; put a test for that
flag in your while loop, with "exit" if the flag = 1 (with reset the flag to
0 before the exit command).

I guess it wouldn't stop your BMP display in the middle of putting up a
specific picture, but I would think it would stop at the beginning or end of
one, and they're small enough that that might be serviceable??

Dan Moyer

Sherm wrote:

><snip>
>I'm trying to write a program that puts lots of bitmaps in a W32 window. To
>do this, I call a procedure when a button is clicked. Just for fun, I
>decided to let it put 10k 16X16 BMPs in the window. That only takes a
couple
>of minutes, but I decided that I might like to stop it by clicking a second
>button while it's calculating the 10k random positions and posting them to
>the window.
>
>Unfortunately, that doesn't work. The button sends the onLeftClick (or
>whatever)  message to Windows, but it doesn't respond (it doesn't "click"),
>and I have no idea what kind of code to use to interrupt this 10k iteration
>WHILE loop. Can anyone help?

new topic     » goto parent     » topic index » view message » categorize

5. Re: ? re: Win32lib an onClick (+fan mail)

On Tue, 15 Feb 2000 22:22:10 -0800, Dan B Moyer wrote:

>Hi Sherm,
>
>I guess there must be some reason this won't work, or someone would have
>suggested it, but here's what I would have tried:
>
>Make an integer variable to serve as a true/false flag,
>("Flag_StopDisplay"), & initialize it to 0; make a procedure to respond to
>the "stop" button click event that sets the flag to 1; put a test for that
>flag in your while loop, with "exit" if the flag = 1 (with reset the flag
to
>0 before the exit command).
>
>I guess it wouldn't stop your BMP display in the middle of putting up a
>specific picture, but I would think it would stop at the beginning or end
of
>one, and they're small enough that that might be serviceable??

From past experience... I think the problem with that solution is that your
button click does not get processed until you finish the loop that displays
your bitmaps.  (I think that was the original problem that started this
thread.)  When your loop finishes, then your button gets processed, but
then it's too late.  That's why a timer is required... it gives you the
break required to process that button click.  Unfortunately, you can't get
much speed using a regular timer.  Multimedia timers are supposedly much
faster but I haven't looked into them in depth.

-- Brian

new topic     » goto parent     » topic index » view message » categorize

6. Re: ? re: Win32lib an onClick (+fan mail)

Brian,

Oh!  So THAT'S why no one else suggested it! <cha-grin>

As a rank dilettante, I've been under the vague impression that WinMain
processed all the events specified in a program in a loop that stole slices
of processor time from the rest of the executing program to check on all the
events, so that no matter what else was happening in a program, any event
would be trapped relatively "quickly".  I thought that was the basic idea
about programming in relation to "events", that whenever an event occurred,
it could be noticed & therefore responded to.

Dan


Brian wrote:

>From past experience... I think the problem with that solution is that your
>button click does not get processed until you finish the loop that displays
>your bitmaps.  (I think that was the original problem that started this
>thread.)  When your loop finishes, then your button gets processed, but
>then it's too late.  That's why a timer is required... it gives you the
>break required to process that button click.

In response to my suggestion:


>>Hi Sherm,
>>
>>I guess there must be some reason this won't work, or someone would have
>>suggested it, but here's what I would have tried:
>>
>>Make an integer variable to serve as a true/false flag,
>>("Flag_StopDisplay"), & initialize it to 0; make a procedure to respond to
>>the "stop" button click event that sets the flag to 1; put a test for that
>>flag in your while loop, with "exit" if the flag = 1 (with reset the flag
>to
>>0 before the exit command).
>>
>>I guess it wouldn't stop your BMP display in the middle of putting up a
>>specific picture, but I would think it would stop at the beginning or end
>of
>>one, and they're small enough that that might be serviceable??

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu