PlanetSquires Forums

Support Forums => José Roca Software => Topic started by: James Fuller on June 23, 2016, 12:18:03 PM

Title: setfocus
Post by: James Fuller on June 23, 2016, 12:18:03 PM
Jose,
  How and or where to setfocus to a control ?

James
Title: Re: setfocus
Post by: Paul Squires on June 23, 2016, 12:44:09 PM
If you mean where to set the initial focus then I am doing it immediately before that form's message pump (pWindow->DoEvents())
Title: Re: setfocus
Post by: James Fuller on June 23, 2016, 12:50:38 PM
Ok the button I want with the focus does have it and if I press the space bar the coded action happens.
But there is no visual clue as which control has the actual focus until one presses the tab key.
Then we have the blue border (Win10) around the command button with the focus.
Is there a way to induce the visual clue?
James

Title: Re: setfocus
Post by: Paul Squires on June 23, 2016, 01:07:35 PM
On my system when I set focus to a regular command button, I get the dotted rectangular outline showing on the button.
Title: Re: setfocus
Post by: Paul Squires on June 23, 2016, 01:10:02 PM
As an off-topic aside, in order to prevent visual issues such as a form moving into position after creation, I do not set the WS_VISIBLE style of the form when I create it. Just before the message pump I will issue a ShowWindow call to show the form. This works especially well in cases where you create the form, center it on screen, and then final add controls to the form.
Title: Re: setfocus
Post by: James Fuller on June 23, 2016, 01:37:51 PM
Looking at the CWindow help file I do not see where WS_VISIBLE is even used for the default in the Create Method??

James
Title: Re: setfocus
Post by: Paul Squires on June 23, 2016, 02:07:54 PM
You are probably right. I never use the default styles. I always explicitly set the standard and extended styles just so I am always 100% sure of how the control was created.
Title: Re: setfocus
Post by: José Roca on June 24, 2016, 11:45:24 AM
Sorry, I have been one day without internet conexion because of a little problem activating the new router. Now I have 300 MB.

> Looking at the CWindow help file I do not see where WS_VISIBLE is even used for the default in the Create Method??

Contrarily to controls, it is not used at all. You decide what to do with the value passed as nCmdShow pWindow.DoEvents(nCmdShow).


   ' // Show the window and update its client area
   IF nCmdShow = 0 THEN .ShowWindow m_hwnd, SW_SHOW ELSE .ShowWindow m_hwnd, nCmdShow
   .UpdateWindow m_hwnd


If the value is 0 (the default), DoEvents will call ShowWindow m_hwnd, SW_SHOW and UpdateWindow m_hwnd. This follows what Paul does. I don't like to see a window and its controls moving and resizing.

You can replace DoEvents with your own message pump and do the ShowWindow/UpdateWindow when you like.