Why TabCtrl_GetCurSel always returns 0?

By | March 7, 2017 | 0 Comment
Category: Win32 Tags: ,

TabCtrl_GetCurSel returns 0 when the handler passed as a parameter is “invalid”. Here is the fix.

  • If you are using a dialog box, you need to get the tab handler using GetDlgItem(dialog_hwnd, MY_TAB_ID); and pass that handler to TabCtrl_GetCurSel.
  • Make sure you are using the correct variable. I faced the issue when I had two variables with same name but different scopes. I was setting a value of GetDlgItem(dialog_hwnd, MY_TAB_ID) to one variable but passing another variable to TabCtrl_GetCurSel

About Vishal Monpara

Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1's and 0's from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.

Leave a Reply

Your email address will not be published. Required fields are marked *