begin process at 2012 05 29 18:30:46
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

Au secours

 > 

pb => timer


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

pb => timer

jeudi 21 août 2003 à 12:44:39 | pb => timer

mat74

salu a ts
jai 1 pb => normal si jsui la
j'arrivge pa a mettre de timer ds mes jeu (jutilise allegro avec VC++ v6.0 )
si qq1 pourrai mexpliquer EN DETAIL commen en faire 1 sa serai cool
merci davance
@+
jeudi 21 août 2003 à 13:13:19 | Re : pb => timer

vecchio56

Administrateur CodeS-SourceS
/*-----------------------------------------
BEEPER1.C -- Timer Demo Program No. 1
(c) Charles Petzold, 1998
-----------------------------------------*/

#include <windows.h>

#define ID_TIMER 1

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

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("Beeper1") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;

wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;

if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("Program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}

hwnd = CreateWindow (szAppName, TEXT ("Beeper1 Timer Demo"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ;

ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;

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

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static BOOL fFlipFlop = FALSE ;
HBRUSH hBrush ;
HDC hdc ;
PAINTSTRUCT ps ;
RECT rc ;

switch (message)
{
case WM_CREATE:
SetTimer (hwnd, ID_TIMER, 1000, NULL) ;
return 0 ;

case WM_TIMER :
MessageBeep (-1) ;
fFlipFlop = !fFlipFlop ;
InvalidateRect (hwnd, NULL, FALSE) ;
return 0 ;

case WM_PAINT :
hdc = BeginPaint (hwnd, &ps) ;

GetClientRect (hwnd, &rc) ;
hBrush = CreateSolidBrush (fFlipFlop ? RGB(255,0,0) : RGB(0,0,255)) ;
FillRect (hdc, &rc, hBrush) ;

EndPaint (hwnd, &ps) ;
DeleteObject (hBrush) ;
return 0 ;

case WM_DESTROY :
KillTimer (hwnd, ID_TIMER) ;
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}


-------------------------------
Réponse au message :
-------------------------------

> salu a ts
> jai 1 pb => normal si jsui la
> j'arrivge pa a mettre de timer ds mes jeu (jutilise allegro avec VC++ v6.0 )
> si qq1 pourrai mexpliquer EN DETAIL commen en faire 1 sa serai cool
> merci davance
> @+
jeudi 21 août 2003 à 13:14:14 | Re : pb => timer

vecchio56

Administrateur CodeS-SourceS
/*----------------------------------------
BEEPER2.C -- Timer Demo Program No. 2
(c) Charles Petzold, 1998
----------------------------------------*/

#include <windows.h>

#define ID_TIMER 1

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
VOID CALLBACK TimerProc (HWND, UINT, UINT, DWORD ) ;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("Beeper2") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;

wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;

if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("Program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}

hwnd = CreateWindow (szAppName, TEXT ("Beeper2 Timer Demo"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ;

ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;

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

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
SetTimer (hwnd, ID_TIMER, 1000, TimerProc) ;
return 0 ;

case WM_DESTROY:
KillTimer (hwnd, ID_TIMER) ;
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}

VOID CALLBACK TimerProc (HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime)
{
static BOOL fFlipFlop = FALSE ;
HBRUSH hBrush ;
HDC hdc ;
RECT rc ;

MessageBeep (-1) ;
fFlipFlop = !fFlipFlop ;

GetClientRect (hwnd, &rc) ;

hdc = GetDC (hwnd) ;
hBrush = CreateSolidBrush (fFlipFlop ? RGB(255,0,0) : RGB(0,0,255)) ;

FillRect (hdc, &rc, hBrush) ;
ReleaseDC (hwnd, hdc) ;
DeleteObject (hBrush) ;
}

-------------------------------
Réponse au message :
-------------------------------

> /*-----------------------------------------
> BEEPER1.C -- Timer Demo Program No. 1
> (c) Charles Petzold, 1998
> -----------------------------------------*/
>
> #include <windows.h>
>
> #define ID_TIMER 1
>
> LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
>
> int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
> PSTR szCmdLine, int iCmdShow)
> {
> static TCHAR szAppName[] = TEXT ("Beeper1") ;
> HWND hwnd ;
> MSG msg ;
> WNDCLASS wndclass ;
>
> wndclass.style = CS_HREDRAW | CS_VREDRAW ;
> wndclass.lpfnWndProc = WndProc ;
> wndclass.cbClsExtra = 0 ;
> wndclass.cbWndExtra = 0 ;
> wndclass.hInstance = hInstance ;
> wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
> wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
> wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
> wndclass.lpszMenuName = NULL ;
> wndclass.lpszClassName = szAppName ;
>
> if (!RegisterClass (&wndclass))
> {
> MessageBox (NULL, TEXT ("Program requires Windows NT!"),
> szAppName, MB_ICONERROR) ;
> return 0 ;
> }
>
> hwnd = CreateWindow (szAppName, TEXT ("Beeper1 Timer Demo"),
> WS_OVERLAPPEDWINDOW,
> CW_USEDEFAULT, CW_USEDEFAULT,
> CW_USEDEFAULT, CW_USEDEFAULT,
> NULL, NULL, hInstance, NULL) ;
>
> ShowWindow (hwnd, iCmdShow) ;
> UpdateWindow (hwnd) ;
>
> while (GetMessage (&msg, NULL, 0, 0))
> {
> TranslateMessage (&msg) ;
> DispatchMessage (&msg) ;
> }
> return msg.wParam ;
> }
>
> LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
> {
> static BOOL fFlipFlop = FALSE ;
> HBRUSH hBrush ;
> HDC hdc ;
> PAINTSTRUCT ps ;
> RECT rc ;
>
> switch (message)
> {
> case WM_CREATE:
> SetTimer (hwnd, ID_TIMER, 1000, NULL) ;
> return 0 ;
>
> case WM_TIMER :
> MessageBeep (-1) ;
> fFlipFlop = !fFlipFlop ;
> InvalidateRect (hwnd, NULL, FALSE) ;
> return 0 ;
>
> case WM_PAINT :
> hdc = BeginPaint (hwnd, &ps) ;
>
> GetClientRect (hwnd, &rc) ;
> hBrush = CreateSolidBrush (fFlipFlop ? RGB(255,0,0) : RGB(0,0,255)) ;
> FillRect (hdc, &rc, hBrush) ;
>
> EndPaint (hwnd, &ps) ;
> DeleteObject (hBrush) ;
> return 0 ;
>
> case WM_DESTROY :
> KillTimer (hwnd, ID_TIMER) ;
> PostQuitMessage (0) ;
> return 0 ;
> }
> return DefWindowProc (hwnd, message, wParam, lParam) ;
> }
>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > salu a ts
> > jai 1 pb => normal si jsui la
> > j'arrivge pa a mettre de timer ds mes jeu (jutilise allegro avec VC++ v6.0 )
> > si qq1 pourrai mexpliquer EN DETAIL commen en faire 1 sa serai cool
> > merci davance
> > @+
>
samedi 8 mai 2004 à 15:57:38 | Re : pb => timer


Cette discussion est classée dans : pb, timer


Répondre à ce message

Sujets en rapport avec ce message

directx pb de timer [ par niketou ] Salut a tous.Ceci est il normal:j'ai cree un timer (500msec)et une fonction "MainTimer();" qui affiche le rendu.Quand je la met dans la winmain ca va. Timer dans service [ par deck_bsd ] Bonjour à tous,Voila, je me demandai, ds mon service je doit me servir d'un timer. Hors celui-ci ne contient aucune fenêtre et donc aucun hwnd. Donc d Timer & service [ par deck_bsd ] Bonjour à tous.Voici mon problème,J'ai crée un timer dans mon service, mais celui-ci ne fonctionne pas (je suis certain que c'est le timer car j'ai te Problème avec le Timer d'ALLEGRO [ par tibe18453636 ] J'ai un problème avec un jeu (une sorte de pong) que j'ai développé sous dev-cpp avec Allegro.Apparament cela vient du timer que jutilise pour limiter Timer C++ en console? [ par lekenyanbreton ] Salut tout le monde je cherche à développer un timer C++ en mode console car avec une MFC c facile mais en console j'arrive pas.Merci d'avance!!! pb avec les rotations [ par ET29 ] Bonjour,je bute sur un petit pb de rotations :je voudrais faire pivoter une pyramide avec la souris autour des axes X et Y de l'ecran (soit horizontal PB de malloc() [ par skim13 ] Bonjour,Lorsque je compile mon fichier.c j'ai un message qui apparait sur mon ecran"glibc detected***malloc():memory corruption: 0x0804b0d8 **a [MFC Visual 6] timer, debug assertion et autres questions [ par vladii ] J'ai quelques questions sur les MFC avec Visual 6, si quelqu'un peut m'aider, ça serait sympa: (projet en sdi) - je voudrais qu'au départ de mon appl pb avec GTK et le redimensionnement d'une image [ par barok59 ] bonjour a tous,Alors voila, je vous écrit car j'ai un petit pb avec mon cpp.Je dois afficher une image de type GTK::Image dans une widget. L'image est Pb de debutant en C [ par tezca_system ] BonjourJ'ai des pb pour manipuler char *argv[] lors de son passage en argument d'une fonction.char *argv[] est une chaine de caractere saisi à l'invit


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,186 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales