Hello,all the following codes can't show the correct Title. Код (Text): .486 .model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\user32.inc include \masm32\include\masm32.inc include \masm32\include\comctl32.inc include \masm32\include\advapi32.inc include \masm32\include\comdlg32.inc include \masm32\include\gdi32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\masm32.lib includelib \masm32\lib\comctl32.lib includelib \masm32\lib\advapi32.lib includelib \masm32\lib\comdlg32.lib includelib \masm32\lib\gdi32.lib include \masm32\macros\macros.asm DlgMain proto hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM ChildDlgProc1 proto hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM ChildDlgProc2 proto hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM .const IDD_MAINDLG equ 1001 IDC_TAB equ 100 .data TabTitle1 db "DLG_1", 0 TabTitle2 db "DLG_2", 0 Child1Name db "IDD_CHILD1",0 ; lpTemplateName for the first child Child2Name db "IDD_CHILD2",0 ; lpTemplateName for the second child .data? hInstance HINSTANCE ? ItemStruct TC_ITEM <?> hTab HWND ? Handles LABEL DWORD Child1hWnd HWND ? Child2hWnd HWND ? WhichTabChosen DWORD ? .code start proc invoke GetModuleHandle, NULL mov hInstance, eax invoke DialogBoxParam, hInstance, IDD_MAINDLG, NULL, offset DlgMain, NULL invoke ExitProcess, NULL invoke InitCommonControls ret start endp DlgMain proc USES EBX hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM .if uMsg == WM_INITDIALOG invoke GetDlgItem, hWin, IDC_TAB mov hTab, eax mov ItemStruct.imask,TCIF_TEXT mov ItemStruct.lpReserved1,0 mov ItemStruct.lpReserved2,0 mov ItemStruct.pszText,OFFSET TabTitle1 mov ItemStruct.cchTextMax,sizeof TabTitle1 mov ItemStruct.iImage,0 mov ItemStruct.lParam,0 invoke SendMessage,hTab,TCM_INSERTITEM,0,OFFSET ItemStruct mov ItemStruct.pszText,OFFSET TabTitle2 mov ItemStruct.cchTextMax,sizeof TabTitle2 invoke SendMessage,hTab,TCM_INSERTITEM,1,OFFSET ItemStruct mov EAX,OFFSET ChildDlgProc1 invoke CreateDialogParam,hInstance,OFFSET Child1Name,hTab,EAX,0 mov Child1hWnd,EAX mov EAX,OFFSET ChildDlgProc2 invoke CreateDialogParam,hInstance,OFFSET Child2Name,hTab,EAX,0 mov Child2hWnd,EAX mov WhichTabChosen,0 invoke ShowWindow,Child2hWnd,SW_SHOWDEFAULT ;;==> it still shows TabTitle1 invoke ShowWindow,Child1hWnd,SW_HIDE .elseif uMsg == WM_NOTIFY mov eax,lParam mov eax, (NMHDR PTR [eax]).code .if eax == TCN_SELCHANGE mov ebx,WhichTabChosen mov eax,[Handles+EBX*4] invoke ShowWindow,EAX,SW_HIDE invoke SendMessage,hTab,TCM_GETCURSEL,0,0 ; Ok which one is BEING chosen right now? mov WhichTabChosen,EAX mov EBX,[Handles+EAX*4] invoke ShowWindow,EBX,SW_SHOWDEFAULT .endif .elseif uMsg == WM_CLOSE invoke EndDialog, hWin, NULL .endif xor eax,eax ret DlgMain endp ChildDlgProc1 proc hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM m2m Child1hWnd, hWin mov eax, uMsg .if eax == WM_INITDIALOG .elseif eax == WM_CLOSE invoke EndDialog, hWin, NULL .else mov eax, FALSE ret .endif mov eax, TRUE ret ChildDlgProc1 endp ChildDlgProc2 proc hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM m2m Child2hWnd, hWin mov eax, uMsg .if eax == WM_INITDIALOG .elseif eax == WM_CLOSE invoke EndDialog, hWin, NULL .else mov eax, FALSE ret .endif mov eax, TRUE ret ChildDlgProc2 endp end start
dcskm4200 Код (Text): ... DlgMain proc USES EBX hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM .if uMsg == WM_INITDIALOG ... mov Child2hWnd,EAX mov WhichTabChosen,1 ;; !!! 0 -> 1 invoke ShowWindow,Child2hWnd,SW_SHOWDEFAULT ;;==> it still shows TabTitle1 invoke ShowWindow,Child1hWnd,SW_HIDE invoke SendMessage,hTab,TCM_SETCURSEL,WhichTabChosen,0 ;; !!! add .elseif uMsg == WM_NOTIFY ...
Код (Text): mov WhichTabChosen,0 invoke ShowWindow,Child2hWnd,SW_HIDE invoke ShowWindow,Child1hWnd,SW_SHOWDEFAULT it shows correct for me except first time until tab is clicked. swap SW_HIDE and SW_SHOWDEFAULT in WM_INITDIALOG processing and it works ok