News:

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

Main Menu

Do mdi children comport menus?

Started by xandaz, November 25, 2020, 06:13:34 AM

Previous topic - Next topic

xandaz

    I have this code

CreateMdiMenu   PROC    hWnd:DWORD

    invoke  CreateMenu
    mov     hMenu,eax
    invoke  SetMenu,hWnd,eax
    push    eax   
    invoke  GetWindowLong,hWnd,GWL_USERDATA
    mov     edi,eax
    pop     eax
    mov     [edi.MdiStruct.hMenu],eax
    invoke  CreatePopupMenu
    mov     hMenuMdiFile,eax
    invoke  CreatePopupMenu
    mov     hMenuMdiEdit,eax
    invoke  CreatePopupMenu
    mov     hMenuMdiTools,eax
    lea     esi,MiiMdiChild
    push    hMenuMdiFile
    pop     [esi.MENUITEMINFO.hSubMenu]
    invoke  InsertMenuItem,hMenu,-1,TRUE,esi
    add     esi,sizeof MENUITEMINFO
    push    hMenuMdiEdit
    pop     [esi.MENUITEMINFO.hSubMenu]
    invoke  InsertMenuItem,hMenu,-1,TRUE,esi
    add     esi,sizeof MENUITEMINFO
    push    hMenuMdiTools
    pop     [esi.MENUITEMINFO.hSubMenu]
    invoke  InsertMenuItem,hMenu,-1,TRUE,esi
    lea     esi,MiiMdiEdit
    mov     edi,119
    mov     ecx,3
loop_1:
    push    ecx
    invoke  LoadBitmap,hInstance,edi
    mov     [esi.MENUITEMINFO.hbmpChecked],eax
    invoke  InsertMenuItem,hMenuMdiFile,-1,TRUE,esi   
    add     esi,sizeof MENUITEMINFO
    inc     edi
    pop     ecx
    loop    loop_1
    invoke  DrawMenuBar,hWnd
    ret
       
CreateMdiMenu   endp

    No menu appears. why would that be?

xandaz

   i've been experiencing with WM_MDISETMENU but nothing happens.

xandaz

    I'm still fighting against these mdi children. Why dont they accept menus?

jj2007

If you post complete code, maybe somebody can help

xandaz

here the code:
   .elseif uMsg==WM_CREATE
        invoke  MdiCreateWindows,hWnd


MdiCreateWindows   PROC    hWnd:DWORD

        mov     ebx,noMdiChild
        mov     eax,sizeof MdiStruct
        xor     edx,edx
        mul     ebx
        lea     edi,MdiStructs
        add     edi,eax
        invoke  SetWindowLong,hWnd,GWL_USERDATA,edi
        push    edi
        invoke  CreateMdiMenu,hWnd
        invoke  CreateToolbar,hWnd
        pop     edi
        invoke  GetClientRect,hWnd,addr rect
        sub     rect.bottom,38+22+22
        invoke  CreateWindowEx,0,addr WC_RICHEDIT50W,0,WS_VISIBLE+WS_CHILD+ES_SAVESEL+\
                    ES_MULTILINE+ES_LEFT+ES_AUTOHSCROLL+ES_AUTOVSCROLL+WS_HSCROLL+WS_VSCROLL,\
                    0,38+22,rect.right,rect.bottom,hWnd,RichEditId,hInstance,0
        mov     [edi.MdiStruct.hEdit],eax
        inc     noMdiChild
        inc     RichEditId
        invoke  GetClientRect,hWnd,addr rect
        sub     rect.bottom,22
        invoke  CreateWindowEx,WS_EX_STATICEDGE,addr WC_STATIC,0,WS_VISIBLE+WS_CHILD\
                        +SS_SIMPLE,rect.left,rect.bottom,rect.right,20,hWnd,\
                        0,hInstance,0
        mov     [edi.MdiStruct.hStatic],eax
        ret
       
MdiCreateWindows   endp

CreateMdiMenu   PROC    hWnd:DWORD

    local   hMdiMenu:DWORD
    local   hActive:DWORD
   
    invoke  CreateMenu
    mov     hMdiMenu,eax
    push    eax
    invoke  SetMenu,hWnd,eax
    invoke  GetWindowLong,hWnd,GWL_USERDATA
    mov     edi,eax
    pop     eax
    mov     [edi.MdiStruct.hMenu],eax
    invoke  CreatePopupMenu
    mov     hMenuMdiFile,eax
    invoke  CreatePopupMenu
    mov     hMenuMdiEdit,eax
    invoke  CreatePopupMenu
    mov     hMenuMdiTools,eax
    lea     esi,MiiMdiChild
    push    hMenuMdiFile
    pop     [esi.MENUITEMINFO.hSubMenu]
    invoke  InsertMenuItem,hMdiMenu,-1,TRUE,esi
    add     esi,sizeof MENUITEMINFO
    push    hMenuMdiEdit
    pop     [esi.MENUITEMINFO.hSubMenu]
    invoke  InsertMenuItem,hMdiMenu,-1,TRUE,esi
    add     esi,sizeof MENUITEMINFO
    push    hMenuMdiTools
    pop     [esi.MENUITEMINFO.hSubMenu]
    invoke  InsertMenuItem,hMdiMenu,-1,TRUE,esi
    lea     esi,MiiMdiFile
    mov     edi,119
    mov     ecx,3
loop_1:
    push    ecx
    invoke  LoadImage,hInstance,edi,IMAGE_BITMAP,16,16,LR_SHARED
    mov     [esi.MENUITEMINFO.hbmpChecked],eax
    mov     [esi.MENUITEMINFO.hbmpUnchecked],eax
   
    invoke  InsertMenuItem,hMenuMdiFile,-1,TRUE,esi   
    add     esi,sizeof MENUITEMINFO
    inc     edi
    pop     ecx
    loop    loop_1
    invoke  SendMessage,hMdi,WM_MDISETMENU,hMenu,hMdiMenu
    invoke  DrawMenuBar,hWnd
    ret

xandaz

   Thanks in advance. Let me know if you need all the code....cause i'll post.

jj2007

Quote from: xandaz on November 26, 2020, 02:34:49 AM
   Thanks in advance. Let me know if you need all the code....cause i'll post.

Of course we need the complete code! Do you think anybody has the time and energy to add all the headers and WndMain and WndProc to your snippet, in order to make it debuggable???

xandaz


xandaz

    what we're after is in the mdichild.asm.

xandaz

   It gives INVALID_WINDOW_HANDLE on SetMenu,hWnd,hMdiMenu although i'm not sure this call is necessary and gives the same error on WM_MDISETMENU and DrawMenuBar.

xandaz

    Sorry the  error for SetMenu is ERROR_CHILD_WINDOW_MENU.

xandaz

    I'm pretty sure it's a lost issue. One must use WM_MDISETMENU to change menus but the menu bar always appears in the Frame Window.

jj2007

It took me half an hour to fix things like [edi.CREATESTRUCT.hWndParent] instead of your [edi.CREATESTRUCT.hwndParent] ("Symbol not defined : CREATESTRUCTW.hwndParent"), the align_2 issue etc, only to discover that the WM_MDISETMENU message that you complain about is not present in your code. You are wasting my precious time.

xandaz

   I would laugh a little but it seems you're pretty serious. Sorry for anything.

jj2007

I wonder how you made this code assemble, it throws errors :cool: