Accueil > > > 2.0 GESTION DE LA RAM EN PROGRESS BAR [VC++] API WIN32
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 :)
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
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
|
Derniers Blogs
TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|