To get a Window-like progress bar I tried this way.
#include /* #define PB_DELTAPOS PBM_DELTAPOS #define PB_SETPOS PBM_SETPOS #define PB_SETRANGE PBM_SETRANGE #define PB_SETSTEP PBM_SETSTEP #define PB_STEPIT PBM_STEPIT */ extern int CreateProgressBar (int panelhandle, int left, int top, int width, int height, HWND *handlePB); extern void DestroyProgressBar (HWND handlePB); extern void ResetProgressBar (HWND handlePB); extern int ConvertFromGraphProgressBar (int panelhandle, int controlID, HWND *handlePB);
#include #include //#include NON SI PUO' INCLUDERE PROBLEMI CON GetFileSize #include
HINSTANCE g_hinst;
static RECT rcClient; // client area of parent window static int cyVScroll; // height of scroll bar arrow
/* * CreateProgressBar * disegna una Progress Bar * POSIZIONE : * di default (left = 0, top = 0, width = 0, height = 0) sul fondo della finestra padre * altrimenti e' possibile impostare valori diversi per ognuno o qualcuno dei quattro * valori impostabili (left, top, width, height) * RESTITUISCE : * 1) handle (HWND) della Progress Bar a cui riferirsi per le altre funzioni * 2) error (int) 0 se operazione riuscita con successo * */ int CreateProgressBar (int panelhandle, int left, int top, int width, int height, HWND *handlePB) { HWND hwndParent; int number, error;
#include #include /* Needed if linking in external compiler; harmless otherwise */ //#include #include "panello.h"
static int panelHandle;
// ParseALargeFile - parses a large file and uses a progress bar to // indicate the progress of the parsing operation. // Returns TRUE if successful or FALSE otherwise. // hwndParent - parent window of the progress bar // lpszFileName - name of the file to parse // // Global variable // g_hinst - instance handle #include #include //#include NON SI PUO' INCLUDERE PROBLEMI CON GetFileSize #include
BOOL ParseALargeFile(LPSTR lpszFileName) { HANDLE hFile; // handle of file DWORD cb; // size of file and count of bytes read LPCH pch; // address of data read from file LPCH pchTmp; // temporary pointer long pippo;
// Ensure that the common control DLL is loaded and create a // progress bar along the bottom of the client area of the // parent window. Base the height of the progress bar on // the height of a scroll bar arrow.
// Open the file for reading, and retrieve the size of the file. hFile = CreateFile(lpszFileName, GENERIC_READ, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL);
if (hFile == (HANDLE) INVALID_HANDLE_VALUE) return FALSE;
// Set the range and increment of the progress bar. SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, cb / 2048)); SendMessage(hwndPB, PBM_SETSTEP, (WPARAM) 1, 0);
// Advance the current position of the progress bar // by the increment. SendMessage(hwndPB, PBM_STEPIT, 0, 0); } while (cb);
ResetProgressBar (hwndPB);
CloseHandle((HANDLE) hFile);
return TRUE; }
int main (int argc, char *argv[]) {
if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */ return -1; /* out of memory */ if ((panelHandle = LoadPanel (0, "panello.uir", PANEL)) < 0) return -1; DisplayPanel (panelHandle);
DrawProgressBar (panelHandle, &hwndPB);
RunUserInterface ();
return 0; }
int CVICALLBACK ExitApp_xButton (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: EraseProgressBar (hwndPB);
QuitUserInterface (0); break; } return 0; }
int CVICALLBACK StartProgressBar (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) {
switch (event) { case EVENT_COMMIT: ParseALargeFile ("pippo.ppp");
Why not just use a horizontal slide control on your UIR panel? I'm sorry I don't understand your (Italian?) comments or see what your problem is, but placing and editing a slide control in the UIR editor has to be easier than trying to create one in your program.