Dans zip: exe + cpp, rc et resource.h pour recompiler.
Version de Kirua refaite avec fenetre.
Source / Exemple :
#include <windows.h>
#include "resource.h"
HWND htim;
DWORD dwstart;
DWORD idtimer;
char szbuff[40];
__declspec (naked) char* __stdcall bnultoa(unsigned int dwnum, char* szdst)
{
__asm {
mov eax, [esp+4]
mov ecx, [esp+8]
or eax, eax
jnz short LBL1
lea eax, [ecx+1]
mov byte ptr[ecx], 48
mov byte ptr[eax], 0
ret 8
LBL1:
mov [esp-4], edi
mov [esp-8], ecx
mov edi, ecx
mov ecx, eax
LBL2:
mov eax, -858993459
mul ecx
mov eax, edx
shr eax, 3
mov edx, ecx
lea ecx, [eax+eax*8]
add ecx, eax
sub edx, ecx
add dl, 48
mov [edi], dl
mov ecx, eax
inc edi
test eax, eax
jnz short LBL2
mov [edi], al
mov [esp-12], edi
mov eax, [esp-8]
LBL3:
dec edi
mov dl, [eax]
mov cl, [edi]
mov [edi], dl
mov [eax], cl
inc eax
cmp eax, edi
jb short LBL3
mov edi, [esp-4]
mov eax, [esp-12]
ret 8
}
}
void CALLBACK TimProc(HWND hwnd, UINT mssg, UINT idEvent, DWORD dwTime)
{
DWORD d, h, m, s;
char *c;
dwstart++;
d = dwstart / (60*60*24);
h = dwstart % (60*60*24);
m = h % (60*60);
h /= (60*60);
s = m % 60;
m /= 60;
c = bnultoa(d, szbuff);
- c++ = 32; *c++ = 'j'; *c++ = 32;
c = bnultoa(h, c);
- c++ = 32; *c++ = 'h'; *c++ = 32;
c = bnultoa(m, c);
- c++ = 32; *c++ = 'm'; *c++ = 32;
c = bnultoa(s, c);
- c++ = 32; *c++ = 's'; *c = 0;
SetWindowText(htim, szbuff);
}
BOOL CALLBACK AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam)
{
switch(mssg) {
case WM_INITDIALOG:
SetClassLong(hdlg, GCL_HICON, (long)LoadIcon(0, IDI_APPLICATION));
htim = GetDlgItem(hdlg, ID_TIME);
dwstart = GetTickCount() / 1000;
idtimer = SetTimer(0, 0, 1000, TimProc);
TimProc(0, 0, 0, 0); // pour affichage immediat
return 1;
case WM_COMMAND:
if(wParam == IDCANCEL) {
KillTimer(0, idtimer);
EndDialog(hdlg, 0);
}
}
return 0;
}
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE, PSTR, int)
{
DialogBoxParam(hinst, (LPCTSTR)IDD_APP, 0, AppDlgProc, 0);
return 0;
}
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.