Sir,
I have a dialog box with two without argument and without return type functions, a check box and has two push buttons
recycler();//---------Will empty the recycle bin
Emptier();//----------Will empty my old VS projects which I have used for learning
When the check box (Which specifically asks the user to empty the recycle bin) is checked recycler + Emptier function gets executed if the check box is unchecked Emptier function gets executed.
int checked;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
checked = IsDlgButtonChecked(hDlg, IDC_CHECK1);
if (checked) {
recycler();
Emptier();
}
else
{
Emptier();
}
break;
}
else if (LOWORD(wParam) == IDCANCEL)
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
break;
Since I cant confirm that my code has done the job I used a progress bar to do the job
here is the code for it!
case WM_INITDIALOG:
progressbar = GetDlgItem(hDlg, IDC_PROGRESS1);
SendMessage(progressbar, PBM_SETRANGE, 0, MAKELPARAM(0, 10));
SendMessage(progressbar, PBM_SETSTEP, (WPARAM)10, 0);
return (INT_PTR)TRUE;
and I have sent the message successfully to the progress bar and progress bar shows some progress.
My problem is:
Since Visual studio projects are quiet huge and consumes a lot of memory I could not guess several things.
For example, My old, useless projects which I did created for learning consumes more than a GB which I consider use less and usually my recycle bin always has more than a GB of waste files.
When I run my program the progress is shown by by my Operating system (Windows 10) like this
http://tncdn.vikitech.netdna-cdn.com/assets/6-deleting.png[
^]
in addition to my progress bar.
On experimenting with this I found my progress bar just simply shows the progress but not actually doing work.
Since my English is bad I'll try to explain this clear:
when I click on the OK button within a fraction of second my progress bars beeps a sound(I used Beep(x,y) function to know my progress has been completed)
Every time I get comments that my code is insufficient for the experts to solve to avoid my mistakes I have provided the complete code below for the convenient view!
int checked;
HWND progressbar;
INT_PTR CALLBACK Optimizer(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
progressbar = GetDlgItem(hDlg, IDC_PROGRESS1);
SendMessage(progressbar, PBM_SETRANGE, 0, MAKELPARAM(0, 10));
SendMessage(progressbar, PBM_SETSTEP, (WPARAM)10, 0);
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
checked = IsDlgButtonChecked(hDlg, IDC_CHECK1);
if (checked) {
recycler();
Emptier();
SendMessage(progressbar, PBM_STEPIT, 0, 0);
Beep(750, 100);
}
else
{
Emptier();
SendMessage(progressbar, PBM_STEPIT, 0, 0);
Beep(750,100);
}
}
else if (LOWORD(wParam) == IDCANCEL)
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
break;
case WM_CTLCOLORDLG:
{
return(LONG)DlgBackground;
}
case WM_CTLCOLORSTATIC:
{
}
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hDlg, &ps);
HBITMAP logo;
logo = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP2));
HDC logoB;
logoB = CreateCompatibleDC(hdc);
SelectObject(logoB, logo);
BitBlt(hdc, 0, 0, 4100, 4100, logoB, 10, 10, SRCCOPY);
}
}
return (INT_PTR)FALSE;
}
What I have tried:
I have referred to some experts answer and came to know that it is not the purpose of progress bar.
This is what I learnt,
One can use the progress bar only if he knows how long will the task takes place
I also referred Goggle through various key words like progress bar for unknown time and found various solutions in C# which is quiet difficult to figure out my solution
So I don't know here what should I do?
Thank you