我需要不断地往画板上载入图片,已经调用了一个settimer,可是开启了多个画板,但是我只想用一个画板,不停在这个画板上加载图片,具体怎么实现。其中调用的函数是
::ShellExecute(NULL,NULL,_T("mspaint.exe"),_T("D:\\classwork\\"+aboutfile),NULL,SW_SHOWMAXIMIZED);

解决方案 »

  1.   

    把之前的那个mspaint程序关闭不可以吗?
      

  2.   

    同上。先关闭掉你那个mspaint.exe,然后再重新打开。
    默认m_bOpen = FALSE;
    OnTimer
    {
    if(m_bOpen)
    关闭掉你那个mspaint.exe;
    重新打开
    else
    打开那个mspaint.exe
    m_bOpen=TRUE;
    }
      

  3.   

    用此函数即可BOOL UseMsPaintOpenFile(CString strFilePath)
    {
        int                  nResult = TRUE;
        HWND                 hMain = NULL;
        DWORD                dwBufSize   =   0;//sizeof(DROPFILES)   +   sizeof(szFile)   +   1;  
        BYTE                 *pBuf   =   NULL; 
        DWORD                dwProcessId = 0;      HANDLE               hProcess    = 0;    LPSTR                pszRemote = NULL; 
    DROPFILES   *pDrop = NULL;
    HINSTANCE hinstance = NULL;   
    do { dwBufSize = sizeof(DROPFILES) + strlen(strFilePath.GetBuffer(0)) + 1;
    /*
    是否打开画图软件
    没打开先打开
    */ hMain = ::FindWindow(_T("MSPaintApp"),NULL);
    if ( hMain == NULL)
    {
    hinstance = ::ShellExecute(NULL,NULL,_T("mspaint.exe"),strFilePath.GetBuffer(0),NULL,SW_SHOWMAXIMIZED);

    //再次没打开,报错返回
    if ( hinstance <= (HINSTANCE)32 )
    {
    AfxMessageBox("找不到画图程序,退出");
    nResult = FALSE;
    break;
    }
    else
    break;
    } pBuf   =   new   BYTE[dwBufSize];
    if (pBuf == NULL)
    {
    nResult = FALSE;
    break;
    } memset(pBuf,0,dwBufSize);
    pDrop   =   (DROPFILES   *)pBuf; 
    pDrop->pFiles = sizeof(DROPFILES);
    strcpy((char   *)(pBuf   +   sizeof(DROPFILES)),strFilePath.GetBuffer(0));   GetWindowThreadProcessId(hMain,&dwProcessId);
    if (0 == dwProcessId)
    {
    nResult = FALSE;
    break;
    } hProcess   =   OpenProcess(PROCESS_VM_OPERATION   |   PROCESS_VM_WRITE,   FALSE,  dwProcessId); 
    if (hProcess == 0)
    {
    nResult = FALSE;
    break;
    } pszRemote   =   (LPSTR)VirtualAllocEx(hProcess,   NULL,   dwBufSize,   MEM_COMMIT,   PAGE_READWRITE);  if (NULL == pszRemote)
    {
    nResult = FALSE;
    break;
    } if(WriteProcessMemory(hProcess,   pszRemote,   pBuf,   dwBufSize,   0))
    {
    ::SendMessage(hMain, WM_DROPFILES, (WPARAM)pszRemote, NULL);
    }
    else
    {
    nResult = FALSE;
    break;
    } }while ( 0 );
        if (pBuf)
        {
            delete [] pBuf;
            pBuf = NULL;
        }    return nResult;
    }void CCFormViewView::OnCc() 
    {
    // TODO: Add your command handler code here


    }
      

  4.   


     调用方法
     UseMsPaintOpenFile(_T("C:\\WINDOWS\\River Sumida.bmp"));