Click here to Skip to main content
16,016,605 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionset focus to a control problem on win32 dialogs [modified] Pin
abdolahzadeh15-Nov-08 2:55
abdolahzadeh15-Nov-08 2:55 
AnswerRe: set focus to a control problem on win32 dialogs Pin
Code-o-mat15-Nov-08 3:36
Code-o-mat15-Nov-08 3:36 
GeneralRe: set focus to a control problem on win32 dialogs Pin
abdolahzadeh16-Nov-08 2:43
abdolahzadeh16-Nov-08 2:43 
AnswerRe: set focus to a control problem on win32 dialogs Pin
Mark Salsbery15-Nov-08 7:27
Mark Salsbery15-Nov-08 7:27 
GeneralRe: set focus to a control problem on win32 dialogs Pin
abdolahzadeh16-Nov-08 2:39
abdolahzadeh16-Nov-08 2:39 
QuestionRe: set focus to a control problem on win32 dialogs Pin
Mark Salsbery16-Nov-08 6:05
Mark Salsbery16-Nov-08 6:05 
AnswerRe: set focus to a control problem on win32 dialogs Pin
abdolahzadeh18-Nov-08 3:51
abdolahzadeh18-Nov-08 3:51 
GeneralRe: set focus to a control problem on win32 dialogs Pin
Phil Outram20-Sep-10 11:02
Phil Outram20-Sep-10 11:02 
Here's a solution I've finally found that nails this problem...phewph. It was on MSDN.itags.org at http://visual-c.itags.org/visual-c-c++/49186/[^] and is provided by Jeff Partch [MVP] - thanks so much Jeff!!

On Win2k and up, the focus rect is hidden by default until you do things like: 1) Tabbing with the keyboard, 2) Hit the ALT key, or 3) Invoke the dialog with the keyboard in the first place. The WM_UPDATEUISTATE may explain it better than I do, but if I add a PostMessage of it to your OnInitDialog...

BOOL CTestChekBoxDlg::OnInitDialog()
{
CDialog::OnInitDialog();

m_button.Create(_T("Hello"), WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX, CRect(10,10,100,30), this, 10000);

GotoDlgCtrl(&m_button);

PostMessage(WM_UPDATEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEFOCUS));

return FALSE;
}


...it'll circumvent the expected behavior (which may not be a good thing, but that's your call). It
does do for me anyway. To get these 'UISTATE' defines you need to have the latest (or later than
that which ships with VC6) PSDK installed, and 2) You need to have defined (_WIN32_WINNT >= 0x0500)
way early in the build process. Personally, I think this conditional around a Window's message and
its parameter values is an error in judgement. Anyway, both these can be a real pain, so FWIW...

#ifndef WM_UPDATEUISTATE
#define WM_UPDATEUISTATE 0x0128
#endif
#ifndef UISF_HIDEFOCUS
#define UISF_HIDEFOCUS 0x1
#endif
#ifndef UIS_CLEAR
#define UIS_CLEAR 2
#endif


--
Jeff Partch [MVP]
QuestionSetRegistryKey problem, when uninstalling Pin
followait15-Nov-08 0:51
followait15-Nov-08 0:51 
AnswerRe: SetRegistryKey problem, when uninstalling Pin
22491715-Nov-08 17:38
22491715-Nov-08 17:38 
GeneralRe: SetRegistryKey problem, when uninstalling Pin
followait15-Nov-08 18:46
followait15-Nov-08 18:46 
Questiondate and time Pin
Russell'15-Nov-08 0:18
Russell'15-Nov-08 0:18 
AnswerRe: date and time Pin
Hamid_RT15-Nov-08 1:44
Hamid_RT15-Nov-08 1:44 
AnswerRe: date and time Pin
Mark Salsbery15-Nov-08 7:40
Mark Salsbery15-Nov-08 7:40 
QuestionDll Not Found Pin
Aabid15-Nov-08 0:00
Aabid15-Nov-08 0:00 
AnswerRe: Dll Not Found Pin
Hamid_RT15-Nov-08 1:45
Hamid_RT15-Nov-08 1:45 
AnswerRe: Dll Not Found Pin
CPallini15-Nov-08 3:04
mveCPallini15-Nov-08 3:04 
QuestionOpen Excel and write Pin
hellogany14-Nov-08 21:57
hellogany14-Nov-08 21:57 
AnswerRe: Open Excel and write Pin
Hamid_RT14-Nov-08 22:57
Hamid_RT14-Nov-08 22:57 
QuestionPicture Erases Pin
Aabid14-Nov-08 21:04
Aabid14-Nov-08 21:04 
QuestionRe: Picture Erases Pin
Perspx14-Nov-08 22:18
Perspx14-Nov-08 22:18 
AnswerRe: Picture Erases Pin
Aabid14-Nov-08 22:22
Aabid14-Nov-08 22:22 
AnswerRe: Picture Erases Pin
Hamid_RT14-Nov-08 23:00
Hamid_RT14-Nov-08 23:00 
GeneralRe: Picture Erases Pin
Aabid14-Nov-08 23:07
Aabid14-Nov-08 23:07 
GeneralRe: Picture Erases Pin
Hamid_RT14-Nov-08 23:11
Hamid_RT14-Nov-08 23:11 

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.