Click here to Skip to main content
16,006,341 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: What's wrong with this code ? (CString issue) Pin
kk.tvm12-Jun-06 22:54
kk.tvm12-Jun-06 22:54 
AnswerRe: What's wrong with this code ? (CString issue) Pin
Justin Tay12-Jun-06 22:54
Justin Tay12-Jun-06 22:54 
AnswerRe: What's wrong with this code ? (CString issue) Pin
Laxman Auti12-Jun-06 22:55
Laxman Auti12-Jun-06 22:55 
AnswerRe: What's wrong with this code ? (CString issue) Pin
welkass12-Jun-06 22:56
welkass12-Jun-06 22:56 
AnswerRe: What's wrong with this code ? (CString issue) Pin
_AnsHUMAN_ 12-Jun-06 22:56
_AnsHUMAN_ 12-Jun-06 22:56 
AnswerRe: What's wrong with this code ? (CString issue) Pin
Hamid_RT12-Jun-06 23:07
Hamid_RT12-Jun-06 23:07 
AnswerRe: What's wrong with this code ? (CString issue) Pin
David Crow13-Jun-06 4:31
David Crow13-Jun-06 4:31 
QuestionWin32 API - Tab Control Not Working Pin
capricious_00112-Jun-06 22:35
capricious_00112-Jun-06 22:35 
Hi guys,

I was having a bit of trouble with certain tabs not displaying their appropriate dialog controls.

The options Dialog appears and shows it has 2 tabs. However when the 2nd tab is clicked, it becomes "on top" or becomes focused, but the dialog control associated with it does not appear below the tab. Basically if I click any tab, it shows only the dialog control associated with the general tab (1st tab) and not the dialog controls associated with the tab that was chosen by the user. Below is the code for your perusal:

<br />
BOOL CALLBACK OptionsDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
HWND tab1_hwnd = NULL;<br />
HWND tab2_hwnd = NULL;<br />
HWND CurrentTabHwnd = NULL;<br />
int CurrentTabIndex;<br />
HWND hwndTab = NULL;<br />
<br />
switch(msg)<br />
{<br />
case WM_INITDIALOG:<br />
{<br />
<br />
LPSTR tab1_title = "General";<br />
LPSTR tab2_title = "Advanced";<br />
<br />
INITCOMMONCONTROLSEX tabctl;<br />
<br />
tabctl.dwSize = sizeof(tabctl);<br />
tabctl.dwICC = ICC_TAB_CLASSES;<br />
<br />
InitCommonControlsEx(&tabctl);<br />
<br />
hwndTab = GetDlgItem(hwnd,IDC_TAB1);<br />
<br />
TCITEM ItemStruct;<br />
<br />
ItemStruct.mask = TCIF_TEXT;<br />
ItemStruct.pszText = tab1_title;<br />
ItemStruct.cchTextMax = sizeof(tab1_title);<br />
ItemStruct.iImage = 0;<br />
ItemStruct.lParam = 0;<br />
<br />
SendMessage(hwndTab, TCM_INSERTITEM, 0, (LPARAM)&ItemStruct);<br />
<br />
ItemStruct.pszText = tab2_title;<br />
ItemStruct.cchTextMax = sizeof(tab2_title);<br />
<br />
SendMessage(hwndTab, TCM_INSERTITEM, 1, (LPARAM)&ItemStruct);<br />
<br />
tab1_hwnd = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_OPTIONS_GENERAL), hwndTab, General_OptionsDialogProc, 0);<br />
tab2_hwnd = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_OPTIONS_ADVANCED), hwndTab, Advanced_OptionsDialogProc, 0);<br />
<br />
CurrentTabIndex = 0;<br />
CurrentTabHwnd = tab1_hwnd;<br />
<br />
ShowWindow(tab1_hwnd,SW_SHOWDEFAULT);<br />
<br />
<br />
}<br />
break;<br />
<br />
case WM_NOTIFY:<br />
{<br />
<br />
LPNMHDR lpnmhdr = (LPNMHDR) lParam;<br />
<br />
switch(lpnmhdr->code){<br />
case TCN_SELCHANGING:<br />
{<br />
ShowWindow(CurrentTabHwnd, SW_HIDE);<br />
SendMessage(hwndTab, TCM_GETCURSEL, 0, 0);<br />
<br />
switch(TabCtrl_GetCurSel(hwndTab)){<br />
case 0:<br />
ShowWindow(tab1_hwnd,SW_SHOWDEFAULT);<br />
CurrentTabHwnd = tab1_hwnd;<br />
CurrentTabIndex = 0;<br />
break;<br />
case 1:<br />
ShowWindow(tab2_hwnd,SW_SHOWDEFAULT);<br />
CurrentTabHwnd = tab1_hwnd;<br />
CurrentTabIndex = 1;<br />
break;<br />
}<br />
}<br />
break;<br />
default:<br />
return FALSE;<br />
}<br />
<br />
}<br />
break;<br />
case WM_COMMAND:<br />
{<br />
<br />
switch(LOWORD(wParam)){<br />
<br />
case IDOK:<br />
EndDialog(hwnd,0);<br />
break;<br />
case IDCANCEL:<br />
EndDialog(hwnd,0);<br />
break;<br />
}<br />
<br />
}<br />
break;<br />
case WM_CLOSE:<br />
EndDialog(hwnd, 0);<br />
break;<br />
<br />
default:<br />
return FALSE;<br />
}<br />
return 0;<br />
}<br />
<br />



Everything works correctly up until WM_NOTIFY case and even more specifically the "case TCN_SELCHANGING" code block and even more so there are issues associated with the Message TCN_SELCHANGING.

I want to know how do I find out through the message system which tab index is selected? If I can find out which tab index is selected then I can easily write code that will show the appropriate dialog window under the selected tab.

Thanks for your help,

Robbie
AnswerRe: Win32 API - Tab Control Not Working Pin
Laxman Auti12-Jun-06 22:43
Laxman Auti12-Jun-06 22:43 
GeneralRe: Win32 API - Tab Control Not Working Pin
capricious_00113-Jun-06 0:18
capricious_00113-Jun-06 0:18 
AnswerRe: Win32 API - Tab Control Not Working Pin
Viorel.12-Jun-06 22:49
Viorel.12-Jun-06 22:49 
Questionbig login problem [modified] Pin
yogendra kaushik12-Jun-06 22:24
yogendra kaushik12-Jun-06 22:24 
AnswerRe: big login problem Pin
Ganesh_T12-Jun-06 22:28
Ganesh_T12-Jun-06 22:28 
AnswerRe: big login problem Pin
_AnsHUMAN_ 12-Jun-06 22:28
_AnsHUMAN_ 12-Jun-06 22:28 
GeneralRe: big login problem Pin
Laxman Auti12-Jun-06 22:35
Laxman Auti12-Jun-06 22:35 
Question` Pin
yogendra kaushik12-Jun-06 22:19
yogendra kaushik12-Jun-06 22:19 
AnswerRe: MYSQL Strings Pin
_AnsHUMAN_ 12-Jun-06 22:23
_AnsHUMAN_ 12-Jun-06 22:23 
GeneralRe: MYSQL Strings Pin
yogendra kaushik12-Jun-06 22:28
yogendra kaushik12-Jun-06 22:28 
GeneralRe: MYSQL Strings Pin
_AnsHUMAN_ 12-Jun-06 22:29
_AnsHUMAN_ 12-Jun-06 22:29 
GeneralRe: MYSQL Strings Pin
yogendra kaushik12-Jun-06 22:39
yogendra kaushik12-Jun-06 22:39 
GeneralRe: MYSQL Strings Pin
Laxman Auti12-Jun-06 22:46
Laxman Auti12-Jun-06 22:46 
JokeRe: MYSQL Strings Pin
_AnsHUMAN_ 12-Jun-06 23:03
_AnsHUMAN_ 12-Jun-06 23:03 
JokeRe: MYSQL Strings Pin
Laxman Auti12-Jun-06 23:07
Laxman Auti12-Jun-06 23:07 
GeneralRe: MYSQL Strings Pin
yogendra kaushik13-Jun-06 0:54
yogendra kaushik13-Jun-06 0:54 
AnswerRe: MYSQL Strings Pin
Laxman Auti13-Jun-06 2:19
Laxman Auti13-Jun-06 2:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.