Click here to Skip to main content
16,022,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create a MFC application to create picture viewer software. I am able to select the folder and display all the images in it at a stretch. I want to implement pause, stop, next, previous options to it. As of now, when the images are running rest of the buttons and even the menu is disabled.
I hope I made the problem clear.
I am using Visual studio 2008.
Can anyone help me out.

[edit]
Hi there,
I am sorry for coming back after so much delay. Thanks for the interest in my question. I am adding code here for review.

C++
void CCA_ToolDlg::OnBnClickedPlay()
{
	HANDLE hFind;
	string strPrefix;
	WIN32_FIND_DATA FindData;
	char pattern[150];
	sprintf(pattern, "%s\\*.jpg", ImagePath);
	sprintf(ImagePath, "%s\\", ImagePath);
	hFind = FindFirstFile(pattern, &FindData);
	char *filename;
	filename = (char *)calloc(2000,sizeof(char));
	do
	{		
		strPrefix = string(ImagePath);
		strPrefix += FindData.cFileName;
		sprintf(filename,"%s",strPrefix.c_str());
		m_picCtrl.Load(CString(_T(filename)));
	}while(FindNextFile(hFind, &FindData));
	FindClose(hFind);
	free(filename);
}

This is the function when i click on play button.
Now, when i am inside the do loop, All my dialog doesnt respond to any user inputs. I am using PictureCrtl to display the images.
So, how I can handle other button functions when this function is running.
Thanks all.
[/edit]
Posted
Updated 10-Oct-11 23:34pm
v2
Comments
[no name] 5-Oct-11 6:34am    
Unless you show some code, it is unlikely that anyone can guess what you mean by As of now, when the images are running rest of the buttons and even the menu is disabled. .
Albert Holguin 5-Oct-11 10:46am    
Problem isn't clear... do you mean your application is running as a slide show? ...and you want to be able to add those new functions?
Sathya Bhat 11-Oct-11 2:23am    
Hi there,
I am sorry for coming back after so much delay. Thanks for the interest in my question. I am adding code here for review.

void CCA_ToolDlg::OnBnClickedPlay()
{
HANDLE hFind;
string strPrefix;
WIN32_FIND_DATA FindData;
char pattern[150];
sprintf(pattern, "%s\\*.jpg", ImagePath);
sprintf(ImagePath, "%s\\", ImagePath);
hFind = FindFirstFile(pattern, &FindData);
char *filename;
filename = (char *)calloc(2000,sizeof(char));
do
{
strPrefix = string(ImagePath);
strPrefix += FindData.cFileName;
sprintf(filename,"%s",strPrefix.c_str());
m_picCtrl.Load(CString(_T(filename)));
}while(FindNextFile(hFind, &FindData));
FindClose(hFind);
free(filename);
}

This is the function when i click on play button.
Now, when i am inside the do loop, All my dialog doesnt respond to any user inputs. I am using PictureCrtl to display the images.
So, how I can handle other button functions when this function is running.
Thanks all.
Sathya Bhat 12-Oct-11 0:25am    
Hi all,
I also found the issue in my coding. I solved it using timers.
Thanks all
Mystery Box 12-Feb-24 0:04am    
Hi all
How we can set the time for creating the image and displaying that image. My issue is how to set the timer for image is been created and then displaying.

1 solution

hmm well, your problem is very simple, here is the solution

the reason you can't use the controls of the dialog is the culprit do-while loop, its executing very fast and literally hang your program until it finishes to find the last file and display its attribute.

you need to write the loop in a separate thread with a sleep of few seconds depending on how long you want one picture to stay on the screen and by that time your main dialog will respond to your mouse click or any other events.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900