News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Clicking in specific areas

Started by savage, May 28, 2006, 02:59:15 AM

Previous topic - Next topic

savage

Quote from: Mark Jones on May 28, 2006, 09:31:41 PM
Quote from: savage on May 28, 2006, 08:22:39 PM
EDIT: sigh... tripod won't let me directly download from them from an anonymous referrer...

It worked for me out of the Sprint backbone in Chicago, USA. Nice example by the way. :U

Others have told me the same thing when I've posted stuff before.  How come I'm the only one who can't download my own stuff?? huh??  :lol

sluggy

It may be a little too late for me to reply now, but i will anyway  :8)

The way i would do this would be to create a custom control (window) for each key. Each control would be hooked to the same wndproc, that way you get identical functionality for each key/control. What you then do is create a struct for each key that contains its note and whatever other unique information it needs, and as you create each control you call SetWindowLong with the GWL_USERDATA flag to store a pointer to that control's custom struct.
So, each control is set up to go through the same click handler in the wndproc. In that click handler, call GetWindowLong to get the pointer to the custom struct, and you can use the info in that struct to generate the correct note etc.

I hope i have explained this well enough  :eek This method of doing it is very OO, and you actually end up with very little code. Less code means less chance of errors, and doing it in an OO way means you get consistent handling of all the controls. I used this method in a game which had several hundred tiles on the screen at once - all the tiles went through the same click handler, and i had a struct attached to each tile. And the performance was great  :U


PBrennick

Sluggy,
The explanation of this method proves that you can never be too late.  I like this method of yours very much.  It follows the idea I was presenting in the button method but has the benefit of being a lot more flexible and I would not be forced to work with the bounds of button generation.  Are you willing to throw together a small example that would create, let's say, 3 custom controls?

Paul
The GeneSys Project is available from:
The Repository or My crappy website

savage

Sluggy, if you didn't notice, I actually already already did exactly this and posted the program up here.

But it's good to have verification that I"m not heading the wrong direction.

PBrennick

Savage,
I missed that, also.  What I usually when I awaken is catch up on the thread and make notes of external links.  I make my comments and then I check external links.  Moving off the forum to external sites is always a bother to me as it increases my risk of exposure to bad scripts.  Some sites, I will not go to at all depending on the domain.  If the domain has a reputation of negative re-enforcement, I stay away.  I feel that tripod fits this definition.  Anyway, why don't you attach your zip to this board?

Paul
The GeneSys Project is available from:
The Repository or My crappy website

savage

Quote from: PBrennick on May 29, 2006, 06:44:14 AM
Anyway, why don't you attach your zip to this board?

Paul



Because I'm an idiot.   :dance:

[attachment deleted by admin]

Siekmanski

Hi Guys

Just finished the 2D example I promised to make.
Look at the source-code how I did it.

I made a piano bitmap with 3 octaves.
Then made a copy of it and gave every pianokey his own color,

key c-1 color 1
    c#1 color 2 etc.

pianomap.gif is that bitmap and is saved as 8-bit raw data.
Now we have some kind of a lookup-table for the pianokeys.

This method is fast and you can use all kind of shaped buttons.

Enjoy.... lets make some music.


greetings Siekmanski




[attachment deleted by admin]

savage

Quote from: Siekmanski on May 29, 2006, 08:39:06 PM
Hi Guys

Just finished the 2D example I promised to make.
Look at the source-code how I did it.

I made a piano bitmap with 3 octaves.
Then made a copy of it and gave every pianokey his own color,

key c-1 color 1
    c#1 color 2 etc.

pianomap.gif is that bitmap and is saved as 8-bit raw data.
Now we have some kind of a lookup-table for the pianokeys.

This method is fast and you can use all kind of shaped buttons.

Enjoy.... lets make some music.


greetings Siekmanski




:eek  :eek   :eek  :eek   :eek   :eek   :eek   :eek   :eek

:red  :thumbu  :thumbu  :dazzled:  :eek  :eek

How the...


Thanks for making me feel like a newb.
I will be quitting as a programmer now and go work at mcdonald's.

That just looks way too hard.
Lol.

sluggy

Quote from: savage on May 29, 2006, 06:28:12 AM
Sluggy, if you didn't notice, I actually already already did exactly this and posted the program up here.

But it's good to have verification that I"m not heading the wrong direction.
Hehe :) I didn't check your code before commenting  :red

Mark Jones

Beautiful example Siekmanski! :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08