示例#1
0
bool CglWnd::selectImageFile()
{
	CMzString strFilePath(MAX_PATH);
	TCHAR defDir[MAX_PATH] = {0};
	bool bSelect = false;   
	bool ret = false;
	g_config->GetValue(L"Last", L"Path", L"\\Disk\\Photo", defDir, MAX_PATH);
	bSelect = selectFile(m_hWnd, strFilePath, CMzString(L"*.jpg;*.png;"), defDir);

	if (bSelect)
	{
		showWaiting(m_hWnd);
		ImagingHelper img;
		MemoryDC memDc;
		if (img.LoadImage(strFilePath.C_Str(), true, true))
		{
			HDC dc;
			if (img.GetImageWidth() == 480 && img.GetImageHeight() == 720)
			{
				dc = img.GetDC();
			}
			else
			{
				memDc.Create(480, 720);
				RECT r;
				HBRUSH hBrush = CreateSolidBrush(RGB(0,0,0));
				SetRect(&r, 0, 0, 480, 720);
				FillRect(memDc.GetDC(), &r, hBrush);
				DeleteObject(hBrush);
				int w,h;
				if (img.GetImageWidth()*3 > img.GetImageHeight()*2)
				{
					w = 480;
					h = w*img.GetImageHeight()/img.GetImageWidth();
				}
				else
				{
					h = 720;
					w = h*img.GetImageWidth()/img.GetImageHeight();
				}
				SetRect(&r, 240 - w/2, 360 - h/2, 240 + w/2, 360 + h/2);
				img.Draw(memDc.GetDC(), &r, true, true);
				dc = memDc.GetDC();
			}

			if (setImageFromDC(dc))
			{
				ret = true;
				removeAllBubbles();
				if (extractDir(strFilePath.C_Str(), defDir))
					g_config->SetValue(L"Last", L"Path", defDir);
				
			}
		}
		hideWaiting();
	}
	return ret;
}
示例#2
0
CMzString GetMyPath()
{
    HMODULE hmodule;
    hmodule = GetModuleHandleW(NULL);
    WCHAR path[MAX_PATH];
    int i = GetModuleFileNameW(hmodule, path, MAX_PATH);

    for (; i >= 0 ; i--)
    {
        if (path[i] == L'\\')
        {
            path[i] = 0;
            break;
        }
    }
    return CMzString(path);
}