How do I programmatically simulate clicking a control?
-
Specifically, I am wondering how to programmatically simulate clicking on a tab in a TabCtrl. It seems that I should be able to do SetCurSel and then call OnSelchange, but I don't know how to call the OnSelchange (it requires a PNMHDR and LPRESULT). I know I've seen a way to do this, but I can't remember where or how I found it. Thanks.
-
Specifically, I am wondering how to programmatically simulate clicking on a tab in a TabCtrl. It seems that I should be able to do SetCurSel and then call OnSelchange, but I don't know how to call the OnSelchange (it requires a PNMHDR and LPRESULT). I know I've seen a way to do this, but I can't remember where or how I found it. Thanks.
-
Check FindWindow and SendMessage you can do it without calling OnSelChange they system will call it for you Good luck Papa while (TRUE) Papa.WillLove ( Bebe ) ;
Thanks for the reply, but I have a couple of questions: I can get the ClassName easy enough (for FindWindow), but I don't know how to get the window name (the window's title). And if I supply NULL (which the Help says you can do), FindWindow returns 0. So where do I get the window name? Second, why can't I simply use SendMessage through the control itself? The control is mapped to a variable (of type CTabCtrl) called m_tabLists. It doesn't seem to do anything when I use m_tabLists.SendMessage(TCN_SELCHANGE). Do I have to get a CWnd* by using FindWindow and then call SendMessage? Or am I simply using SendMessage wrong? Do I need parameters (wParam and/or lParam) in my SendMessage call? And if so, what are they or how do I find them? Thanks a bunch.
-
Check FindWindow and SendMessage you can do it without calling OnSelChange they system will call it for you Good luck Papa while (TRUE) Papa.WillLove ( Bebe ) ;
I can get a CWnd* by using
CWnd* pWnd = GetDlgItem(IDC_TAB_LISTS)
. But usingLRESULT lRes = pWnd->SendMessage(TCN_SELCHANGE)
still returns 0 (fails) and does nothing. I'm thinking I'm doing something wrong with regard to SendMessage. Again, suggestions are greatly welcome. Thanks.