flat assembler
Message board for the users of flat assembler.

Index > Windows > how create a floating menu?

Author
Thread Post new topic Reply to topic
j2lf22



Joined: 02 Nov 2004
Posts: 1
j2lf22
how create a floating menu?

[edit by moderator]Please giver your threads descriptive names, names like "j2lf22" is not considered descriptive. - topic name changed-[/edit]
Post 02 Nov 2004, 01:26
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
TrackPopupMenu
Post 02 Nov 2004, 02:05
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 885
Location: \\world\asia\malaysia
vbVeryBeginner
try this Smile
Code:
format PE GUI 4.0
entry start

include '%fasminc%\win32a.inc'

section '.data' data readable writeable
     wndH            dd ?
        insH            dd ?
        wndClsName      db 'GENERIC',0
    wndTitle        db 'Popup Menu Demo',0

        wndCls  WNDCLASS
    wndMsg  MSG

     menuH   dd ?
        point   POINT
       dcH     dd ?
        rect    RECT

section '.code' code readable executable
start:
        invoke  GetModuleHandle,0
           mov  [insH],eax
             mov  [wndCls.hInstance],eax
         mov  [wndCls.style],CS_HREDRAW or CS_VREDRAW
                mov  [wndCls.lpfnWndProc],window_procedure
          mov  [wndCls.lpszClassName],wndClsName
              mov  [wndCls.hbrBackground],COLOR_APPWORKSPACE+1
    invoke  LoadIcon,NULL,IDI_APPLICATION
               mov  [wndCls.hIcon],eax
     invoke  LoadCursor,NULL,IDC_ARROW
           mov  [wndCls.hCursor],eax
   invoke  RegisterClass,wndCls

    invoke  CreateWindowEx,WS_EX_CLIENTEDGE,\
          wndClsName,wndTitle,\
              WS_OVERLAPPEDWINDOW + WS_VISIBLE - WS_MINIMIZEBOX - WS_MAXIMIZEBOX,\
               CW_USEDEFAULT,CW_USEDEFAULT,400,240,\
              NULL,NULL,[insH],NULL
               mov  [wndH],eax

 invoke  LoadMenu,[insH],30
  invoke  GetSubMenu,eax,0
            mov  [menuH],eax
            mov  [rect.left],0
          mov  [rect.top],0

;+---------------------------+
;| entering the message loop |
;+---------------------------+
window_message_loop_start:
       invoke  GetMessage,wndMsg,NULL,0,0
          or    eax,eax
               je    window_message_loop_end
       invoke  TranslateMessage,wndMsg
     invoke  DispatchMessage,wndMsg
              jmp     window_message_loop_start

window_message_loop_end:
       invoke  DestroyMenu,[menuH]
 invoke  ExitProcess,0

;+----------------------+
;| the window procedure |
;+----------------------+
proc window_procedure,hWnd,uMsg,wParam,lParam
           push ebx esi edi
            cmp  [uMsg],WM_RBUTTONDOWN
          je   wmRBUTTONDOWN
          cmp  [uMsg],WM_SIZE
         je   wmSIZE
         cmp  [uMsg],WM_COMMAND
              je   wmCOMMAND
              cmp  [uMsg],WM_DESTROY
              je   wmDESTROY

  wmDEFAULT:
              invoke  DefWindowProc,[hWnd],[uMsg],[wParam],[lParam]
                       jmp  wmBYE

        wmSIZE:
                       mov  edx,[lParam]
                   mov  ecx,edx
                        shr  ecx,16             ;height - high order
                        and  edx,0xFFFF         ;width  - low order
                 mov  [rect.right],edx
                       mov  [rect.bottom],ecx
                      jmp  wmBYE

      wmRBUTTONDOWN:
          invoke  GetCursorPos,point
          invoke  TrackPopupMenu,[menuH],TPM_RIGHTBUTTON,\
                   [point.x],[point.y],0,[hWnd],NULL
                   jmp  wmBYE
  
    wmCOMMAND:
              invoke  GetDC,[hWnd]
                        cmp  [wParam],0xFFFF and 300
                        je   wmCOMMAND_300
                  cmp  [wParam],0xFFFF and 301
                        je   wmCOMMAND_301
                  cmp  [wParam],0xFFFF and 302
                        je   wmCOMMAND_302
                  jmp  wmBYE
  
            wmCOMMAND_300:
                  invoke  FillRect,eax,rect,COLOR_ACTIVECAPTION+1
                     invoke  ReleaseDC,[hWnd],[dcH]
                              jmp  wmBYE

              wmCOMMAND_301:
                  invoke  FillRect,eax,rect,COLOR_INACTIVECAPTION+1
                   invoke  ReleaseDC,[hWnd],[dcH]
                              jmp  wmBYE

              wmCOMMAND_302:
                  invoke  FillRect,eax,rect,COLOR_CAPTIONTEXT+1
                       invoke  ReleaseDC,[hWnd],[dcH]
                              jmp  wmBYE

      wmDESTROY:
              invoke  PostQuitMessage,0

       wmBYE:
          pop edi esi ebx
             return
   endp

section '.idata' import data readable
    library KERNEL32, 'KERNEL32.DLL',\
               USER32,   'USER32.DLL'
    
    import  KERNEL32,\
         GetModuleHandle,        'GetModuleHandleA',\
             ExitProcess,            'ExitProcess'
     import  USER32,\
           RegisterClass,          'RegisterClassA',\
               CreateWindowEx,         'CreateWindowExA',\
              DefWindowProc,          'DefWindowProcA',\
               LoadCursor,             'LoadCursorA',\
          LoadIcon,               'LoadIconA',\
            LoadMenu,               'LoadMenuA',\
            GetSubMenu,             'GetSubMenu',\
           GetCursorPos,           'GetCursorPos',\
         TrackPopupMenu,         'TrackPopupMenu',\
               FillRect,               'FillRect',\
             GetDC,                  'GetDC',\
                ReleaseDC,              'ReleaseDC',\
            DestroyMenu,            'DestroyMenu',\
          MoveWindow,             'MoveWindow',\
           SendMessage,            'SendMessageA',\
         GetMessage,             'GetMessageA',\
          MessageBox,             'MessageBoxA',\
          DestroyWindow,          'DestroyWindow',\
                TranslateMessage,       'TranslateMessage',\
             DispatchMessage,        'DispatchMessageA',\
             PostQuitMessage,        'PostQuitMessage'
 

section '.rsrc' resource data readable

        directory RT_MENU,appMenu

       resource  appMenu,\
                  30,LANG_NEUTRAL,menu1

 menu menu1
          menuitem '',0,MFR_POPUP+MFR_END
           menuitem        'Active Caption Color',300,0
              menuitem        'Inactive Caption Color',301,0
            menuitem        'Caption Text Color',302,MFR_END
    


Image
sincerely,
sulaiman chang
Post 02 Nov 2004, 04:57
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.