IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Discussion :

SplashScrenn besoin d'aide


Sujet :

Windows

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 8
    Points : 3
    Points
    3
    Par défaut SplashScrenn besoin d'aide
    bonjours ,
    je voudrais creer un splash screen en c++ , mais je ne sait pas comment faire j'ai beau regarder sur google je ne trouve pas .

    Alors es que quelqu'un pourait me passer un code source d'exemple pour que je comprenne comment ça marche ??

    Merci d'avance pour vos reponces

    comi512

  2. #2
    Expert éminent
    Avatar de Melem
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2006
    Messages
    3 656
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 3 656
    Points : 8 389
    Points
    8 389
    Par défaut
    - Tu crées un thread (CreateThread) dans lequel tu crées une fenêtre (CreateWindow) qui sera le splash screen.

    - Dans le thread principal de ton application, tu fais toutes les initialisations requises par l'application.

    - Tu communiques avec le thread du splash screen à l'aide de PostThreadMessage.

    - Tu fermes le splash screen (et termine le thread) une fois toutes les initialisations terminées. Il ne reste plus que le thread principal qui va continuer à faire ce qu'il a à faire.

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 8
    Points : 3
    Points
    3
    Par défaut
    re bonjours

    Es que tu pourrais me donner le code source parce que là je sui assez pommer en faite !!!

    merci d'avance pour vos reponces .

  4. #4
    Expert éminent
    Avatar de Melem
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2006
    Messages
    3 656
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 3 656
    Points : 8 389
    Points
    8 389
    Par défaut
    Tu me paies combien ?

    Solution de secours : Cours et tutoriels de programmation Windows.

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 8
    Points : 3
    Points
    3
    Par défaut
    ben je ne sait pas proposez un prix et je vous dirais si sa me convient ou pas .

  6. #6
    Expert éminent
    Avatar de Melem
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2006
    Messages
    3 656
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 3 656
    Points : 8 389
    Points
    8 389
    Par défaut
    C'était juste une manière de t'inviter à faire des recherches avec les indices que je t'ai donnés avant de demander aux autres de te pondre du code mais apparemment c'est bien raté ...

    Bref, voilà je t'ai fait un petit programme qui montre comment ça fonctionne, par contre c'est en C et non en C++. J'ai favorisé la simplicité par rapport à la flexibilité. J'espère que cela t'ira.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    #include <windows.h>
    
    /* Quelques messages que NOUS définissons */
    #define WM_SPLASH_READY      (WM_USER + 1)
    #define WM_SPLASH_SET_STATUS (WM_USER + 2)
    #define WM_SPLASH_EXIT       (WM_USER + 3)
    
    LRESULT CALLBACK FenPrincipaleProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
    DWORD WINAPI SplashThreadProc(LPVOID lpParams);
    LRESULT CALLBACK SplashScreenProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
    
    struct {
        HINSTANCE hInstance;
        DWORD dwMainThreadId;
        int ScreenWidth, ScreenHeight;
    } MyApp;
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
        WNDCLASS wc;
        HWND hWnd;
        MSG msg;
    
        HANDLE hSplashThread;
        DWORD dwSplashThreadId;
        BOOL SplashScreenReady = FALSE;
    
        MyApp.hInstance = hInstance;
        MyApp.dwMainThreadId = GetCurrentThreadId();
        MyApp.ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
        MyApp.ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
    
        wc.cbClsExtra     = 0;
        wc.cbWndExtra     = 0;
        wc.hbrBackground  = (HBRUSH)(COLOR_WINDOW + 1);
        wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
        wc.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
        wc.hInstance      = hInstance;
        wc.lpfnWndProc    = FenPrincipaleProc;
        wc.lpszClassName  = "Fenêtre principale";
        wc.lpszMenuName   = NULL;
        wc.style          = CS_HREDRAW | CS_VREDRAW;
    
        RegisterClass(&wc);
    
        /* Créer un thread pour faire apparaître le beau splash screen qui patientera l'utilisateur */
        /* pendant que nous allons initialiser le programme.                                        */
        hSplashThread = CreateThread(NULL, 0, SplashThreadProc, NULL, 0, &dwSplashThreadId);
    
        /* Attendre que le splash screen ait bien été créé. */
        while (!SplashScreenReady)
        {
            GetMessage(&msg, NULL, 0, 0);
            SplashScreenReady = (msg.message == WM_SPLASH_READY);
        }
    
        /* Début des initialisations. */
        PostThreadMessage(dwSplashThreadId, WM_SPLASH_SET_STATUS, 0, (LPARAM)"Initialisation 1");
        Sleep(1000); /* Exemple de traitement qui requiert 1 seconde (1000 ms). */
        PostThreadMessage(dwSplashThreadId, WM_SPLASH_SET_STATUS, 0, (LPARAM)"Initialisation 2");
        Sleep(2000); /* Exemple de traitement qui requiert 2 secondes. */
        PostThreadMessage(dwSplashThreadId, WM_SPLASH_SET_STATUS, 0, (LPARAM)"Initialisation 3");
        Sleep(500); /* Exemple de traitement qui requiert 0.5 seconde. */
        /* Fin des initialisations. On peut désormais créer la fenêtre principale de l'application. */
    
        /* Fermons alors le splash screen. */
        PostThreadMessage(dwSplashThreadId, WM_SPLASH_EXIT, 0, 0);
    
        /* Attendre que le thread du splash screen s'est terminé avant de continuer. */
        WaitForSingleObject(hSplashThread, INFINITE);
    
        hWnd = CreateWindow("Fenêtre principale",
                            "Notre fenêtre principale",
                            WS_OVERLAPPEDWINDOW,
                            MyApp.ScreenWidth / 5,
                            MyApp.ScreenHeight / 5,
                            3 * MyApp.ScreenWidth / 5,
                            3 * MyApp.ScreenHeight / 5,
                            NULL,
                            NULL,
                            hInstance,
                            NULL);
    
        ShowWindow(hWnd, SW_MINIMIZE);
        ShowWindow(hWnd, nCmdShow);
        SetForegroundWindow(hWnd);
    
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    
        return (int)msg.wParam;
    }
    
    LRESULT CALLBACK FenPrincipaleProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch(message)
        {
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
    
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
        }
    
        return 0L;
    }
    
    DWORD WINAPI SplashThreadProc(LPVOID lpParams)
    {
        /* Pratiquement un autre WinMain ... */
    
        WNDCLASS wc;
        HWND hWnd;
        MSG msg;
    
        wc.cbClsExtra     = 0;
        wc.cbWndExtra     = 0;
        wc.hbrBackground  = (HBRUSH)(COLOR_BTNFACE + 1);
        wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
        wc.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
        wc.hInstance      = MyApp.hInstance;
        wc.lpfnWndProc    = SplashScreenProc;
        wc.lpszClassName  = "Splash Screen";
        wc.lpszMenuName   = NULL;
        wc.style          = CS_HREDRAW | CS_VREDRAW;
    
        RegisterClass(&wc);
    
        hWnd = CreateWindow("Splash Screen",
                            "Notre splash screen",
                            WS_POPUP,
                            MyApp.ScreenWidth / 4,
                            MyApp.ScreenHeight / 4,
                            MyApp.ScreenWidth / 2,
                            MyApp.ScreenHeight / 2,
                            NULL,
                            NULL,
                            MyApp.hInstance,
                            NULL);
    
        ShowWindow(hWnd, SW_SHOW);
        PostThreadMessage(MyApp.dwMainThreadId, WM_SPLASH_READY, 0, 0);
    
        while (GetMessage(&msg, NULL, 0, 0))
        {
            switch(msg.message)
            {
            case WM_SPLASH_SET_STATUS:
                SetWindowText(hWnd, (const char *)msg.lParam);
                InvalidateRect(hWnd, NULL, TRUE);
                break;
    
            case WM_SPLASH_EXIT:
                DestroyWindow(hWnd);
                break;
    
            default:
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
    
        return (int)msg.wParam;
    }
    
    LRESULT CALLBACK SplashScreenProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        static char lpText[256];
        static int TextLength;
        static HDC hDC;
        PAINTSTRUCT ps;
        static RECT r;
    
        switch(message)
        {
        case WM_CREATE:
            hDC = GetDC(hwnd);
            SetBkMode(hDC, TRANSPARENT);
            SetBkColor(hDC, RGB(0, 0, 0));
            GetClientRect(hwnd, &r);
            break;
    
        case WM_SETTEXT:
            strcpy(lpText, (const char *)lParam);
            TextLength = strlen(lpText);
            break;
    
        case WM_PAINT:
            BeginPaint(hwnd, &ps);
            DrawTextA(hDC, lpText, TextLength, &r, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
            EndPaint(hwnd, &ps);
            break;
    
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
    
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
        }
    
        return 0L;
    }

  7. #7
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 8
    Points : 3
    Points
    3
    Par défaut
    Je te remerci pour ton aide qui m'es pressieuse . je te tiens au courant si cela marche .

    Encore une fois 1000 fois merci

Discussions similaires

  1. besoin d'aide pour le composant DBComboBox
    Par jane2002 dans le forum Bases de données
    Réponses: 8
    Dernier message: 28/02/2004, 19h01
  2. Besoin d'aide avec postgresql sous windows NT
    Par Chihuahua dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 18/07/2003, 08h29
  3. [CR] besoin d'aide sur les formules
    Par GuillaumeDSA dans le forum Formules
    Réponses: 4
    Dernier message: 10/07/2003, 12h19
  4. [TP]besoin d'aide pour commandes inconnues
    Par Upal dans le forum Turbo Pascal
    Réponses: 15
    Dernier message: 03/10/2002, 10h48
  5. Besoin d'aide pour l'I.A. d'un puissance 4
    Par Anonymous dans le forum C
    Réponses: 2
    Dernier message: 25/04/2002, 17h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo