⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadpicture.cpp

📁 WINCE ARM9三星2440下的按键驱动验证程序
💻 CPP
字号:
#include   "StdAfx.h"
#include   "loadpicture.h"

void LoadResourceImage(HWND hwnd,LPCWSTR lpName,LPCWSTR lpType, int X_Start,int Y_Start,int width,int height)
{
    HDC       hdc;
    HRSRC     hr;
    DWORD     dwsize;
    HGLOBAL   hg;
    LPSTR     lp;
	RECT      rect;
    hr = FindResource(GetModuleHandle(NULL),lpName,lpType);
    dwsize = SizeofResource(GetModuleHandle(NULL),hr);
    hg = LoadResource(GetModuleHandle(NULL),hr);
    lp = (LPSTR)LockResource(hg);
    hdc = GetDC(hwnd);

	rect.left =  X_Start;
	rect.top =   Y_Start;
	rect.right = X_Start   +   width;
    rect.bottom =Y_Start   +   height;
    Drawpicture(hdc,lp,dwsize,&rect);
    ReleaseDC(hwnd, hdc) ;
    DeleteObject(hr);
 }

void Drawpicture(HDC hdc, const void *buffer,UINT size,LPCRECT rect)
{
    IImagingFactory    *pImageFactory = NULL;
    IImage             *pImage = NULL;
    if(SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) 
    {
        HRESULT hResult = 0; 
    	if(SUCCEEDED(hResult=CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,(void **)&pImageFactory)))
			{
			  hResult = 0; 	
              if(SUCCEEDED(hResult = (pImageFactory->CreateImageFromBuffer(buffer,size,DISPOSAL_NONE,&pImage))))
			  {
               pImage->Draw(hdc,rect,NULL);
               pImage->Release();
			  }
			  else MessageBox(NULL, _T("initialize failed"),_T("error"), MB_OK );
              pImageFactory->Release();
			}
		else MessageBox(NULL, _T("initialize failed"),_T("error"), MB_OK );
		if (hResult == REGDB_E_CLASSNOTREG)   MessageBox(NULL, _T("initialize failed"),_T("error"), MB_OK );
        CoUninitialize();
	 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -