WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check the Grayed/NonGrayed State of Buttons in Pull Down Menus

Keywords:   info about grayed buttons   Check the Grayed/NonGrayed State of Buttons in Pull Down Menus

Question:

Is there way to check the =grayed/nongrayed state of buttons in pulldownmenues?

As in Winbatch Studio: Debug =-> Step over can sometimes be grayed and sometimes not.

Answer:

Here is a way to do it (from Guido). The following checks for the grayed/ungrayed state mostly, although there are more states.

The following script checks for the Step Over item in the Debug submenu of the WinBatch Studio menu.

Remember that menu separators are considered menu items too.


;Get menu items info
;Guido 10/2002

MF_BYPOSITION=1024

MF_ENABLED=0
MF_GRAYED=1
MF_DISABLED=2
MF_SEPARATOR=2048

user32=dllload(strcat(dirwindows(1),"user32.dll"))

;get window handle
hwnd=dllhwnd("WinBatch Studio")
if hwnd==0
  message("","Window not found")
  exit
endif

;get menu handle
hmenu=dllcall(user32,long:"GetMenu",long:hwnd)

;get dropdown menu handle based on position, 0 based
subpos=4  ; 'Debug'
hsub=dllcall(user32,long:"GetSubMenu",long:hmenu,long:subpos)

;get item state based on position, 0 based
itempos=8 ; 'Step Over'
state=dllcall(user32,long:"GetMenuState",long:hsub,long:itempos,long:MF_BYPOSITION)

message("State:",state)

select state

  case -1
    message("Info:","Not found")
    break

  case MF_ENABLED
    message("Info:","Enabled")
    break

  case MF_GRAYED
    message("Info:","Grayed")
    break

  case MF_DISABLED
    message("Info:","Disabled")
    break

  case MF_DISABLED | MF_GRAYED
    message("Info:","Disabled and grayed")
    break

  case MF_SEPARATOR | MF_DISABLED | MF_GRAYED
    message("Info:","Separator")

endselect

dllfree(user32)

Article ID:   W15506
File Created: 2003:05:13:11:28:26
Last Updated: 2003:05:13:11:28:26