SDL déplacer fenêtre (noframe)

Résolu
Utilisateur anonyme -  
 Utilisateur anonyme -
Bonjour, je cherche a déplacer une fenêtre en langage C, avec la bibliothèque SDL, quand on retire la barre (avec l'option SDL_NOFRAME) donc je cherche le bout de code qui pourrait m'aider, je ne veux pas non plus du tout fait mais bref si vous pouvez m'aider à ce sujet merci.
J'utilise CodeBlocks sur windows 7.

Autre problème j'essaie d'imiter la bouton réduire avec le petit tiret mais je n'y arrive pas donc si là aussi vous pouvez m'aider, merci d'avance.

1 réponse

  1. Hxyp Messages postés 401 Date d'inscription   Statut Membre Dernière intervention   54
     
    Bonjour,
    Voici un exemple sous windows pour le déplacement et le minimize :
    #include <stdlib.h> 
    #include <stdio.h> 
    #include <SDL/SDL.h> 
    #include <windows.h> 
    
    int main( int argc, char *argv[] ) 
      { 
        SDL_Surface *screen; 
        HWND hwnd; 
        int quit = 0; 
    
        if( SDL_Init( SDL_INIT_VIDEO ) == -1 ) 
          { 
            printf( "Can't init SDL:  %s\n", SDL_GetError( ) ); 
            return EXIT_FAILURE; 
          } 
    
        atexit( SDL_Quit ); 
        screen = SDL_SetVideoMode( 200, 200, 16, SDL_HWSURFACE|SDL_NOFRAME ); 
    
        if( screen == NULL ) 
          { 
            printf( "Can't set video mode: %s\n", SDL_GetError( ) ); 
            return EXIT_FAILURE; 
          } 
    
        hwnd = GetActiveWindow(); 
    
        while(!quit){ 
            SDL_Event event; 
    
            while ( SDL_PollEvent(&event) ) { 
                switch (event.type) { 
                    case SDL_MOUSEMOTION: 
                        ReleaseCapture(); 
                        SendMessage(hwnd,WM_NCLBUTTONDOWN,HTCAPTION,0); 
                        break; 
                    case SDL_KEYDOWN: 
                        if(event.key.keysym.sym == SDLK_ESCAPE) quit=1; 
                        if(event.key.keysym.sym == SDLK_SPACE) 
                            SendMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); 
                        break; 
                    case SDL_QUIT: 
                        exit(0); 
                } 
            } 
            SDL_Delay(10); 
        } 
        return EXIT_SUCCESS; 
      } 
    

    touche echap = quit, space = minimize

    sources :
    handle de la fenêtre : https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getactivewindow?redirectedfrom=MSDN
    event sdl : http://www.libsdl.org/intro.fr/usingeventsfr.html
    déplacement : https://social.msdn.microsoft.com/Forums/vstudio/en-US/b9985b19-cab5-4fba-9dc5-f323d0d37e2f/move-form-without-titlebar?forum=csharpgeneral
    minimize : https://www.codeproject.com/Answers/286300/SendMessage-WM_SYSCOMMAND-fails-to-minimize-a-wind.aspx#answer1
    0
    1. Utilisateur anonyme
       
      Salut, merci pour ton aide ça marche correctement.
      0