Click here to Skip to main content
15,885,537 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Convert C++ from VisC++ 6 to VS 2008 Pin
Stuart Dootson20-May-09 8:24
professionalStuart Dootson20-May-09 8:24 
GeneralRe: Convert C++ from VisC++ 6 to VS 2008 Pin
gartnerj20-May-09 8:53
gartnerj20-May-09 8:53 
Questionassigning string table element to char* variable Pin
jimjim73320-May-09 5:31
jimjim73320-May-09 5:31 
QuestionRe: assigning string table element to char* variable Pin
CPallini20-May-09 5:35
mveCPallini20-May-09 5:35 
AnswerRe: assigning string table element to char* variable Pin
ThatsAlok20-May-09 21:53
ThatsAlok20-May-09 21:53 
QuestionMove the rectangle Pin
C_Hunter20-May-09 4:56
C_Hunter20-May-09 4:56 
AnswerRe: Move the rectangle Pin
Hamid_RT20-May-09 19:23
Hamid_RT20-May-09 19:23 
QuestionApply Wim with no progress bar. Pin
Drakesal20-May-09 4:45
Drakesal20-May-09 4:45 
In this days i'm writing a software to use for recovery PC. My software is complete but i need a progress bar moves during file extraction, i am trying but in 10 days nothing. How i can solve??? i post only the complete wim code. Please help me Frown | :(

// WimApplyProgressDlg.cpp : file di implementazione
//

#include "stdafx.h"
#include "WimApplyProgress.h"
#include "WimApplyProgressDlg.h"
#include <wimgapi.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

CProgressCtrl *Progress = new CProgressCtrl;

CWimApplyProgressDlg::CWimApplyProgressDlg(CWnd* pParent /*=NULL*/)
     : CDialog(CWimApplyProgressDlg::IDD, pParent)
{
     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CWimApplyProgressDlg::DoDataExchange(CDataExchange* pDX)
{
     CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CWimApplyProgressDlg, CDialog)
     ON_WM_PAINT()
     ON_WM_QUERYDRAGICON()
     //}}AFX_MSG_MAP
     ON_BN_CLICKED(IDOK, &CWimApplyProgressDlg::OnBnClickedOk)
END_MESSAGE_MAP()


// gestori di messaggi di CWimApplyProgressDlg

BOOL CWimApplyProgressDlg::OnInitDialog()
{
     CDialog::OnInitDialog();

     // Impostare l'icona per questa finestra di dialogo. Il framework non esegue questa operazione automaticamente
     //   se la finestra principale dell'applicazione non è una finestra di dialogo.
     SetIcon(m_hIcon, TRUE);               // Impostare icona grande.
     SetIcon(m_hIcon, FALSE);          // Impostare icona piccola.

     Progress->Create(WS_CHILD | WS_VISIBLE, CRect(10, 10, 288, 35), this,0x16);
     Progress->SetRange(1, 100);
     Progress->SetPos(0);

     return TRUE;   // restituisce TRUE a meno che non venga impostato lo stato attivo su un controllo.
}

// Se si aggiunge alla finestra di dialogo un pulsante di riduzione a icona, per trascinare l'icona sarà necessario
//   il codice sottostante. Per le applicazioni MFC che utilizzano il modello documento/visualizzazione,
//   questa operazione viene eseguita automaticamente dal framework.

void CWimApplyProgressDlg::OnPaint()
{
     if (IsIconic())
     {
          CPaintDC dc(this); // contesto di dispositivo per il disegno

          SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

          // Centrare l'icona nel rettangolo client.
          int cxIcon = GetSystemMetrics(SM_CXICON);
          int cyIcon = GetSystemMetrics(SM_CYICON);
          CRect rect;
          GetClientRect(&rect);
          int x = (rect.Width() - cxIcon + 1) / 2;
          int y = (rect.Height() - cyIcon + 1) / 2;

          // Disegnare l'icona
          dc.DrawIcon(x, y, m_hIcon);
     }
     else
     {
          CDialog::OnPaint();
     }
}

// Il sistema chiama questa funzione per ottenere la visualizzazione del cursore durante il trascinamento
//   della finestra ridotta a icona.
HCURSOR CWimApplyProgressDlg::OnQueryDragIcon()
{
     return static_cast<HCURSOR>(m_hIcon);
}

DWORD WINAPI ApplyCallback(DWORD msgId,WPARAM param1,LPARAM param2,void   *unused)
{
      //First parameter: full file path for if WIM_MSG_PROCESS, message string for others
      TCHAR *message   = (TCHAR *) param1;
      TCHAR *filePath = (TCHAR *) param1;
      int      percent   = (int)      param1;


      //Second parameter: message back to caller if WIM_MSG_PROCESS, error code for others
      DWORD errorCode = param2;
      DWORD *msg_back = (DWORD *) param2;

      switch ( msgId )
      {

     case WIM_MSG_PROGRESS:
          Progress->SetPos(percent);
          break;

     }
      return WIM_MSG_SUCCESS;
}

void CWimApplyProgressDlg::OnBnClickedOk()
{
HANDLE hWim = NULL, hImg = NULL;

     // Get source, destination strings and other info
      WCHAR wimFile[MAX_PATH] = L"C:\\boot.wim";
     FARPROC callback = (FARPROC) ApplyCallback;

     //Create the WIM file
     DWORD created;
     hWim = WIMCreateFile(wimFile, WIM_GENERIC_READ, WIM_OPEN_EXISTING,WIM_FLAG_VERIFY, 0, &created);
     if (!hWim) {
          MessageBox("Impossibile trovare il file WIM", "Errore", MB_OK | MB_ICONEXCLAMATION);
          WIMCloseHandle(hWim);
          return;
     }

     if (WIMRegisterMessageCallback(hWim,callback,NULL ) == INVALID_CALLBACK_VALUE) {
          MessageBox("Callback error","Errore",MB_OK | MB_ICONEXCLAMATION);
            return;
      }
    
      WCHAR tempDir[MAX_PATH] = L"C:\\mounted_wim";
     if (!WIMSetTemporaryPath(hWim, tempDir)) {
          MessageBox("Impossibile impostare la cartella di lavoro","Errore",MB_OK | MB_ICONEXCLAMATION);
          WIMCloseHandle(hWim);
          return;
     }    
    
     hImg = WIMLoadImage ( hWim, 1 );
      if ( !hImg ) {
            MessageBox("Non posso caricare l'immagine", "Errore", MB_OK | MB_ICONEXCLAMATION);
          WIMCloseHandle(hWim);
          WIMCloseHandle(hImg);
          return;
      }
     if (!WIMApplyImage(hImg, L"Y:\\",0)) {
          MessageBox("Applying image failed","Error", MB_OK | MB_ICONEXCLAMATION);
          WIMCloseHandle(hWim);
          WIMCloseHandle(hImg);         
          return;
     }
     OnOK();
}

with this code all is blocked if i remove the item "Progress->SetPos(percent);" all go ok but without progress bar moving.
AnswerRe: Apply Wim with no progress bar. Pin
Cedric Moonen20-May-09 4:48
Cedric Moonen20-May-09 4:48 
QuestionButton does not change the position when I resize my dialog Pin
pandit8420-May-09 4:25
pandit8420-May-09 4:25 
AnswerRe: Button does not change the position when I resize my dialog Pin
Cedric Moonen20-May-09 4:40
Cedric Moonen20-May-09 4:40 
AnswerRe: Button does not change the position when I resize my dialog Pin
Rajesh R Subramanian20-May-09 4:59
professionalRajesh R Subramanian20-May-09 4:59 
GeneralRe: Button does not change the position when I resize my dialog Pin
pandit8420-May-09 5:03
pandit8420-May-09 5:03 
AnswerRe: Button does not change the position when I resize my dialog Pin
David Crow20-May-09 5:42
David Crow20-May-09 5:42 
QuestionSet Dialog Size Pin
MsmVc20-May-09 2:55
MsmVc20-May-09 2:55 
AnswerRe: Set Dialog Size Pin
Cedric Moonen20-May-09 3:03
Cedric Moonen20-May-09 3:03 
AnswerRe: Set Dialog Size Pin
Nuri Ismail20-May-09 3:08
Nuri Ismail20-May-09 3:08 
QuestionRe: Set Dialog Size Pin
David Crow20-May-09 5:45
David Crow20-May-09 5:45 
QuestionCode from visual studio 7.1 don't want to work on visual studio 2008 Pin
hrddd20-May-09 2:51
hrddd20-May-09 2:51 
AnswerRe: Code from visual studio 7.1 don't want to work on visual studio 2008 Pin
Cedric Moonen20-May-09 3:02
Cedric Moonen20-May-09 3:02 
QuestionADO in a DLL Pin
staticv20-May-09 2:51
staticv20-May-09 2:51 
AnswerRe: ADO in a DLL Pin
led mike20-May-09 4:29
led mike20-May-09 4:29 
GeneralRe: ADO in a DLL Pin
staticv20-May-09 5:25
staticv20-May-09 5:25 
GeneralRe: ADO in a DLL Pin
led mike20-May-09 6:00
led mike20-May-09 6:00 
GeneralRe: ADO in a DLL Pin
staticv20-May-09 6:12
staticv20-May-09 6:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.