News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

menu

Started by imadhx30, February 05, 2014, 07:14:16 AM

Previous topic - Next topic

imadhx30

how to create menu ( masm32) ????

dedndave

you can do it with code, using functions like CreateMenu, CreatePopupMenu, AppendMenu, etc
but, it's easier to do it with a resource file

http://masm32.com/board/index.php?topic=2806.msg29562#msg29562

imadhx30


dedndave

you must be talking about a console mode program ?
in that case, you can make the menu any way you like
perhaps you should give us more details to work with

Tedd

I'm guessing the intention is something more like:


                           S E L E C T I O N   M E N U

                        1. Draw list of menu items

                        2. Wait for user input

                        3. Check user input

                        4. Perform user's selected action


                        Enter the number for your selection: _
Potato2

imadhx30

hello teed :)
how to create a menu:

                           S E L E C T I O N   M E N U

                        1. Draw list of menu items

                        2. Wait for user input

                        3. Check user input

                        4. Perform user's selected action


                        Enter the number for your selection: _

jj2007

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  .Repeat
      Locate(0,0)
      PrintLine "c=CLS"
      PrintLine "h=say hello"
      PrintLine "i=get info"
      PrintLine "b=say bye", CrLf$
      Print "Enter your choice: "
      Inkey
      switch$ Chr$(eax)
      case$ "c"
            Cls
            invoke Sleep, 100
      case$ "h"
            PrintLine "Hello", Space$(40)
      case$ "i"
            PrintLine "You should study \masm32\macros\macros.asm"
      case$ "b"
            PrintLine "bye bye", Space$(40)
            .Break
      endsw$
  .Until 0
  invoke Sleep, 2000
  Exit
end start

TWell

With bare Win32API.486
.MODEL FLAT, STDCALL
OPTION CASEMAP:NONE

INCLUDELIB kernel32.lib

ExitProcess  PROTO :DWORD
GetStdHandle PROTO :DWORD
WriteConsoleA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ReadConsoleA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
SetConsoleCursorPosition PROTO :DWORD,:DWORD
FillConsoleOutputCharacterA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
FlushConsoleInputBuffer PROTO :DWORD

Cls PROTO h:DWORD

.data
stdih dd 0
stdoh dd 0
numw  dd 0
mst   db 13,10,9,9,9,"  S E L E C T I O N   M E N U",13,10,13,10
mso1  db 9,9,9,"1. Draw list of menu items",13,10,13,10
mso2  db 9,9,9,"2. Wait for user input",13,10,13,10
mso3  db 9,9,9,"3. Check user input",13,10,13,10
mso4  db 9,9,9,"4. Perform user's selected action",13,10,13,10
mssi  db 9,9,9,"Enter the number for your selection:",0
buf   db 100 DUP(?)

msolen EQU SIZEOF mst+SIZEOF mso1+SIZEOF mso2+SIZEOF mso3+SIZEOF mso4+SIZEOF mssi

.code
start PROC
   INVOKE GetStdHandle, -10
   mov stdih, eax
   INVOKE GetStdHandle, -11
   mov stdoh, eax
   .repeat
       INVOKE Cls, stdoh
       INVOKE WriteConsoleA, stdoh, ADDR mst, msolen, ADDR numw, 0
       mov DWORD PTR buf, 0
       INVOKE FlushConsoleInputBuffer, stdih
       INVOKE ReadConsoleA, stdih, ADDR buf, SIZEOF buf, ADDR numw, 0
       mov eax, DWORD PTR buf
       .if eax == 000A0D33h
           INVOKE WriteConsoleA, stdoh, ADDR mso3, SIZEOF mso3, ADDR numw, 0
           INVOKE ReadConsoleA, stdih, ADDR buf, SIZEOF buf, ADDR numw, 0
       .elseif eax == 000A0D34h
           INVOKE WriteConsoleA, stdoh, ADDR mso4, SIZEOF mso4, ADDR numw, 0
           INVOKE ReadConsoleA, stdih, ADDR buf, SIZEOF buf, ADDR numw, 0
       .endif
   .until eax == 000A0D30h  ; 0 for exit
   INVOKE Cls, stdoh
   INVOKE ExitProcess, 0
start ENDP

Cls PROC h:DWORD
   LOCAL numw
   INVOKE FillConsoleOutputCharacterA, h, 20h, 80*25, 0, ADDR numw
   INVOKE SetConsoleCursorPosition, h, 0
   ret
Cls ENDP

END start
and fix all those errors someone found from this code.