Re: Clickable windows areas

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message -----
From: "Evan Marshall" <evan at net-link.net>
To: "EUforum" <EUforum at topica.com>
Subject: Clickable windows areas


>
> Is there an easy(+ or -) way to make certain areas of a window clickable?
> I have an image of a piano keyboard and I'd like to be able to make the
> keys clickable.
> I could use an onMouse event and check to see if the mouse was in the
> area of a certain key, but I am hoping there is an easier way.
>

Hi Evan,
yes there is an easy way to do this. You can create a child window that only
has a border and detect clicks in that. Here is an example:

------------------
include win32lib.ew
without warning

constant w1 = createEx(Window, "Test", 0, 0, 0, 600, 400, 0, 0),
         sb = createEx(StatusBar, "", w1, 0, 0, 0, 0, 0, 0)

sequence PKeys
integer x,y,z,h,w

procedure click_PKeys(integer self, integer event, sequence parms)
    integer n

    n = find(self, PKeys)
    setText(sb, sprintf("Key ID %d, #%d", {self, n}))

end procedure

PKeys = repeat(0, 88)
w=45
h=34
x = 5-w
z = 0
for i = 1 to 11 do
    x += w
    y = 5-h
    for j = 1 to 8 do
        y += h
        z += 1
        PKeys[z] = createEx(Window, "", w1,
                        x, y, w, h, {WS_VISIBLE,WS_CHILD,WS_BORDER},0)
    end for
end for
setHandler(PKeys, w32HClick, routine_id("click_PKeys"))

WinMain(w1, Normal)

---------
Derek

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu