|
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 !
2.0 GESTION DE LA RAM EN PROGRESS BAR [VC++] API WIN32
Information sur la source
Description
Voila la version 2.0 qui sans RACPP n'aurait exister.
Merci beaucoup a lui !
Ce petit utiltaire, va vous permettre de gerer votre utilisation de Memoire Ram.
Merci de ne pas mettre de mauvaise note sans expliquer pourquoi.
Version 2.1 Release Grace a BRUNEWS :)
Source
- #define _WIN32_WINNT 0x0500
- #include <windows.h>
- #include <commctrl.h>
- #include "bnIntA.h"
- #include "resource.h"
-
- #pragma comment(lib, "comctl32.lib")
-
- HBRUSH fond;
- HWND progress, text1, text2, text3, text4, text5, text6, text7, text8;
- char szClassName[] = "WindowsApp";
-
- void __stdcall OnTimer()
- {
- MEMORYSTATUSEX statex;
- DWORD n;
- char buf[32], *c;
- statex.dwLength = sizeof (statex);
- GlobalMemoryStatusEx(&statex);
- // Obtenir la taille de la mémoire totale en Mo:
- n = (DWORD) ((statex.ullTotalPhys >> 20) + 1);
- c = bnultoa(n, buf);
- *c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
- SetWindowText(text4, buf);
- // Obtenir la taille de la mémoire disponible en Mo:
- n = (DWORD) ((statex.ullAvailPhys >> 20) + 1);
- c = bnultoa(n, buf);
- *c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
- SetWindowText(text8, buf);
- // Calculer la taille de la mémoire utilisée en Mo:
- n = (DWORD) ((statex.ullTotalPhys - statex.ullAvailPhys) >> 20);
- c = bnultoa(n, buf);
- *c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
- SetWindowText(text6, buf);
- // Obtenir le pourcentage de la mémoire utilisée:
- n = statex.dwMemoryLoad;
- c = bnultoa(n, buf);
- *c = 32; *(c+1) = '%'; *(c+2) = 0;
- SetWindowText(text1, buf);
- SendMessage(progress, PBM_SETPOS, (WPARAM) n, 0);
- if(n < 41) n = RGB(23, 219, 38);
- else if(n < 81 && n >= 41) n = RGB(255, 127, 0);
- else if(n >= 81) n = RGB(255, 66, 66);
- SendMessage(progress, PBM_SETBARCOLOR, 0, (LPARAM) n);
- }
-
- void __stdcall OnCreate(HWND hwnd)
- {
- HGDIOBJ font = GetStockObject(DEFAULT_GUI_FONT);
- progress = CreateWindowEx(CS_DBLCLKS, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH , 30, 115, 200, 50, hwnd, NULL, 0, NULL);
- text1 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_CENTER , 30,95,200,20,hwnd, 0, 0, NULL);
- SendMessage(text1, WM_SETFONT, (WPARAM)font, 0);
- text2 = CreateWindowEx(0,"STATIC","Jean G et RaCPP", WS_VISIBLE|WS_CHILD | SS_CENTER , 30,180,200,20,hwnd, 0, 0, NULL);
- SendMessage(text2, WM_SETFONT, (WPARAM)font, 0);
- text3 = CreateWindowEx(0,"STATIC","Mémoire totale\t\t:", WS_VISIBLE|WS_CHILD , 30,10,150,20,hwnd, 0, 0, NULL);
- SendMessage(text3, WM_SETFONT, (WPARAM)font, 0);
- text4 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,10,50,20,hwnd, 0, 0, NULL);
- SendMessage(text4, WM_SETFONT, (WPARAM)font, 0);
- text5 = CreateWindowEx(0,"STATIC","Mémoire utilisée\t\t:", WS_VISIBLE|WS_CHILD , 30,35,150,20,hwnd, 0, 0, NULL);
- SendMessage(text5, WM_SETFONT, (WPARAM)font, 0);
- text6 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,35,50,20,hwnd, 0, 0, NULL);
- SendMessage(text6, WM_SETFONT, (WPARAM)font, 0);
- text7 = CreateWindowEx(0,"STATIC","Mémoire disponible\t:", WS_VISIBLE|WS_CHILD , 30,60,150,20,hwnd, 0, 0, NULL);
- SendMessage(text7, WM_SETFONT, (WPARAM)font, 0);
- text8 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,60,50,20,hwnd, 0, 0, NULL);
- SendMessage(text8, WM_SETFONT, (WPARAM)font, 0);
- SendMessage(progress,PBM_SETRANGE,0,MAKELPARAM(0,100));
- SendMessage(progress, PBM_SETBKCOLOR, 0, RGB(236,233,216));
- SetTimer(hwnd,1,500,NULL);
- }
-
- LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch(message) {
- case WM_CREATE:
- OnCreate(hwnd);
- OnTimer(); // AFFICHAGE IMMEDIAT
- return 0;
- case WM_CTLCOLORSTATIC:
- SetTextColor((HDC)wParam,RGB(150,0,75));
- SetBkMode((HDC)wParam, TRANSPARENT);
- return (LRESULT)fond;
- case WM_CLOSE:
- KillTimer(hwnd,1);
- DestroyWindow(hwnd);
- return 0;
- case WM_DESTROY:
- PostQuitMessage (0);
- return 0;
- case WM_TIMER:
- OnTimer();
- return 0;
- default:
- return DefWindowProc (hwnd, message, wParam, lParam);
- }
- return 0;
- }
-
- HWND __stdcall InitInstance(HINSTANCE hinst)
- {
- WNDCLASSEX wincl;
- wincl.hInstance = hinst;
- wincl.lpszClassName = szClassName;
- wincl.lpfnWndProc = WindowProcedure;
- wincl.style = CS_HREDRAW | CS_VREDRAW;
- wincl.cbSize = sizeof(WNDCLASSEX);
- wincl.hIcon = LoadIcon(hinst, (LPCTSTR) IDI_APP);
- wincl.hIconSm = LoadIcon(hinst, (LPCTSTR) IDI_APP);
- wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
- wincl.lpszMenuName = NULL;
- wincl.cbClsExtra = 0;
- wincl.cbWndExtra = 0;
- wincl.hbrBackground = fond;
- if(!RegisterClassEx(&wincl)) return 0;
- return CreateWindowEx(WS_EX_TOPMOST, szClassName, "Mémoire RAM",
- WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, 270,240, 0, 0, hinst, 0);
- }
-
- #pragma comment(linker, "/entry:myWinMain")
- __declspec(naked) int __stdcall myWinMain()
- {
- __asm {
- call dword ptr InitCommonControls
- push 0D8E9ECh ; RGB(236, 233, 216)
- call dword ptr CreateSolidBrush
- mov fond, eax
- push 0
- call dword ptr GetModuleHandle
- push eax
- call dword ptr InitInstance
- lea ebp, [esp-28]
- test eax, eax
- je short progEXIT
- mov esp, ebp
- mov esi, GetMessage
- push SW_NORMAL
- push eax
- mov ebx, TranslateMessage
- call dword ptr ShowWindow
- mov edi, DispatchMessage
- getMSG:
- push 0
- push 0
- push 0
- push ebp
- call esi
- test eax, eax
- je short progEXIT
- push ebp
- call ebx
- push ebp
- call edi
- jmp short getMSG
- progEXIT:
- push 0
- call dword ptr ExitProcess
- }
- }
-
- //int WINAPI WinMain(HINSTANCE hinst, HINSTANCE x, LPSTR y, int z)
- //{
- // MSG messages;
- // HWND hwnd;
- // InitCommonControls();
- // fond = CreateSolidBrush(RGB(236,233,216));
- // hwnd = InitInstance(hinst);
- // if(!hwnd) return 0;
- // ShowWindow(hwnd, SW_SHOW);
- // while(GetMessage(&messages, 0, 0, 0)) {
- // TranslateMessage(&messages);
- // DispatchMessage(&messages);
- // }
- // DeleteObject(fond);
- // return 0;
- //}
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <commctrl.h>
#include "bnIntA.h"
#include "resource.h"
#pragma comment(lib, "comctl32.lib")
HBRUSH fond;
HWND progress, text1, text2, text3, text4, text5, text6, text7, text8;
char szClassName[] = "WindowsApp";
void __stdcall OnTimer()
{
MEMORYSTATUSEX statex;
DWORD n;
char buf[32], *c;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx(&statex);
// Obtenir la taille de la mémoire totale en Mo:
n = (DWORD) ((statex.ullTotalPhys >> 20) + 1);
c = bnultoa(n, buf);
*c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
SetWindowText(text4, buf);
// Obtenir la taille de la mémoire disponible en Mo:
n = (DWORD) ((statex.ullAvailPhys >> 20) + 1);
c = bnultoa(n, buf);
*c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
SetWindowText(text8, buf);
// Calculer la taille de la mémoire utilisée en Mo:
n = (DWORD) ((statex.ullTotalPhys - statex.ullAvailPhys) >> 20);
c = bnultoa(n, buf);
*c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
SetWindowText(text6, buf);
// Obtenir le pourcentage de la mémoire utilisée:
n = statex.dwMemoryLoad;
c = bnultoa(n, buf);
*c = 32; *(c+1) = '%'; *(c+2) = 0;
SetWindowText(text1, buf);
SendMessage(progress, PBM_SETPOS, (WPARAM) n, 0);
if(n < 41) n = RGB(23, 219, 38);
else if(n < 81 && n >= 41) n = RGB(255, 127, 0);
else if(n >= 81) n = RGB(255, 66, 66);
SendMessage(progress, PBM_SETBARCOLOR, 0, (LPARAM) n);
}
void __stdcall OnCreate(HWND hwnd)
{
HGDIOBJ font = GetStockObject(DEFAULT_GUI_FONT);
progress = CreateWindowEx(CS_DBLCLKS, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH , 30, 115, 200, 50, hwnd, NULL, 0, NULL);
text1 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_CENTER , 30,95,200,20,hwnd, 0, 0, NULL);
SendMessage(text1, WM_SETFONT, (WPARAM)font, 0);
text2 = CreateWindowEx(0,"STATIC","Jean G et RaCPP", WS_VISIBLE|WS_CHILD | SS_CENTER , 30,180,200,20,hwnd, 0, 0, NULL);
SendMessage(text2, WM_SETFONT, (WPARAM)font, 0);
text3 = CreateWindowEx(0,"STATIC","Mémoire totale\t\t:", WS_VISIBLE|WS_CHILD , 30,10,150,20,hwnd, 0, 0, NULL);
SendMessage(text3, WM_SETFONT, (WPARAM)font, 0);
text4 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,10,50,20,hwnd, 0, 0, NULL);
SendMessage(text4, WM_SETFONT, (WPARAM)font, 0);
text5 = CreateWindowEx(0,"STATIC","Mémoire utilisée\t\t:", WS_VISIBLE|WS_CHILD , 30,35,150,20,hwnd, 0, 0, NULL);
SendMessage(text5, WM_SETFONT, (WPARAM)font, 0);
text6 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,35,50,20,hwnd, 0, 0, NULL);
SendMessage(text6, WM_SETFONT, (WPARAM)font, 0);
text7 = CreateWindowEx(0,"STATIC","Mémoire disponible\t:", WS_VISIBLE|WS_CHILD , 30,60,150,20,hwnd, 0, 0, NULL);
SendMessage(text7, WM_SETFONT, (WPARAM)font, 0);
text8 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,60,50,20,hwnd, 0, 0, NULL);
SendMessage(text8, WM_SETFONT, (WPARAM)font, 0);
SendMessage(progress,PBM_SETRANGE,0,MAKELPARAM(0,100));
SendMessage(progress, PBM_SETBKCOLOR, 0, RGB(236,233,216));
SetTimer(hwnd,1,500,NULL);
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_CREATE:
OnCreate(hwnd);
OnTimer(); // AFFICHAGE IMMEDIAT
return 0;
case WM_CTLCOLORSTATIC:
SetTextColor((HDC)wParam,RGB(150,0,75));
SetBkMode((HDC)wParam, TRANSPARENT);
return (LRESULT)fond;
case WM_CLOSE:
KillTimer(hwnd,1);
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return 0;
case WM_TIMER:
OnTimer();
return 0;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
HWND __stdcall InitInstance(HINSTANCE hinst)
{
WNDCLASSEX wincl;
wincl.hInstance = hinst;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_HREDRAW | CS_VREDRAW;
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hIcon = LoadIcon(hinst, (LPCTSTR) IDI_APP);
wincl.hIconSm = LoadIcon(hinst, (LPCTSTR) IDI_APP);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = fond;
if(!RegisterClassEx(&wincl)) return 0;
return CreateWindowEx(WS_EX_TOPMOST, szClassName, "Mémoire RAM",
WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, 270,240, 0, 0, hinst, 0);
}
#pragma comment(linker, "/entry:myWinMain")
__declspec(naked) int __stdcall myWinMain()
{
__asm {
call dword ptr InitCommonControls
push 0D8E9ECh ; RGB(236, 233, 216)
call dword ptr CreateSolidBrush
mov fond, eax
push 0
call dword ptr GetModuleHandle
push eax
call dword ptr InitInstance
lea ebp, [esp-28]
test eax, eax
je short progEXIT
mov esp, ebp
mov esi, GetMessage
push SW_NORMAL
push eax
mov ebx, TranslateMessage
call dword ptr ShowWindow
mov edi, DispatchMessage
getMSG:
push 0
push 0
push 0
push ebp
call esi
test eax, eax
je short progEXIT
push ebp
call ebx
push ebp
call edi
jmp short getMSG
progEXIT:
push 0
call dword ptr ExitProcess
}
}
//int WINAPI WinMain(HINSTANCE hinst, HINSTANCE x, LPSTR y, int z)
//{
// MSG messages;
// HWND hwnd;
// InitCommonControls();
// fond = CreateSolidBrush(RGB(236,233,216));
// hwnd = InitInstance(hinst);
// if(!hwnd) return 0;
// ShowWindow(hwnd, SW_SHOW);
// while(GetMessage(&messages, 0, 0, 0)) {
// TranslateMessage(&messages);
// DispatchMessage(&messages);
// }
// DeleteObject(fond);
// return 0;
//}
Conclusion
sera encore et encore mis a jour prochainement selon vos commantaire !
pour me suggerer quelque amelioration n'oublier pas les Message Prive et mon email : Jean_guis (AT) hotmail.com
Bon coding :)
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
- 09 février 2006 10:44:26 :
- Code au Norm, Reduction de l'exe.
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
|