|
Trouver une ressource
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 !
[VC++] API WIN32 : GESTION DE LA RAM EN PROGRESS BAR V 1.1
Information sur la source
Description
Le code a pour but de vous montrer grace a une progress bar, l'utilisation de votre Ram ! C'est la Version 1.0, car la version avec Texte nessecite une conversion DWLONG -> LPCSTR ! Zone verte : Entre 0 et 41 % Orange Entre 41 et 81 ROUGE + 81 voila plz, ne mettez pas de mauvaise sans expliquer pourquoi dans les commentaires
Source
- #define _WIN32_WINNT 0x0501
- #include <windows.h>
- #include <commctrl.h>
- #pragma comment(lib,"comctl32.lib")
-
- HWND hmain;
- HWND hprg;
- HWND csur;
- HWND soit;
- HWND pcent;
- HWND libre;
-
- char szappname[] = "Rameur";
-
- void __stdcall OnTimerRam()
- {
- MEMORYSTATUSEX mstt;
- DWORD mem;
- long color;
- mstt.dwLength = sizeof(MEMORYSTATUSEX);
- GlobalMemoryStatusEx(&mstt);
- mem = mstt.dwMemoryLoad;
- if(mem < 41) color = RGB(23, 219, 38);
- else if(mem > 81) color = RGB(255, 66, 66);
- else color = RGB(255, 127, 0);
- SendMessage(hprg, PBM_SETBARCOLOR, 0, color);
- SendMessage(hprg, PBM_SETPOS, (WPARAM) mem, 0);
- char buf[12];
- char buf1[12];
- ultoa(mem, buf, 10);
- ultoa(mstt.ullAvailPhys,buf1,10);
- SetWindowText(csur,buf);
- SetWindowText(soit,"% soit ");
- SetWindowText(pcent,buf1);
- SetWindowText(libre,"Oc Libre");
- }
-
- LRESULT CALLBACK AppWndProc(HWND hwnd, UINT mssg, WPARAM wParam, LPARAM lParam)
- {
- switch(mssg) {
- case WM_TIMER:
- OnTimerRam();
- return 0;
- case WM_CREATE:
- hprg = CreateWindowEx(CS_DBLCLKS, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 30, 20, 218, 30, hwnd, 0, 0, 0);
- csur = CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,30,60,200,30,hwnd,0,0,0);
- soit = CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,50,60,200,90,hwnd,0,0,0);
- pcent =CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,95,60,300,90,hwnd,0,0,0);
- libre =CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,175,60,300,90,hwnd,0,0,0);
- SetTimer(hwnd,1,500,NULL);
- SendMessage(hprg, PBM_SETRANGE, 0, MAKELPARAM(0,100));
- return 0;
- case WM_DESTROY:
- KillTimer(hwnd, 1);
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hwnd, mssg, wParam, lParam);
- }
-
- DWORD __stdcall InitInstance(HINSTANCE hinst)
- {
- WNDCLASSEX wndcls;
- INITCOMMONCONTROLSEX iccex;
- iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- iccex.dwICC = ICC_PROGRESS_CLASS;
- if(!InitCommonControlsEx(&iccex)) return 0;
- memset(&wndcls, 0, sizeof(WNDCLASSEX));
- wndcls.cbSize = sizeof(WNDCLASSEX);
- wndcls.lpfnWndProc = AppWndProc;
- wndcls.style = CS_HREDRAW | CS_VREDRAW;
- wndcls.hInstance = hinst;
- wndcls.lpszClassName = szappname;
- wndcls.hbrBackground = CreateSolidBrush(RGB(236,233,216));
- wndcls.hCursor = LoadCursor(0, IDC_ARROW);
- if(!RegisterClassEx(&wndcls)) return 0;
- hmain = CreateWindowEx(WS_EX_TOPMOST, szappname, szappname, WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, 280, 125, 0, 0, hinst, 0);
- return (hmain != 0);
- }
-
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE x, PSTR y, int z)
- {
- MSG msg;
- if(!InitInstance(hInstance)) return 0;
- ShowWindow(hmain, SW_NORMAL);
- while(GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <commctrl.h>
#pragma comment(lib,"comctl32.lib")
HWND hmain;
HWND hprg;
HWND csur;
HWND soit;
HWND pcent;
HWND libre;
char szappname[] = "Rameur";
void __stdcall OnTimerRam()
{
MEMORYSTATUSEX mstt;
DWORD mem;
long color;
mstt.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&mstt);
mem = mstt.dwMemoryLoad;
if(mem < 41) color = RGB(23, 219, 38);
else if(mem > 81) color = RGB(255, 66, 66);
else color = RGB(255, 127, 0);
SendMessage(hprg, PBM_SETBARCOLOR, 0, color);
SendMessage(hprg, PBM_SETPOS, (WPARAM) mem, 0);
char buf[12];
char buf1[12];
ultoa(mem, buf, 10);
ultoa(mstt.ullAvailPhys,buf1,10);
SetWindowText(csur,buf);
SetWindowText(soit,"% soit ");
SetWindowText(pcent,buf1);
SetWindowText(libre,"Oc Libre");
}
LRESULT CALLBACK AppWndProc(HWND hwnd, UINT mssg, WPARAM wParam, LPARAM lParam)
{
switch(mssg) {
case WM_TIMER:
OnTimerRam();
return 0;
case WM_CREATE:
hprg = CreateWindowEx(CS_DBLCLKS, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 30, 20, 218, 30, hwnd, 0, 0, 0);
csur = CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,30,60,200,30,hwnd,0,0,0);
soit = CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,50,60,200,90,hwnd,0,0,0);
pcent =CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,95,60,300,90,hwnd,0,0,0);
libre =CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,175,60,300,90,hwnd,0,0,0);
SetTimer(hwnd,1,500,NULL);
SendMessage(hprg, PBM_SETRANGE, 0, MAKELPARAM(0,100));
return 0;
case WM_DESTROY:
KillTimer(hwnd, 1);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, mssg, wParam, lParam);
}
DWORD __stdcall InitInstance(HINSTANCE hinst)
{
WNDCLASSEX wndcls;
INITCOMMONCONTROLSEX iccex;
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccex.dwICC = ICC_PROGRESS_CLASS;
if(!InitCommonControlsEx(&iccex)) return 0;
memset(&wndcls, 0, sizeof(WNDCLASSEX));
wndcls.cbSize = sizeof(WNDCLASSEX);
wndcls.lpfnWndProc = AppWndProc;
wndcls.style = CS_HREDRAW | CS_VREDRAW;
wndcls.hInstance = hinst;
wndcls.lpszClassName = szappname;
wndcls.hbrBackground = CreateSolidBrush(RGB(236,233,216));
wndcls.hCursor = LoadCursor(0, IDC_ARROW);
if(!RegisterClassEx(&wndcls)) return 0;
hmain = CreateWindowEx(WS_EX_TOPMOST, szappname, szappname, WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, 280, 125, 0, 0, hinst, 0);
return (hmain != 0);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE x, PSTR y, int z)
{
MSG msg;
if(!InitInstance(hInstance)) return 0;
ShowWindow(hmain, SW_NORMAL);
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
Conclusion
Merci a Brunews qui ma expliquer comment recuperer les notions de memoires RAM Version 1.1 :) Je pense bientot integrer un system de defragmentation de RAM :) voila merci :)
Fichier Zip
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
Historique
- 01 février 2006 12:53:25 :
- Code au norm !
- 02 février 2006 20:19:10 :
- EXE en EX_ Dans le Zip !
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
api win32 sdk [ par fabpdg ]
je recherche comment utiliser les fonfions, comme netsessionemun en delphi.Delphi ne reconnaît pas les fonctions api win32 sdk.Comment et quels sont l
equivalent win32 pour linux [ par mbab ]
Bonjour, je debute en c++ et je dois realiser une interface graphique en c++ sous linux. Y a t-il des api tel win32 (pour windows )mais sous linux. Si
Lien DLL 16 / API WIN32 [ par CoreBreaker ]
Bonjour quelqu'un sait-il comment une fonction de l'API Win32 dans une DLL 16bits ?Et de manière générale comment appeler une fonction d'une DLL 32bit
API :: BMP -> RAM !! WARNING !! [ par JackosKing ]
Bon voilà, j'ai fait un projet qui peut affficher des fenetres.au debut les fenetres étaient normale (le progr prenait 800Ko en ram pour 2 fenêtres),
Question API Win32 [ par LordBob ]
Bonjours a tous,j'aimerais avoir quelques info sur les API suivante:EnumWindowsGetWindowcar sinon il faudrai que j'aille voir sur le site de la MSDN m
Existe-t-il un InvokeHelper en Api win32 [ par youpiyoyo ]
comme le titre l'indique j'aurai besoin de sauvegarder un fichier. j'aurais aimer un boite de dlg pour cela.merci d'avance...
l'API win32 sait-elle lire? [ par supergrey ]
Bonjour, je voudrais savoir s'il est possible de récupérer le texte visible dans les page web que je visite sur le net avec un programme.Merci.
2 questions en api win32 [ par youpiyoyo ]
j'aimerai tout d'abord savoir comment mettre un titre sur ma boite de dlg en api win32 sachant ke a border=none dans la gestion des ressources. a mon
Slider bar en API Win32 [ par sebseb42 ]
voila, j'utilise un controle Slider dans une fenetre que je gere en API Win32 (pas de MFC)je voudrais definir sa position initial, pour placer ;e curs
fonctions api win32 [ par mdgtr ]
salutje voudrais obtenir de l'aide apropos d'une source en c++ qui aura comme tache de commander le windows media player a partir d'une fentre mais en
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|