| View previous topic :: View next topic |
| Author |
Message |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Fri May 11, 2007 7:40 pm Post subject: SetTimer? |
|
|
Whats up people, well I'm not sure if thats the right way to go but I'm trying to close a window in this case notepad in 2 mins. I believe SetTimer is the right way to go. But even there I can't get it to work. I'm developing a WIN32 app.
As we are here one more thing. How to we get the input from a user, from an editbox? _________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri May 11, 2007 7:50 pm Post subject: |
|
|
1) call SetTimer with NULL for the callback and 120000 milliseconds count
2) in your messageloop, close notepad on WM_TIMER message
3) call InvalidateRect to stop the timer
| zomgiownyou wrote: | | How to we get the input from a user, from an editbox? |
SendMessage(editWnd, WM_GETTEXT, (WPARAM)sizeof(Buffer), (LPARAM)Buffer); |
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Fri May 11, 2007 8:05 pm Post subject: |
|
|
| appalsap wrote: | | 1) call SetTimer with NULL for the callback and 120000 milliseconds count |
Thanks for the fast reply. So this should be right
| Code: | SetTimer(hwnd,
IDT_TIMER1,
120000,
(TIMERPROC) NULL); |
| Quote: | | 2) in your messageloop, close notepad on WM_TIMER message |
| Code: | case WM_TIMER:
switch (wParam)
{
case IDT_TIMER1:
HWND hWin;
hWin = FindWindow(NULL,"Noptepad");
SendMessage(hWin,WM_CLOSE,(LPARAM)0,(WPARAM)0);
return 0;
} |
Ref from msdn, so I believe I have to add IDT_TIMER1 in resource _________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri May 11, 2007 8:11 pm Post subject: |
|
|
you only need to make a unique ID for your timer if you want to call KillTimer. If you use NULL the system will generate a unique timer id for you, but you have the right idea. Just remember to stop the timer once you've closed notepad (unless you want to do it constantly) else it will execute that code every 2 minutes.
Last edited by appalsap on Fri May 11, 2007 8:16 pm; edited 1 time in total |
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Fri May 11, 2007 8:14 pm Post subject: |
|
|
Once again thanks a lot, using google for those function is not very promising and using www.koders.com is not helpfully either, Thanks
*EDIT* I searched a bit, and I find it more easy to use | Code: | | GetDlgItemText (Hwnd,IDC_EDIT1, buffer, 256); |
_________________
|
|
| Back to top |
|
 |
|