In my application I have a simple module were I will read files for some process that will take
few seconds..so I thought of displaying a progress bar(using worker thread) while the files are in progress.I have created a thread (code shown below) and also I designed a dialog window with progress control.I used the function MyThreadFunction below to display the progressbar but it just shows only one time and disappears,I am not sure how to make it work.I tried my best inspite of the fact that I am new to threading. - reading files
-
void ReadMyFiles()
-
{
-
-
for(int i = 0; i < fileCount ; fileCount++)
-
{
-
CWinThread* myThread = AfxBeginThread((AFX_THREADPROC)MyThreadFunction,NULL);
-
tempState = *(checkState + index);
-
if(tempCheckState == NOCHECKBOX)
-
{
-
//my operations
-
}
-
else//CHECKED or UNCHECKED
-
{
-
//myoperation
-
}
-
myThread->PostThreadMessage(WM_QUIT,NULL,NULL);
-
}
-
}
thread functions -
UINT MyThreadFunction(LPARAM lparam)
-
{
-
HWND dialogWnd = CreateWindowEx(0,WC_DIALOG,L"Proccessing...",WS_OVERLAPPEDWINDOW|WS_VISIBLE,
-
600,300,280,120,NULL,NULL,NULL,NULL);
-
HWND pBarWnd = CreateWindowEx(NULL,PROGRESS_CLASS,NULL,WS_CHILD|WS_VISIBLE|PBS_MARQUEE,40,20,200,20,
-
dialogWnd,(HMENU)IDD_PROGRESS,NULL,NULL);
-
-
MSG msg;
-
-
PostMessage( pBarWnd, PBM_SETRANGE, 0, MAKELPARAM( 0, 100 ) );
-
PostMessage(pBarWnd,PBM_SETPOS,0,0);
-
while(PeekMessage(&msg,NULL,NULL,NULL,PM_NOREMOVE))
-
{
-
if(msg.message == WM_QUIT)
-
{
-
DestroyWindow(dialogWnd);
-
return 1;
-
}
-
AfxGetThread()->PumpMessage();
-
Sleep(40);
-
}
-
return 1;
-
-
-
}
-
0 1251 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Stuart Norris |
last post by:
Dear Group,
I am attempting to write a "splash" and "status" Form using a second
thread.
I wish to use this Form to display status information to the user when
I do CPU intensive work in my...
|
by: |
last post by:
Hi all I am posting this to check if anyone could help
me. The problem still persists. I am beginner in C#.
Thanks.
Subject: SQLDMO.Backup and ProgressBar - help please
From: ...
|
by: needin4mation |
last post by:
Please consider:
foreach (ListViewItem item in listViewFiles.Items)
{
// Display the ProgressBar control.
pBar1.Visible = true;
// Set Minimum to 1 to represent the first file being copied....
|
by: Mehr H |
last post by:
I've been trying to figure out how i can embed a Windows.Forms.ProgressBar
in my webform (aspx) file.
I have tried putting a Windows.Forms.ProgressBar as public on a regular
winform designer form...
|
by: Nicolas |
last post by:
When I resize (Enlarge) the form while the progress bar is running the
rectangle drawing is not going to the end of the rectangle?
I got a form with one button, one statusbar with three...
|
by: pmcguire |
last post by:
Rather than putting a progress bar on all of my forms to show progress during time consuming tasks, I made a form called frmProgress with 2 controls, a Label and a ProgressBar. Suppose I expose 1...
|
by: sotto |
last post by:
I need a loginscreen, that will show a progressbar that changes values
based on a method in the main application (loading data from database)
how would i do this?
(i guess i need threading for...
|
by: nobody |
last post by:
Hi
I'm currently developing a Windows application. At the start of the
application I load several tables into datatables in a dataset. I also use
a progressbar to show the user how much percent...
|
by: =?Utf-8?B?QWFyb24=?= |
last post by:
Since some controls such as the DataGridView take a long time to update
themselves when performing certain tasks, I have added a StatusStrip with a
ProgressBar on it. While I am updating the...
|
by: =?Utf-8?B?Q2hyaXM=?= |
last post by:
I want to create an app in VS 2003 (not in 2005 !!).
It works this way: user chooses an excel file in openfiledialog. then he
clicks OK and a new form appears. There is a progressbar on the form....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |