Re: Problems with SetDefaultItem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



See below...
On Wed, 22 Apr 2009 07:49:31 +0300, Ismo Salonen <Ismo.Salonen@xxxxxxxxx> wrote:


I've an application where I've got a popup menu. And one item is
set as default item with this code .

if( objectPopupMenu->SetDefaultItem( ID_OBJECT_OPEN, FALSE) == FALSE)
****
Do not compare results to boolean values. They are already boolean values, and comparing
them to a boolean literal is as silly as writing
if( (a > 0) == TRUE)
instead of
if(a > 0)

I have no idea why people cannot comprehend a simple concept like boolean. If a value is
boolean, it is already in the right form to use in an if-statement, and further
comparisons are unnecessary, silly, and error-prone (people who write == FALSE are often
fooled into believing the opposite is == TRUE, and that is not guaranteed)
****
{
DWORD error = GetLastError();
xxxTRACE2("SetDefaultItem failed ", error);
}

It bolds the "Open" item in the popup but the open command is not
executed with return key.
****
It is not clear why this is expected; the documentation for default menu items says

"When the user opens a submenu by double-clicking, the system sends a command message to
the menu's owner window and closes the menu as if the default command item had been
chosen."

It does not suggest that the <return> key is involved in this at all. I have tried
several menus that have default items, and <enter> does not cause the default item to be
selected.
****

Should the open command be executed in this case ( it is not selected
but just bold). It excutes correctly when user selects the "Open" and
presses the item ( keyboard and mouse bot work).

I tries Spy++ but the popup menu vanishes when ever it loses focus so it
is quite hard to dig further. Spying on process messages does not reveal
anything special, these messages seem to be result of enter key :

<12316> 000B20D0 R WM_CAPTURECHANGED
<12317> 000B20D0 S WM_UNINITMENUPOPUP
<12318> 000B20D0 R WM_UNINITMENUPOPUP
<12319> 000B20D0 S WM_MENUSELECT uItem:0 fuFlags:FFFF (menu was closed)
hmenu:00000000


environment : WinXP+SP3 , VS2005

Any idea how to debug this deeper ?
****
You are asking how to get an unspecified behavior. I don't see anywhere in the docs where
the enter key is described as being functionally equivalent to a double-click. I have not
observed any existing application that treats <enter> as equivalent to a double-click when
a default menu item is selected. So the reason it doesn't work is that it is not supposed
to work.
****

ismo

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Command button to open form and find record
    ... Opens the form if it is not already open. ... Public Function OpenFormTo(strForm As String, strWhere As String, Optional bGotoNewRecord As Boolean, _ ... Optional strOpenArgs As String) As Boolean ... Public Function HasProperty ...
    (microsoft.public.access.forms)
  • Re: IP Brodcast
    ... In Internet Explorer the Internet Options properties under the Security tab ... enables the PC user to set Intranet, Trusted, and Restricted sites. ... If you like visit certain cites like about.com or bn.com and hate their popup ... opens, it will show an restricted symbol at the bottom of the IE status bar. ...
    (microsoft.public.win2000.security)
  • Re: Setting properties in a popup form?
    ... OpenArgs argument of the OpenForm method to pass a value to the target form, ... > If you open a form using acDialog Windowmode value it opens the form as a ... > return from the popup. ... > display the form and then put myself into a counter loop ...
    (microsoft.public.access.formscoding)
  • RE: Requiring Data Input for a Field in a Dialog Box
    ... on the VBA button so that it opens the form's code module. ... "nytwodees" wrote: ... Function SetPreviewLabelSheetCommandAs Boolean ... ElseIf IsNullThen ...
    (microsoft.public.access.forms)
  • Error number returned different from IDE to EXE
    ... It opens the text file to make sure it is not ... Private Sub btnExit_Click ... Dim strOldLine As String ... 'Input first line of file into strOldLine to compare ...
    (comp.lang.basic.visual.misc)