Solved

call a function continuously till a button on dialog box is clicked

Posted on 2004-04-28
4
231 Views
Last Modified: 2013-11-20
Hi,
 I want a call a function continuously till a button is clicked.
created a dialog resource having a listbox and a button.
as soon as the dialog opens start calling function
return from the function should be placed in list box.
this should continue untill button on dialog is clicked.

I tried putting function in a loop but it freezes the dialog untill the loop is completed.

Iam new to vc++. help me.please

Thanks
Sahaj

0
Comment
Question by:su_us_76
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 250 total points
ID: 10942696
A simple way is to use a timer.

In your OnInitDialog have a line
SetTimer(1, 100, NULL);
this should generate a timer event 10 times a second (note it doesn't mean 10 timer events in one second if the routine takes longer than 0.1 seconds or the system is busy then you will get less timer events).
map the WM_TIMER message (class wizard).
In that call your function.
For your button provide a handler with the line
KillTimer(1);
this is to stop the timer.

0
 
LVL 14

Expert Comment

by:wayside
ID: 10942870
You could create a thread which will run a loop that calls your function, and post an event back to the dialog when you want to add something in the listbox. You can use a global variable set when the button is pressed to break out of the loop and exit the thread.
0
 

Author Comment

by:su_us_76
ID: 11118952
Thanks  Andy.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
lucky13 challenge 11 158
sumHeights  challenge 17 79
Is there a simple front-end menu system. 9 121
Excel file not created as expected 7 92
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question