Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do I programmatically simulate clicking a control?

How do I programmatically simulate clicking a control?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David Fleming
    wrote on last edited by
    #1

    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.

    J 1 Reply Last reply
    0
    • D David Fleming

      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.

      J Offline
      J Offline
      jmkhael
      wrote on last edited by
      #2

      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 ) ;

      D 2 Replies Last reply
      0
      • J jmkhael

        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 ) ;

        D Offline
        D Offline
        David Fleming
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • J jmkhael

          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 ) ;

          D Offline
          D Offline
          David Fleming
          wrote on last edited by
          #4

          I can get a CWnd* by using CWnd* pWnd = GetDlgItem(IDC_TAB_LISTS). But using LRESULT 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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups