cs_Joky
Messages postés
1787
Date d'inscription
lundi 22 novembre 2004
Statut
Membre
Dernière intervention
31 janvier 2009
2
6 août 2006 à 16:35
#include <windows.h>
const char TxtToScroll[] = "Le Texte à Scroller";
UINT uiY,LIMITEP, LIMITEM;
RECT txtArea;
SIZE szTxt;
HDC hDc;
BOOL Down;
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
switch(Msg)
{
case WM_CREATE:
LIMITEM = 10;
uiY = LIMITEM;
LIMITEP = 100;
Down = TRUE;
SetTimer(hWnd, 1, 1, NULL);
return 0;
case WM_PAINT:
hDc = BeginPaint(hWnd, &ps);
SetBkMode(hDc, TRANSPARENT);
TextOut(hDc, 10, uiY, TxtToScroll, 19);
EndPaint(hWnd, &ps);
return 0;
case WM_TIMER:
if(Down) uiY++;
else uiY--;
if(Down)
{
if (uiY==LIMITEP)
{
Down = FALSE;
LIMITEP -= 1;
}
}
else
{
if (uiY==LIMITEM)
{
Down = TRUE;
LIMITEM += 1;
}
}
if(LIMITEM>=LIMITEP)
KillTimer(hWnd, 1);
GetTextExtentPoint(hDc, TxtToScroll, strlen(TxtToScroll), &szTxt);
SetRect(&txtArea, 10, uiY-1, 10+szTxt.cx, uiY-1+szTxt.cy);
InvalidateRect(hWnd, 0, 1);
return 0;
case WM_DESTROY:
if(LIMITEM>=LIMITEP)
KillTimer(hWnd, 1);
ExitProcess(0);
return 0;
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
int __stdcall WinMain(HINSTANCE hInst, HINSTANCE x, PSTR y, int z)
{
WNDCLASS wcl;
HWND hWnd;
MSG Msg;
memset(&wcl, 0, sizeof(WNDCLASS));
wcl.hbrBackground = CreateSolidBrush(RGB(255,255,255));
wcl.hCursor = LoadCursor(NULL, (LPCSTR)IDC_ARROW);
wcl.hIcon = LoadIcon(NULL, (LPCSTR)IDI_APPLICATION);
wcl.hInstance = hInst;
wcl.lpfnWndProc = WndProc;
wcl.lpszClassName = "WndClass";
if(!RegisterClass(&wcl)) return 0;
hWnd = CreateWindow( "WndClass", "Défilement de texte", WS_SYSMENU,
50,50,500,400,
HWND_DESKTOP, NULL, hInst, NULL);
ShowWindow(hWnd, SW_SHOWNORMAL);
while(GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return 0;
}
ULARGE_INTEGERJokyQi=QI("Joky"