TimerProc and accessing dialog members

Hi,

this is my problem: I want to access members of my CDialog class from a
TimerProc function (I'm using SetTimer to call TimerProc). Since TimerProc
is static, there seems to be no way to access the dialog's members. Can I
use the HWND parameter that is passed to TimerProc? What I specifically
want to do is call UpdateData on the CDialog that created the timer that
calls TimerProc, from TimerProc. Did you get that? :-)
Thanks for any help!

-- 
Daniel
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
0
someone913 (592)
11/25/2004 3:31:22 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
397 Views

Similar Articles

[PageSpeed] 37

Ummm not sure if I got that or not, is this what you are (essentially) 
trying to do:
UINT IDT_TIMER_AFS = WM_USER + 200;



void CECIASDemoDlg::OnTimer(UINT TimerVal)

{

if (TimerVal == IDT_TIMER_AFS) {

this->UpdateData(TURE);

return;

}

}


"Daniel Lidstr�m" <someone@microsoft.com> wrote in message 
news:mmd5lo4yn45r$.9numn2koa6jx$.dlg@40tude.net...
> Hi,
>
> this is my problem: I want to access members of my CDialog class from a
> TimerProc function (I'm using SetTimer to call TimerProc). Since TimerProc
> is static, there seems to be no way to access the dialog's members. Can I
> use the HWND parameter that is passed to TimerProc? What I specifically
> want to do is call UpdateData on the CDialog that created the timer that
> calls TimerProc, from TimerProc. Did you get that? :-)
> Thanks for any help!
>
> -- 
> Daniel
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail? 


0
Arlis
11/25/2004 4:09:50 PM
On Thu, 25 Nov 2004 11:09:50 -0500, Arlis Rose wrote:

> Ummm not sure if I got that or not, is this what you are (essentially) 
> trying to do:
> UINT IDT_TIMER_AFS = WM_USER + 200;
> 
> 
> 
> void CECIASDemoDlg::OnTimer(UINT TimerVal)
> 
> {
> 
> if (TimerVal == IDT_TIMER_AFS) {
> 
> this->UpdateData(TURE);
> 
> return;
> 
> }
> 
> }

No, not quite. What I'm trying to do is this:

void SurfPage::OnLoop()
{
   if( m_looping )
      ::KillTimer(NULL, m_nTimer);
   else
      m_nTimer = ::SetTimer(NULL, 1, 100, (TIMERPROC)TimerProc);

   m_looping = !m_looping;
}

/* static */
VOID CALLBACK SurfPage::TimerProc(
   HWND hwnd,         // handle to window
   UINT uMsg,         // WM_TIMER message
   UINT_PTR idEvent,  // timer identifier
   DWORD dwTime       // current system time
)
{
   // set m_val to something
   // then update CEdit control in SurfPage.
   // m_val is connected to the CEdit box through
   // DDX. How can I change the displayed value in the
   // CEdit box? This is a static function, that is the
   // whole problem.
}

Thanks!

-- 
Daniel
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
0
someone913 (592)
11/26/2004 9:02:58 AM
Daniel Lidstr�m wrote:
> No, not quite. What I'm trying to do is this:
> 
> void SurfPage::OnLoop()
> {
>    if( m_looping )
>       ::KillTimer(NULL, m_nTimer);
>    else
>       m_nTimer = ::SetTimer(NULL, 1, 100, (TIMERPROC)TimerProc);
> 
>    m_looping = !m_looping;
> }
> 
> /* static */
> VOID CALLBACK SurfPage::TimerProc(
>    HWND hwnd,         // handle to window
>    UINT uMsg,         // WM_TIMER message
>    UINT_PTR idEvent,  // timer identifier
>    DWORD dwTime       // current system time
> )
> {
>    // set m_val to something
>    // then update CEdit control in SurfPage.
>    // m_val is connected to the CEdit box through
>    // DDX. How can I change the displayed value in the
>    // CEdit box? This is a static function, that is the
>    // whole problem.
> }
> 
> Thanks!
> 

The static function needs a static variable that is a pointer to the 
dialog box.  When you create the dialog set the pointer.  The static 
function can use it to call a dialog function, or to send/post a message 
to the dialog.  Then a dialog function should do the update.

But why not use a WM_TIMER message handler?  If you do that then MFC 
solves this problem for you, by calling your nonstatic handler function.

If you are trying to update the dialog from a separate thread then 
neither approach will work, and you asked the wrong question.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
11/26/2004 2:08:38 PM
Reply:

Similar Artilces:

Access OWA during exchange offline
Dear All AS we know, we can access Our inbox (via Ms Outlook) during exhange server down or offline. My concern is, can wee access our inbox or calendar during exchange server is offline? thank you.. In news:%23YTtmu97FHA.2036@TK2MSFTNGP14.phx.gbl, Muhamad Taufik Khasim <Taufik@uniten.edu.my> typed: > Dear All > > AS we know, we can access Our inbox (via Ms Outlook) during exhange > server down or offline. > My concern is, can wee access our inbox or calendar during exchange > server is offline? > > thank you.. No.....only when your mailbox is accessibl...

Macro to import external data from Access query to Excel
I have tried to post this a couple times, but don't see it after I post it... so if it out here three times, I am sorry! I am trying to write code that will allow me to pull in information for different areas depending on the file that I am creating. For example, I will create a file for US006 and want the external information for US006 and then create a file for US007 and want the information for US007. I created the code below. The fourth line from the bottom references US006. I would like that to be a variable dependent on the file I am creating. I cannot seem to g...

Dynamic Dialog
I am fairly new to UI programming using VC++. I am looking for ways to modify a dialog box dynamically. In other words, I want to be able to add controls to an exisitng dialog during run time. This is a simple dialog which will be empty initially. Just before it is shown, I want to be able to add rows or columns of check boxes with static texts next to them, based on some strings read from the registry. Is this possible? How? Any code sample will be helpful. Thanks in advance Scott, Thanks very much for the quick reply. The reason I have to add them dynamically as opposed to during d...

Close dialog
Hello, On my dialog I have a CEdit control. When I type some text in the CEdit control and then press <ENTER> the dialog closes. I don't want the dialog to close. Can anybody help me? Greeting Marco Hi Marco, You need to override the PreTranslateMessage(..) Virtual function into your dialog using the class wizard. Your can implement this function as shown below, this should solve the problem. You'll just have to change IDC_YOUREDIT with the name of your CEdit object and CYourDialog with your dialog box class name. BOOL CYourDialog::PreTranslateMessage(MSG* pMsg) { ...

Vista Access 2003 & Ole
I have a DB I've been using, updating for several years. I use a = different BMP on every record. Today I started to update it again. Last = update a few weeks ago on my XP. Today I went with 'insert object' 'create from file'. with XP I couldn't = use JPG's so I made bmp's. Today even a bmp is just an icon. How do I get the create from file to work again ? --=20 more pix @ http://members.toast.net/cbminfo/index.html ...

Identifying remote Outlook Access
Scenario. I am running outlook 2002 on NT4.0 connected to exchange mailbox on exchange 5.5/2000. Is there any way I can identify whether the Administrator or exchange Admin has my mailbox open on his PC or is accessing my mailbox via his security access. Can i tell on my PC. Is there something left locally on my PC that will tell me. No, you can't. Why the suspicion? -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... Tip of the month: -Create your own fully customized Toolbar Subscribe to the...

How do i fix this error in access
I created a database in microsoft access. I have been trying to open some of the forms that I created but after several tries I keep getting this error message "Not enough memory. Please close un-needed programs." Can someone please help in fixing this. I created 13 forms and 8 of the forms are opening but the other five forms arent. I get the above error when I try. I have uninstalled and re-installed microsoft office several times, and no other programs are opened when I get this error. Any help is appreciated. Thanks Alicia Alicia, unless you actually do have too man...

open/save dialog title broken
The title bar of any Office 2003 program's open/save dialog has just a single letter. Any ideas what's broken? tbone ...

CreateDatabase / Access 2007
Hi all, Question: Can Access 2007 be forced to create an Access 2000 database when using CreateDatabase? I have a "utility" database that I distribute in version 2000 to users which is used to extract data from their main database (also version 2000) and which then creates and dumps this data into a new database ("Homedata.mdb"). This new database can then be zipped up, emailed, and uploaded into our central database. The basic procedure is: Data is extracted from the user's main database; placed in tables within the "utility" database; "H...

how to improve shared mailbox access from branch office
Hi, Our organization has consolidated all mailboxes to centralize location. A team of shared services specialist who often work on the shared mailbox encounter performance issues when trying to access the shared mailbox due to the shared mailbox are being accessed over the WAN in online mode. The shared mailbox is attached as a secondary mailbox to their personal mailbox. Personal mailbox does not have this issue due to all are configure to use Exchange cache mode. We have proposed to user Terminal server nearer to the centralize location and Outlook Web Access but the team...

Keyboard hooking through Accessibility
I am looking for a method to hook the keyboard without running a background process. I know there are APIs for hooking (SetWindowsHookEx), but I want to avoid the overhead of running another background process for this and make the task do by windows itself. I am thinking of tweaking the Accessibility option in windows for this. Can we anyway do this by writing any script or modifying or adding registry entries for Accessibility? Or is there any Accessibility specific APIs which can re-program the Accessibility feature to do our tasks when we press a key with Accessibility feature-on. An...

unable to access mail after re-enable account
Hi, After enable an disable account and change its password, it can login to its mail account. What's happening. Is it normal? Thanks a lot What is the error message when user tries to access mailbox? Does the user still show in ADUC has having Exchange attributes? Have you looked at the MB using ESM to see if it is disconnected? "Raymond" <anonymous@discussions.microsoft.com> wrote in message news:136c01c46f11$d16f8390$a301280a@phx.gbl... > Hi, > > After enable an disable account and change its password, > it can login to its mail account. What's hap...

Stingray's MFC Objective Grid with Access 2K?
Has anyone had success using Stingray's Objective Grid v7.0 with the later versions of DAO. I've seen the suggestions to add an entry to my source to force MFC to use the later version. But, when I do this, I get a lot of crashes after compiling. I wonder if there are any mods that must also be made to the Stingray source? Thanks, Jack ...

Problem access variable in On Format
Hi, I'm using Access via Office XP Pro. I am trying to format the Zip Code on the detail line of my report. I have tried the following lines of code in both the On Format event and the On Print event: If len([PostalCode]) > 5 Then : : end if or if len(Me.PostalCode) > 5 Then : : end if In both events and either code, I receive the error message: Access can't find the field 'PostalCode' referred to in your expression. If I put "PostalCode" as the source of the report's control...

Running an Excel Macro from an Access Command Button
Hi , Can anyone help me with this, I am trying to run an excel macro from an access command button. I want the macro to Bold the Headings on a excel spreadsheet. The code runs without any errors but the macro doesnt seem to work, I think I have got the line ExcelApp.ExecuteExcel4Macro "RUN(""PERSONAL.XLS!BoldHead"")" wrong The code: Private Sub cmdRunMac_Click() Dim ExcelApp As Excel.Application Dim ExcelBook As Excel.Workbook Set ExcelApp = Excel.Application ExcelApp.Visible = True Set ExcelBook = ExcelApp.Workbooks.Open("C:\Documents and Settings\...

outlook web access 2003
web page downloads ok to my home 98SE based PC with 5.0 IE browser, but will not load ok with 6.0. The outlook web access program from work is on a 2000 Professional based server. thanks. all other webpages download ok but when i login to this remote email the page hangs up. try emptying the browser cache and if it's still a problem, repost in the owa newsgroup, http://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.exchange.clients -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for W...

Times Subtraction Whith Access
Hi I need to know how to subtract between two times variants and to get a time result (With Access). Like this: VarTime=[time1]-[time2] 10:05:40=18:05:50-08:00:10 Thanks Access really isn't intended to do things like that, but ?Format(#18:05:50# - #08:00:10#, "hh:nn:ss") 10:05:40 -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) <bennyzamir@gmail.com> wrote in message news:1175704084.566444.282820@b75g2000hsg.googlegroups.com... > Hi > > I need to know how to subtract between two times variants and to get a > time res...

DAO, Access, zero-length strings?
How can you set that you want to allow zero-length strings in a MS Access database with DAO? Also, how can you set that you want default values? Access doesn't seem to allow "DEFAULT" property... ...

How do you access custom entities with javascript?
I'm about to pull my hair out. I have no problem accessing system attributes, but the second I try to get or set a value for a custom attribute, I get an error (null or not an object). My problem is I am checking the changed input to a field, and if it fails a certain criteria, I need to reset the original value. The best way I could think to do this was to store this value in a new attribute and then restore it if needed. Any help would be greatly appreciated. jsankovitch@gmail.com wrote: > I'm about to pull my hair out. I have no problem accessing system > attributes, b...

Restrict dialog resizing
Hello There My dialog is resizable, how can I restrict the resizing to some minimum limit. Means you can't make it small in width and height beyond a certain limit. Should I need to override WM_SIZE. Thanks in advance. "Roland" <ajay.sonawane@gmail.com> wrote in message news:69c0226e.0411260451.4b820b77@posting.google.com... > Hello There > My dialog is resizable, how can I restrict the resizing to some > minimum limit. Means you can't make it small in width and height > beyond a certain limit. Should I need to override WM_SIZE. > Thanks in advance. WM_...

Importing into Access 2000
I have a text file 13187 characters long. It will not import or link. Any suggestions? Hi William, Suggestions? First one is to give us a bit more information: What happens when you try? Can you import other text files? What's different about this one? Separated or delimited? How many fields? Where did it originate? On Fri, 7 Nov 2003 14:57:16 -0800, "William Madison" <anonymous@discussions.microsoft.com> wrote: >I have a text file 13187 characters long. It will not >import or link. Any suggestions? -- John Nurick [Microsoft Access MVP] Please respond in th...

Import excel named range into Access error 3011
Hi, I've read a few posts on this topic, but none addresses my particular problem. I use Office 2003 on an XP SP3 machine. I am using transferspreadsheet to import a named range in an excel file into Access. This has worked beautifully until suddenly it stopped working. I find now that if I extract the address of the named range from within the Access VBA code, it looks like this: =#REF!$A$1:$Z$166 rather than this, which is what it should be: =Data!$A$1:$Z$166 When I open the spreadsheet and get the address of the named range in the immediate window, it also has the #REF error....

Opening Access with the Shift key
I've locked myself out of my own Access2007 database after implementing some settings on how it should open. I used to get back in to older versions by holding down the shift key whilst opening the database, but this does not work in 2007. How do i get back to the advanced access options when I open this *.accdb database? On Sun, 2 Dec 2007 18:38:00 -0800, f13lecturer wrote: > I've locked myself out of my own Access2007 database after implementing some > settings on how it should open. I used to get back in to older versions by > holding down the shift key whilst openi...

exchange OWA mzil boxes access rigths
Guys, hello to everyone, who will try you help or just to read this post. Here is my problem. I have started a new job, this company migrated exchange 2000 to 2003. OWA was not working I have modified some to the setting within the IIS; it works now, but......... When I open my mail box at the first time, it asks for password, after I put the password and I am seeing my mail box, I can simply change just the user name part, On the browser and get to entire company e-mail boxes without supplying a password. Looks real cool to be hones I can read everyone's e-mail. What is the way to have OW...

Opening Excel from Access
Hello, Wasn't sure where to drop this question. I'm using Access 2003. After I dump a bunch of data to an Excel file, and save it off, I'd like to give the user the prompt to open the Excel file the app just created for them. I did a little digging, and found out that the FileDialog object does not support the Open file dialog type in MS Access, or as MSDN puts it: msoFileDialogOpen Not supported in Microsoft Access. So, anyone know of a workaround or a different approach to be able to prompt the user to open an Excel file from within Access? Thanks, Scott On Thu, 2 A...