Page 1 of 1

Creating Gui like buttons and Interface...

Posted: Wed May 28, 2003 12:25 pm
by darklordz
Updated for version 5.20

OK a Gui, using a SkinLib i found and imagegadgets.....
Download the demo http://www.balpoint.com/PlayaH.rar 50KB

How i did it?
I open a Window.

to move a window without a titlebar

Code: Select all

Select WindowEvent()
    Case #WM_LBUTTONDOWN
        ReleaseCapture_()
        SendMessage_(hWnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)
EndSelect
I use a window callback to detect imagegadget events....

Code: Select all

SetWindowCallback(@WindowCallback())

Procedure.l WindowCallback(WindowID, Message, wParam, lParam)
    ReturnValue = #PB_ProcessPureBasicEvents
    If Message = #WM_LBUTTONDOWN
        If WindowMouseX() > 5 And WindowMouseX() < 21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_SM, TBar_SM_Down)

        ElseIf WindowMouseX() > 258 And WindowMouseX() < 258+21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_MM, TBar_MM_Down)
            ShowWindow_(WindowID(),#SW_MINIMIZE)
        ElseIf WindowMouseX() > 278 And WindowMouseX() < 278+21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_XM, TBar_XM_Down)
            End
        EndIf
    ElseIf Message = #WM_LBUTTONUP
        If WindowMouseX() > 5 And WindowMouseX() < 21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_SM, TBar_SM_Over)

        ElseIf WindowMouseX() > 258 And WindowMouseX() < 258+21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_MM, TBar_MM_Over)

        ElseIf WindowMouseX() > 278 And WindowMouseX() < 278+21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_XM, TBar_XM_Over)

        EndIf
    ElseIf Message = #WM_MOUSEMOVE
        If WindowMouseX() > 5 And WindowMouseX() < 21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_SM, TBar_SM_Over)

        ElseIf WindowMouseX() > 258 And WindowMouseX() < 258+21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_MM, TBar_MM_Over)

        ElseIf WindowMouseX() > 278 And WindowMouseX() < 278+21 And WindowMouseY() > 5 And WindowMouseY() < 21 
            SetGadgetState(#TitleBar_XM, TBar_XM_Over)

        Else
            SetGadgetState(#TitleBar_SM, TBar_SM_Up)
            SetGadgetState(#TitleBar_MM, TBar_MM_Up)
            SetGadgetState(#TitleBar_XM, TBar_XM_Up)
        EndIf
    EndIf
    ProcedureReturn ReturnValue
EndProcedure
the above is an example of 3 imagegadgets....
the #TitleBar_XX Constants are image gadgets and their states are image handles....

Posted: Wed May 28, 2003 12:40 pm
by Berikco
I get header corrupt on the dowloaded demo :(

Posted: Wed May 28, 2003 1:12 pm
by Fred
Works fine here.. Nice work.

Posted: Wed May 28, 2003 2:30 pm
by blueb
:(
Berikco,

You're not alone! I get the same thing. I've used RAR for years and I like it a lot. Very stable.

--blueb

Posted: Wed May 28, 2003 2:44 pm
by darklordz
It was packed with winrar 3.20 it works fne for me tried it on 2 pc's

Posted: Wed May 28, 2003 2:46 pm
by Berikco
That's the problem, 2.80 does not read 3.20

Posted: Wed May 28, 2003 3:03 pm
by Froggerprogger
http://www.7-zip.org/
This Freeware-Packer can open it.

Very :P , but if I move the cursor from 'Minimize' to 'Close' ore vice versa, then both gadgets keep the highlighted state, not only the actual one.

Posted: Wed May 28, 2003 4:32 pm
by fsw
As always, with such selfmade GUI the event is fired when you press
ButtonDown instead of ButtonUp. :cry:

There has to go far more work into a GUI to have it act like normal applications. :wink:
Have fun improving your code :)

Posted: Wed May 28, 2003 8:35 pm
by darklordz
@Froggerprogger > That just a problem with definig coordinates i did this in a hurry...
@fsw if coded right the event can also be fired on button up.....!!!!!