Help needed

Just starting out? Need help? Post your questions and find answers here.
Hydrate
Enthusiast
Enthusiast
Posts: 436
Joined: Mon May 16, 2005 9:37 pm
Contact:

Help needed

Post by Hydrate »

I have just started with purebasic, and i just thought i had the media player example cracked, when i tried to add clickable buttons to it for more user interactment.(buttongadgets). But i just cant seem to get this to work, could someone post a basic example of :

Code: Select all

If the left button is pressed on this gadget, show this text
Just so i have something to work with.

Thank you.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Which media player example are you tinkering with?

Check that the program is opening a window (as opposed to a screen) before you attempt to place a button etc. I don't know much about sprites and screens and such like, but I don't think you can mix standard Windows controls with them.

Someone will correct me if I'm wrong here! :)

Welcome to Purebasic btw.
I may look like a mule, but I'm not a complete ass.
Hydrate
Enthusiast
Enthusiast
Posts: 436
Joined: Mon May 16, 2005 9:37 pm
Contact:

Post by Hydrate »

Thanks, and exactly what im trying to do is get it so that if the button(gadget) is pressed then the game does something, like play the loaded movie file or put some text on the screen or create a new window, just something simple like that. I am using the media example that basicly lets you open the file on startup, and then just plays the file with no control over anything, i want to change it to have a button or two, so an example of one would really help, it doesnt necessarily have to be for a media player, just and example with a window, one button in it that uses the messagerequester to say "you clicked this". That would help me very much, thank you.
Garfield9992003
User
User
Posts: 15
Joined: Tue Apr 26, 2005 8:13 am

Post by Garfield9992003 »

Like this?

Code: Select all

; MessageRequester Demo 
; 20. Jan. 2003 by Ingo Turski

If OpenWindow(0, 235, 10, 550, 290, #PB_Window_MinimizeGadget | #PB_Window_TitleBar, "MessageRequester-Demo")

  If CreateGadgetList(WindowID())
    
    Button=ButtonGadget(0,10,10,150,24,"#MB_ICONSTOP") 
    Button=ButtonGadget(1,200,10,150,24,"#MB_ICONERROR") 
    Button=ButtonGadget(2,10,40,150,24,"#MB_ICONHAND") 

    Button=ButtonGadget(3,10,100,150,24,"#MB_ICONQUESTION") 

    Button=ButtonGadget(4,10,160,150,24,"#MB_ICONASTERISK") 
    Button=ButtonGadget(5,10,190,150,24,"#MB_ICONINFORMATION") 

    Button=ButtonGadget(6,200,260,150,24,"#MB_ICONWARNING") 
    Button=ButtonGadget(7,10,260,150,24,"#MB_ICONEXCLAMATION") 

    Button=ButtonGadget(8,390,10,150,24,"0") 
    Button=ButtonGadget(9,390,70,150,24,"#MB_OKCANCEL") 
    Button=ButtonGadget(10,390,130,150,24,"#MB_YESNO") 
    Button=ButtonGadget(11,390,160,150,24,"#MB_YESNOCANCEL") 
    Button=ButtonGadget(12,390,220,150,24,"#MB_RETRYCANCEL") 
    Button=ButtonGadget(13,390,260,150,24,"#MB_ABORTRETRYIGNORE") 

    TextGadget(14, 247, 117, 56, 56, Chr(10)+"Result" , #PB_Text_Center | #PB_Text_Border)

    Repeat
      EventID.l = WaitWindowEvent()
      If EventID = #PB_Event_CloseWindow
        Quit = #True
      ElseIf EventID = #PB_Event_Gadget 

        Select EventGadgetID()
        Case 0 
          Result = MessageRequester("MessageRequester-Demo", "Icon (X) : Stop", #MB_ICONSTOP)
        Case 1
          Result = MessageRequester("MessageRequester-Demo", "Icon (X) : Stop (ab NT4/95)", #MB_ICONERROR)
        Case 2
          Result = MessageRequester("MessageRequester-Demo", "Icon (X) : Stop", #MB_ICONHAND)
        Case 3
          Result = MessageRequester("MessageRequester-Demo", "Icon (?) : Frage", #MB_ICONQUESTION)
        Case 4
          Result = MessageRequester("MessageRequester-Demo", "Icon (i) : Information", #MB_ICONASTERISK)
        Case 5
          Result = MessageRequester("MessageRequester-Demo", "Icon (i) : Information", #MB_ICONINFORMATION)
        Case 6
          Result = MessageRequester("MessageRequester-Demo", "Warnung (ab NT4/95)", #MB_ICONWARNING)
        Case 7
          Result = MessageRequester("MessageRequester-Demo", "Warnung", #MB_ICONEXCLAMATION)
        Case 8
          Result = MessageRequester("MessageRequester-Demo", "#MB_OK (0 = Standard)", #MB_OK)
        Case 9
          Result = MessageRequester("MessageRequester-Demo", "#MB_OKCANCEL", #MB_OKCANCEL)
        Case 10
          Result = MessageRequester("MessageRequester-Demo", "#MB_YESNO", #MB_YESNO)
        Case 11
          Result = MessageRequester("MessageRequester-Demo", "#MB_YESNOCANCEL", #MB_YESNOCANCEL)
        Case 12
          Result = MessageRequester("MessageRequester-Demo", "#MB_RETRYCANCEL", #MB_RETRYCANCEL)
        Case 13
          Result = MessageRequester("MessageRequester-Demo", "#MB_ABORTRETRYIGNORE", #MB_ABORTRETRYIGNORE)
        EndSelect
        SetGadgetText(14,Chr(10)+"Result"+Chr(10)+"= "+Str(Result))

      EndIf 
    Until Quit

  Else
    MessageRequester("MessageRequester-Demo", "schwerwiegender Programmfehler !", #MB_ICONSTOP | #MB_SYSTEMMODAL)
  EndIf

CloseWindow(0)
EndIf

End
Hydrate
Enthusiast
Enthusiast
Posts: 436
Joined: Mon May 16, 2005 9:37 pm
Contact:

Post by Hydrate »

Exacly that, now i have something to work with, thank you.
Post Reply