Creating Gui like buttons and Interface...

Share your advanced PureBasic knowledge/code with the community.
darklordz
Enthusiast
Enthusiast
Posts: 119
Joined: Wed May 21, 2003 1:44 pm
Location: Netherlands
Contact:

Creating Gui like buttons and Interface...

Post 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....
Last edited by darklordz on Wed May 28, 2003 2:43 pm, edited 1 time in total.
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

I get header corrupt on the dowloaded demo :(
Fred
Administrator
Administrator
Posts: 18224
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Works fine here.. Nice work.
User avatar
blueb
Addict
Addict
Posts: 1116
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Post 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
darklordz
Enthusiast
Enthusiast
Posts: 119
Joined: Wed May 21, 2003 1:44 pm
Location: Netherlands
Contact:

Post by darklordz »

It was packed with winrar 3.20 it works fne for me tried it on 2 pc's
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

That's the problem, 2.80 does not read 3.20
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post 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.
%1>>1+1*1/1-1!1|1&1<<$1=1
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post 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 :)
darklordz
Enthusiast
Enthusiast
Posts: 119
Joined: Wed May 21, 2003 1:44 pm
Location: Netherlands
Contact:

Post 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.....!!!!!
Post Reply