当前位置: 代码迷 >> WinCE >> 內存沒有正常釋放,找不到原因
  详细解决方案

內存沒有正常釋放,找不到原因

热度:81   发布时间:2016-04-28 12:36:32.0
【求助】內存沒有正常釋放,找不到原因
這是一個WinMo今日快速啟動插件。
有五個圖標,目前只能響應點擊。
載入后內存佔用24,點擊50次后內存佔用32,不知道哪邊沒有釋放乾淨。

// HelloWorldTodayPlug.cpp : 定义 DLL 应用程序的入口点。
//

extern "C" _declspec(dllexport) HWND APIENTRY InitializeCustomItem(TODAYLISTITEM, HWND);
extern "C" _declspec(dllexport) DWORD APIENTRY CustomOptionsDlgProc();
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
#include "HelloWorldTodayPlug.h"

HINSTANCE g_hInst;
HWND g_hWndParent;

#define IMAGE_1 L"\\TodayLauncher\\1.bmp"
#define IMAGE_2 L"\\TodayLauncher\\2.bmp"
#define IMAGE_3 L"\\TodayLauncher\\3.bmp"
#define IMAGE_4 L"\\TodayLauncher\\4.bmp"
#define IMAGE_5 L"\\TodayLauncher\\5.bmp"

#define IMAGE_AT1 L"\\TodayLauncher\\~1.bmp"
#define IMAGE_AT2 L"\\TodayLauncher\\~2.bmp"
#define IMAGE_AT3 L"\\TodayLauncher\\~3.bmp"
#define IMAGE_AT4 L"\\TodayLauncher\\~4.bmp"
#define IMAGE_AT5 L"\\TodayLauncher\\~5.bmp"

int FocusSel;
void DrawUI(HDC hDC, int type);
void FillSolidRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clr);

int Length;

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
 )
{
    return TRUE;
}

LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch(msg)
{
case WM_CREATE:
{
FocusSel = 0;
Length = GetSystemMetrics(SM_CXSCREEN) / 5;
}
break;
case WM_ERASEBKGND:
{
DrawUI((HDC)wParam, FocusSel);
return TRUE;
}
break;
case WM_TODAYCUSTOM_QUERYREFRESHCACHE:
if (!((TODAYLISTITEM*)wParam)->cyp)
{
((TODAYLISTITEM*)wParam)->cyp = GetSystemMetrics(SM_CXSCREEN)/5;
return TRUE;
}

break;

case WM_TODAYCUSTOM_CLEARCACHE:
{
}
break;

case WM_PAINT:
{
PAINTSTRUCT pt;
HDC dc = BeginPaint(hWnd, &pt);
SetBkMode(dc, TRANSPARENT);

  DrawUI(dc, FocusSel);

EndPaint(hWnd, &pt);
ReleaseDC(hWnd, dc);

return 0;
}
break;

case WM_LBUTTONUP:
{
POINT pt;
pt.x = LOWORD(lParam);

FocusSel = 0;
InvalidateRect(hWnd, NULL, FALSE);
UpdateWindow(hWnd);

if (pt.x > GetSystemMetrics(SM_CXSCREEN)/5*4)
{
//MessageBox(NULL, _T("5"), _T("Ready"), MB_OK);
}
else if (pt.x > GetSystemMetrics(SM_CXSCREEN)/5*3)
{
//MessageBox(NULL, _T("4"), _T("Ready"), MB_OK);
}
else if (pt.x > GetSystemMetrics(SM_CXSCREEN)/5*2)
{
//MessageBox(NULL, _T("3"), _T("Ready"), MB_OK);
}
else if (pt.x > GetSystemMetrics(SM_CXSCREEN)/5*1)
{
//MessageBox(NULL, _T("2"), _T("Ready"), MB_OK);
  相关解决方案