begin process at 2008 07 06 13:01:20
1 205 544 membres
121 nouveaux aujourd'hui
14 119 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

TIMER (VC++ SANS MFC) (FORUM)


Information sur la source

Catégorie :Application Niveau : Débutant Date de création : 13/07/2004 Date de mise à jour : 13/07/2004 21:11:35 Vu / téléchargé: 5 580 / 1 041

Note :
7 / 10 - par 8 personnes
7,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note

Description

Suite à une questin sur le forum, voici un exemple de timer.
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

13 juillet 2004 21:11:35 :
Modification du code la 1ere version était coder comme de la m****
  • signaler à un administrateur
    Commentaire de BruNews le 13/07/2004 20:46:40 administrateur CS

    ben alors tu arretes un timer qui n'existe pas et on en a l'annonce en plus.
    Faut prendre le temps de coder correctement svp, on est pas aux pieces.

  • signaler à un administrateur
    Commentaire de DeAtHCrAsH le 13/07/2004 21:13:57

    Ca y est j'ai revu la source. Ca se voit que c'est les vacances j'avais fait le code vraiment a l'arrache!

    Tout est correcte maintenant.

    Puis aussi quand vous mettez des notes laissez un commentaire avec de quoi expliquer, meme si je sais pourquoi j'ai eu le 1/10 :)

    Shell

  • signaler à un administrateur
    Commentaire de ssinfod le 15/11/2005 15:29:55

    Salut,
    j'ai fait une version qui compile sur borlandx et devc++, voila tout est dans un fichier..(main.cpp)


    #include <windows.h>

    #define ZERO 0
    #define ONE 1
    #define IDT_TIMER1 WM_USER+100

    LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
    LRESULT CALLBACK BtnStartProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
    LRESULT CALLBACK BtnStopProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);

    HWND hwndMain, hwndStatic;
    HWND hwndBtnStart, hwndBtnStop;
    WNDPROC OldBtnStartProc, OldBtnStopProc;

    //////////////////////////////////////////////////////////////////////////////////
    //WinMain
    //////////////////////////////////////////////////////////////////////////////////
    int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
    {
      MSG msg;
      WNDCLASSEX wcx;

      // Fill in the WNDCLASS Struct
      wcx.cbSize = sizeof(WNDCLASSEX);
      wcx.style = CS_DBLCLKS;
      wcx.lpfnWndProc = MainWndProc;
      wcx.cbClsExtra = 0;
      wcx.cbWndExtra = 0;
      wcx.hInstance = hInst;
      wcx.hIcon = LoadIcon (NULL, IDI_APPLICATION);
      wcx.hCursor = LoadCursor (NULL, IDC_ARROW);
      wcx.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
      wcx.lpszMenuName = NULL;
      wcx.lpszClassName = "EzTimer";
      wcx.hIconSm = NULL;

      // Register Class
      if (!RegisterClassEx(&wcx))
      {
        return 0;
      }

      // Create Main Window
      long lSizeX=160;
      long lSizeY=70;
      hwndMain = CreateWindowEx(0, "EzTimer", "EzTimer", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
                                      CW_USEDEFAULT, lSizeX, lSizeY, NULL, NULL, hInst, NULL);

      //Buttons
      hwndBtnStart = CreateWindowEx(0, "BUTTON", "&Start", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, 0, 0, 50, 50, hwndMain, NULL, hInst, NULL);
      hwndBtnStop = CreateWindowEx(0, "BUTTON", "&Stop", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, 0, 0, 50, 50, hwndMain, NULL, hInst, NULL);

      // SubClass
      OldBtnStartProc = (WNDPROC) SetWindowLong(hwndBtnStart,GWL_WNDPROC,(LONG)BtnStartProc);
      OldBtnStopProc = (WNDPROC) SetWindowLong(hwndBtnStop,GWL_WNDPROC,(LONG)BtnStopProc);

      // Make Window visible
      ShowWindow(hwndMain,nCmdShow);
      UpdateWindow(hwndMain);

      // Change the default police
      SendMessage(hwndBtnStart, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));
      SendMessage(hwndBtnStop, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));
      UpdateWindow(hwndMain);

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

      return msg.wParam;
    }

    ////////////////////////////////////////////////////////////////////////////
    // Callback function for the Main Window class
    ////////////////////////////////////////////////////////////////////////////
    LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
    {
      RECT rc;
      switch(msg)
      {
        case WM_DESTROY:
          PostQuitMessage(0);
        break;

        case WM_SIZE:

          if (wParam != SIZE_MINIMIZED)
          {
            long lX=0, lY=0, lSizeX=0, lSizeY=0;
            GetClientRect(hwndMain, &rc);

            //Resize Button Read
            lX=10, lY=10, lSizeX=60, lSizeY=20;
            MoveWindow(hwndBtnStart, lX, lY, lSizeX, lSizeY, TRUE);  //(X, Y, SIZE X, SIZE Y)    //Read
            lX=80, lY=10, lSizeX=60, lSizeY=20;
            MoveWindow(hwndBtnStop, lX, lY, lSizeX, lSizeY, TRUE);  //(X, Y, SIZE X, SIZE Y)  //Clear
          }
        break;

        // On traite l'evenement du TIMER
        case WM_TIMER:
          switch(wParam)
          {
            case IDT_TIMER1:
              MessageBox(0,"Ce message s'affiche toutes les 3 secondes.","TIMER",MB_ICONINFORMATION);
            break;
          }
        break;

        default:
          return DefWindowProc(hwnd,msg,wParam,lParam);
        }

      return 0;
    }

    ////////////////////////////////////////////////////////////////////////////////////
    //Callback of the Button
    ////////////////////////////////////////////////////////////////////////////////////
    LRESULT CALLBACK BtnStartProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
    {
      RECT rc; HDC hdc; HPEN hpen; HBRUSH hbr; HGDIOBJ oldpen, oldbr; LOGBRUSH logbrush;

      switch(msg)
      {

        case WM_PAINT:
          // Draw Original Button
          CallWindowProc(OldBtnStartProc, hwnd, msg, wParam, lParam);
        break;

        case WM_LBUTTONDOWN:
          MessageBox(hwnd,"Le Timer va être lancé!","Message OK",MB_OK|MB_ICONINFORMATION);
          // On mance le timer. Le temps est indiqué en milliseconde. 3000ms = 3s
          SetTimer(hwndMain,IDT_TIMER1,3000,(TIMERPROC)NULL);  //Watch out !. We need to use the mainHandle
          break;

        break;

        default:
          return CallWindowProc(OldBtnStartProc, hwnd, msg, wParam, lParam);
      }

      return 0;
    }


    ////////////////////////////////////////////////////////////////////////////////////
    //Callback of the Button Clear
    ////////////////////////////////////////////////////////////////////////////////////
    LRESULT CALLBACK BtnStopProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
    {
      RECT rc; HDC hdc; HPEN hpen; HBRUSH hbr; HGDIOBJ oldpen, oldbr; LOGBRUSH logbrush;

      switch(msg)
      {

        case WM_PAINT:
          // Draw Original Button
          CallWindowProc(OldBtnStopProc, hwnd, msg, wParam, lParam);
        break;

        case WM_LBUTTONDOWN:
         KillTimer(hwndMain,IDT_TIMER1);  //Watch out !. We need to use the mainHandle
         MessageBox(hwnd,"Le Timer a été arreté!","Message OK",MB_OK|MB_ICONINFORMATION);
        break;

        default:
          return CallWindowProc(OldBtnStopProc, hwnd, msg, wParam, lParam);
      }

      return 0;
    }

Ajouter un commentaire

Pub



Appels d'offres

Plugin Dialer outlook
Budget : 2 000€
Travail graphique- ill...
Budget : 1 000€
creation de marque et ...
Budget : 1 000€

CalendriCode

Juillet 2008
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Boutique

Boutique de goodies CodeS-SourceS