Unique son dans un menu

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Joubarbe
Messages : 93
Inscription : sam. 01/juil./2006 16:40

Message par Joubarbe »

Une petite explication sur la commande SendMessage_ et ses paramètes siouplaît :) ?

L'aide sur cette commande est introuvable :oops:
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

c'est pas une commande purebasic, c'est une API :D
The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately.

LRESULT SendMessage(

HWND hwnd, // handle of destination window
UINT uMsg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
Parameters

hwnd

Identifies the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.

uMsg

Specifies the message to be sent.

wParam

Specifies additional message-specific information.

lParam

Specifies additional message-specific information.

Return Value

The return value specifies the result of the message processing and depends on the message sent.

Remarks

If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, Windows switches to that thread and calls the appropriate window procedure.

See Also
Joubarbe
Messages : 93
Inscription : sam. 01/juil./2006 16:40

Message par Joubarbe »

Code : Tout sélectionner

SendMessage_(Handle de la fenetre,#WM_LBUTTONUP,0,0) 
Donc, handle de la fenêtre je dois mettre ScreenOutput ?... Navré je ne saisis pas vraiment l'utilisation de la commande.

Sinon la constante #WM_LBUTTONUP n'est pas reconnu :(

EDIT : problème réglé, jaPBe ne prenait pas en charge les commandes de la v4, j'ai donc téléchargé la bonne version :)
Dernière modification par Joubarbe le mer. 12/juil./2006 13:13, modifié 1 fois.
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

Joubarbe a écrit : EDIT : problème réglé, jaPBe ne prenait pas en charge les commandes de la v4
a tu telechargé la derniere version de Japbe ? 8O

ici : http://people.freenet.de/gnozal/jaPBeForPB400.zip
Gillou
Messages : 373
Inscription : sam. 28/août/2004 17:35
Localisation : Bretagne, 22
Contact :

Message par Gillou »

Tiens un ptit exemple fait à l'arrache ;)

J'ai mis des beep à la place des sons


If InitSprite () = 0 Or InitKeyboard ()=0 Or InitMouse ()=0
     MessageRequester ( "Erreur" , "Initialisation impossible" , 0)
     End
EndIf

w = 800 : h = 600

If OpenScreen (w, h, 32, "test" )
     CreateSprite (0, 20, 20) ; petite animation
     If StartDrawing ( SpriteOutput (0))
         Box (0, 0, 20, 20, RGB (255, 0, 155))
         Box (5, 5, 10, 10, RGB (155, 0, 255))
         StopDrawing ()
     EndIf
     CreateSprite (1, 20, 20) ; souris
     If StartDrawing ( SpriteOutput (1))
         Line (0, 0, 10, 0, #Red )
         Line (0, 0, 0, 10, #Red )
         LineXY (10, 0, 8, 4, #Red )
         LineXY (0, 10, 4, 8, #Red )
         LineXY (8, 4, 15, 10, #Red )
         LineXY (4, 8, 10, 15, #Red )
         LineXY (10, 15, 15, 10, #Red )
         FillArea (1,1, #Red , #Blue )
         StopDrawing ()
     EndIf
     CreateSprite (2, 100, 20) ; bouton non actif
     If StartDrawing ( SpriteOutput (2))
         Box (0, 0, 100, 20, #White )
         Box (1, 1, 98, 18, #Blue )
        t$ = "Bouton"
         DrawText ((100-TextWidth(t$))/2, (20-TextHeight(t$))/2, t$, #White , #Blue )
         StopDrawing ()
     EndIf
     CreateSprite (3, 100, 20) ; bouton actif ( souris dessus)
     If StartDrawing ( SpriteOutput (3))
         Box (0, 0, 100, 20, #White )
         Box (1, 1, 98, 18, #Green )
        t$ = "Bouton"
         DrawText ((100-TextWidth(t$))/2, (20-TextHeight(t$))/2, t$, #White , #Green )
         StopDrawing ()
     EndIf
     CreateSprite (4, 100, 20) ; bouton appuyée
     If StartDrawing ( SpriteOutput (4))
         Box (0, 0, 100, 20, #White )
         Box (1, 1, 98, 18, #Red )
        t$ = "Bouton"
         DrawText ((100-TextWidth(t$))/2, (20-TextHeight(t$))/2, t$, #White , #Red )
         StopDrawing ()
     EndIf
Else
     MessageRequester ( "Erreur" , "Impossible d'ouvrir un écran dans la fenêtre!" , 0)
     End
EndIf

dx = 2
dy = 2

Repeat
     ExamineKeyboard ()
     ExamineMouse ()
     FlipBuffers ()
     ClearScreen ( RGB (0, 0, 0))
     DisplaySprite (0, x, y)
    xm = MouseX () : ym = MouseY ()
     If xm > 100 And xm < 200 And ym > 100 And ym < 120
         If MouseButton ( #PB_MouseButton_Left )
             DisplaySprite (4, 100, 100)
             If push = 0 : Beep_ (1000, 10) : push = 1 : EndIf
         Else
            push=0
             DisplaySprite (3, 100, 100)
             If over = 0 : Beep_ (200, 10) : over = 1 : EndIf
         EndIf
     Else
         DisplaySprite (2, 100, 100)
        push=0
        over=0
     EndIf
    x+dx
    y+dy
     If x > w-20 : dx=-2
     ElseIf x < 0 : dx=2 : EndIf
     If y > h-20 : dy=-2
     ElseIf y < 0 : dy=2 : EndIf
     DisplayTransparentSprite (1, xm, ym)
     Delay (1)
Until KeyboardPushed ( #PB_Key_Escape )
Répondre