Click here to Skip to main content
15,911,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalmissing menu on windows 98 Pin
Anonymous10-Nov-03 6:29
Anonymous10-Nov-03 6:29 
GeneralRe: missing menu on windows 98 Pin
David Crow10-Nov-03 6:59
David Crow10-Nov-03 6:59 
GeneralRe: missing menu on windows 98 Pin
Roger Allen11-Nov-03 0:47
Roger Allen11-Nov-03 0:47 
GeneralRe: missing menu on windows 98 Pin
Anonymous12-Nov-03 7:22
Anonymous12-Nov-03 7:22 
GeneralIExtractImage::GetLocation() brings up a "Thumbnail could not be created" message-box Pin
ohadp10-Nov-03 5:31
ohadp10-Nov-03 5:31 
QuestionHelp!!!---ATL COM Full Control can't cooperate with MFC? Pin
Dev-xiang10-Nov-03 5:30
Dev-xiang10-Nov-03 5:30 
Generalproperty page problem Pin
YaronNir10-Nov-03 5:17
YaronNir10-Nov-03 5:17 
GeneralRe: property page problem Pin
Antti Keskinen10-Nov-03 7:54
Antti Keskinen10-Nov-03 7:54 
This happens because of the way a tab control works.

The TCM_SETCURSEL message only sets the selected tab index as active. It does not, like stated in the Platform SDK Reference, send TCM_SELCHANGING and TCM_SELCHANGE messages. The general tab control available in Platform SDK (SysTabControl32 window class) handles the changing of the page in the TCM_SELCHANGING and TCM_SELCHANGE message handlers. First is called first, and is responsible for hiding the current page. The latter is sent (and handled) next, and it is responsible for showing the new page.

There are (at least) two solutions to this problem:

1. Override your tab control's TCM_SETCURSEL message handler to send TCM_SELCHANGING and TCM_SELCHANGE messages, which will then swap the page. This is necessary if your tab control has TCM_BUTTONS style set, or you are using a tab control which is not based on the SysTabControl32 class.

2. If your tab control does not have TCM_BUTTONS style set, you can use TCM_SETCURFOCUS message to set the focus to the specified tab. This message will cause TCM_SELCHANGING and TCM_SELCHANGE messages to be sent to the tab control, thus switching the page as well.

If you use MFC, the correct message-map entry is ON_COMMAND (TCM_SETCURSEL, <function>) and the function prototype is afx_msg LRESULT <function>(WPARAM wParam, LPARAM lParam). Same rules apply for TCM_SELCHANGING and TCM_SELCHANGE, if you need to override them.
However, if you use a CCtrlView class as the base, the message map entry is ON_NOTIFY_REFLECT. See MFC Reference for more details about this.

Alternatively, instead of sending messages, you can use the TabCtrl_SetCurFocus macro. In Platform SDK, this macro requires a HWND of the tab and the index to be selected. If you use MFC's CTabCtrl class or it's derivates, you can use the SetCurFocus member method to achieve the same results.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralAnonymous Pin
Anonymous10-Nov-03 5:04
Anonymous10-Nov-03 5:04 
GeneralRe: Anonymous Pin
Roger Allen10-Nov-03 5:07
Roger Allen10-Nov-03 5:07 
GeneralRe: Anonymous Pin
jmkhael10-Nov-03 5:10
jmkhael10-Nov-03 5:10 
GeneralSimple database problem please help me Pin
Scozturk10-Nov-03 4:28
professionalScozturk10-Nov-03 4:28 
GeneralRe: Simple database problem please help me Pin
David Crow10-Nov-03 4:42
David Crow10-Nov-03 4:42 
GeneralRe: Simple database problem please help me Pin
Scozturk11-Nov-03 2:18
professionalScozturk11-Nov-03 2:18 
GeneralRe: Simple database problem please help me Pin
antlers10-Nov-03 6:41
antlers10-Nov-03 6:41 
GeneralRe: Simple database problem please help me Pin
Scozturk11-Nov-03 2:21
professionalScozturk11-Nov-03 2:21 
Generalfunction Pin
Anonymous10-Nov-03 2:27
Anonymous10-Nov-03 2:27 
GeneralRe: function Pin
Alvaro Mendez10-Nov-03 4:23
Alvaro Mendez10-Nov-03 4:23 
GeneralRegEnumKeyEx problem Pin
Anonymous10-Nov-03 2:23
Anonymous10-Nov-03 2:23 
GeneralRe: RegEnumKeyEx problem Pin
Brian Shifrin10-Nov-03 4:12
Brian Shifrin10-Nov-03 4:12 
QuestionActive a event while in a while loop ?? Pin
Member 40481310-Nov-03 0:33
Member 40481310-Nov-03 0:33 
AnswerRe: Active a event while in a while loop ?? Pin
jmkhael10-Nov-03 0:37
jmkhael10-Nov-03 0:37 
GeneralRe: Active a event while in a while loop ?? Pin
BadJerry10-Nov-03 0:45
BadJerry10-Nov-03 0:45 
GeneralRe: Active a event while in a while loop ?? Pin
jmkhael10-Nov-03 1:52
jmkhael10-Nov-03 1:52 
AnswerRe: Active a event while in a while loop ?? Pin
BadJerry10-Nov-03 0:48
BadJerry10-Nov-03 0:48 

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.