Partage
  • Partager sur Facebook
  • Partager sur Twitter

Transparence

SetLayeredWindowAttributes

Anonyme
    12 octobre 2006 à 21:51:45

    Bonjour j'ai le code suivant, mais il ne marche pas.
    Il me mais une erreur sur la ligne :
    SetLayeredWindowAttributes(hwnd,NULL,100,0x02) undeclared.

    Pourtant, cette fonction existe bien, je l'ai vue sur msdn


    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)                  /* handle the messages */
        {
            case WM_CREATE :
                SetLayeredWindowAttributes(hwnd,NULL,100,0x02);
                break;
            case WM_DESTROY:
                PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }

        return 0;
    }


    • Partager sur Facebook
    • Partager sur Twitter
      12 octobre 2006 à 23:30:19

      Il faut placer #define _WIN32_WINNT 0x0501 avant #include <windows.h>.
      • Partager sur Facebook
      • Partager sur Twitter
      Anonyme
        13 octobre 2006 à 7:31:28

        je viens de tester, ca ne marche pas.

        PS : la compilation se passe bien mais la transparence ne change pas.
        il passe dans le Sinon

                    if(SetLayeredWindowAttributes(hwnd,NULL,200,LWA_ALPHA)) {
                        MessageBox(hwnd,"OK","OK",MB_OK);
                    }
                    else {
                        MessageBox(hwnd,"ERREUR","ERREUR",MB_OK);
                    }

        • Partager sur Facebook
        • Partager sur Twitter
          13 octobre 2006 à 8:14:39

          Tu as sûrement omis WS_EX_LAYERED.
          Ceci fonctionne :

          #define _WIN32_WINNT 0x0501

          #include <windows.h>

          LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);

          int WINAPI WinMain(HINSTANCE hInstance,
                             HINSTANCE hPrevInstance,
                             LPSTR lpCmdLine,
                             int nCmdShow)
          {
             WNDCLASSEX wce;

             wce.cbClsExtra = 0;
             wce.cbSize = sizeof(WNDCLASSEX);
             wce.cbWndExtra = 0;
             wce.hbrBackground = CreateSolidBrush(0x00965d41);
             wce.hCursor = LoadCursor(NULL, IDC_ARROW);
             wce.hIcon = LoadIcon(NULL, IDI_APPLICATION);
             wce.hIconSm = NULL;
             wce.hInstance = hInstance;
             wce.lpfnWndProc = WindowProc;
             wce.lpszClassName = "WindowClass";
             wce.lpszMenuNameNULL;
             wce.style = 0;

             RegisterClassEx(&wce);

             CreateWindowEx(WS_EX_LAYERED,
                            "WindowClass",
                            "Essai Transparence",
                            WS_VISIBLE,
                            CW_USEDEFAULT,
                            CW_USEDEFAULT,
                            800,
                            600,
                            NULL,
                            NULL,
                            hInstance,
                            NULL);

             MSG msg;

             while(GetMessage(&msg, NULL, 0, 0))
             {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
             }

             return (int)msg.wParam;
          }

          LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
          {
             switch(msg)
             {
                case WM_CREATE :
                   SetLayeredWindowAttributes(hWnd, NULL, 100, 0x02);
                   break;

                case WM_DESTROY:
                   PostQuitMessage (0);
                   break;
             }

             return DefWindowProc(hWnd, msg, wParam, lParam);
          }
          • Partager sur Facebook
          • Partager sur Twitter

          Transparence

          × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
          × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
          • Editeur
          • Markdown