?
Solved

problem in MFC

Posted on 2004-04-19
4
Medium Priority
?
526 Views
Last Modified: 2013-11-25
hi ....

i created a app in vc++ MFC Dialog based and OS is WIN XP

On the INITDIALOG event i wrote

SetTimer(1,2000,NULL);///to enable the timer

On WM_TIMER event of the dialog i wrote
AfxMessageBox("Hello World");

So far no problem .a message box displays every 2 seconds

Then i write a function Kll_Timer(to kill the timer)
i inserted this function by just writing in the SAME cpp file as Initdialog fuction and other functions generated by AppWizard

void Kll_Timer()
{
    KillTimer(1);
}

i also declared the void Kll_Timer(); on top of the cpp file

//********
Usually a function is added by right clicking the class window and selecting Add Member Function...here i DID NOT do that.
//********

then i inserted a button and the button click event is like this

void CTimerpDlg::OnButton1()
{
    Kll_Timer();// to call the function Kll_Timer(), which in turn kills the timer
}

When compiled it is showing error message
'KillTimer' : function does not take 1 parameters
Error executing cl.exe.

But when the function is created using app wizard ( by right clicking the class window and selecting the Add Member function . the KillTimer(1); with only a single parameter works

What could be the problem..... Actually this is a part of a large program..so i could not change the overall structure
thanks in advance...
0
Comment
Question by:Kiran Paul VJ
[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
  • 3
4 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10857508
void Kll_Timer()
{
    KillTimer(1);
}

If this function is global, KillTimer is global KillTimer API:

BOOL KillTimer(          HWND hWnd,
    UINT_PTR uIDEvent
);

Make   Kll_Timer function as CTimerpDlg class member:

void  CTimerpDlg::Kll_Timer()
{
    KillTimer(1);
}

In this case KillTimer is call to CWindow::KillTimer function:

BOOL KillTimer(
   UINT_PTR nIDEvent
);
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 10857524
If you want to keep Kill_Timer global, you need to change it by the following way:

void Kll_Timer(HWND hwnd)
{
    KillTimer(hwnd, 1);
}

and call it by this way:

void CTimerpDlg::OnButton1()
{
    Kll_Timer(m_hWnd);// to call the function Kll_Timer(), which in turn kills the timer
}
0
 
LVL 16

Author Comment

by:Kiran Paul VJ
ID: 10858095
hi.... AlexFM

now i got it right..I have submited a A grade to u. Since i am a newbie in VC++ and in EE with just 1115 i could give u only 125 points...this is my first question post and dont know wheater 125 is a big point or a small point.

anyway for last two , three days i was googling in net for an answer.

once agian thank u very much.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10858188
125 is OK, don't care.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

765 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