The MASM Forum

General => The Campus => Topic started by: xandaz on November 25, 2020, 06:13:34 AM

Title: Do mdi children comport menus?
Post by: xandaz on November 25, 2020, 06:13:34 AM
    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?
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 25, 2020, 06:57:55 AM
   i've been experiencing with WM_MDISETMENU but nothing happens.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 25, 2020, 10:34:13 AM
    I'm still fighting against these mdi children. Why dont they accept menus?
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 25, 2020, 11:04:28 AM
If you post complete code, maybe somebody can help
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 02:33:07 AM
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
Title: Re: Do mdi children comport menus?
Post by: 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.
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 26, 2020, 03:29:17 AM
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???
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 03:41:26 AM
   ....ok. sorry.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 04:39:51 AM
    what we're after is in the mdichild.asm.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 05:23:20 AM
   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.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 05:41:27 AM
    Sorry the  error for SetMenu is ERROR_CHILD_WINDOW_MENU.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 07:29:50 AM
    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.
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 26, 2020, 08:48:50 PM
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.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 08:54:56 PM
   I would laugh a little but it seems you're pretty serious. Sorry for anything.
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 26, 2020, 08:58:25 PM
I wonder how you made this code assemble, it throws errors :cool:
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 09:00:40 PM
   i was going through my own experiencies. WM_MDISETMENU was prolly commented. But did you get it to work? and [edi.CREATESTRUCT.hwndParent is not the way that's in the header. i din't know about the align_2 issue. Seems to work fine. Soryr if i wasted your time. Don't need to be rude. Thanks anyway
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 09:16:09 PM
   But did you get the menu to work? ty ty
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 26, 2020, 10:32:34 PM
   It doesn't throw error. Assembles just fine. the supposed CREATESTRUCT.hwndParent issue doesn't even deserve to be mentioned. ît's a header problem. And the align_2 issue. I really don't see the point cause it's working just fine. I'm sorry and disgusted for myself for not being able to live up to your God-level or coding.
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 26, 2020, 10:45:52 PM
The code you posted at http://masm32.com/board/index.php?topic=8967.msg98143#msg98143 does not assemble, due to several little problems (I tried with MASM and UASM), and it does not contain the WM_MDISETMENU message that you say is not working.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 27, 2020, 02:29:44 AM
   It's not fully able but i think that this is the way WM_MDISETMENU message works. Haven't been able to make it restore the original frame window Menu but it seems that it's all. No child window menus allowed. ty
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 27, 2020, 03:43:59 AM
   It appears that this is all that can be done. An exchange of menus using WM_NCMOUSEMOVE works perfectlly. No menus for child windows. ty. If you're interested to check it out it's under MdiChildProc and WndProc, tahnks JJ
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 27, 2020, 06:15:10 AM
Error A2063: Symbol not defined : CREATESTRUCTW.hwndParent

Did you "adjust" your Windows.inc?
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 27, 2020, 07:41:43 AM
    no i did not because that's not very important. but i'll get there
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 27, 2020, 11:01:02 AM
So explain to me how you can assemble the code you posted, in spite of the undefined CREATESTRUCT.hwndParent issue. Or do you post code that assembles with errors?
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 28, 2020, 01:38:43 AM
    Is it possible to assemble with errors? it has some issues i know but it assembles. How could there be an executable if it didn't?
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 28, 2020, 02:17:55 AM
Quote from: xandaz on November 28, 2020, 01:38:43 AMHow could there be an executable if it didn't?

That is a valid argument, but then how is it possible that you don't get an error message for CREATESTRUCT.hwndParent? Can you post your Windows.inc? This is mysterious, I'd like to understand what's going on.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 28, 2020, 02:51:27 AM
  from windows.inc
.CREATESTRUCTA STRUCT
  lpCreateParams    DWORD      ?
  hInstance         DWORD      ?
  hMenu             DWORD      ?
  hwndParent        DWORD      ?
  ly                DWORD      ?
  lx                DWORD      ?
  y                 DWORD      ?
  x                 DWORD      ?
  style             DWORD      ?
  lpszName          DWORD      ?
  lpszClass         DWORD      ?
  ExStyle           DWORD      ?
CREATESTRUCTA ENDS

CREATESTRUCTW STRUCT
  lpCreateParams    DWORD      ?
  hInstance         DWORD      ?
  hMenu             DWORD      ?
  hwndParent        DWORD      ?
  ly                DWORD      ?
  lx                DWORD      ?
  y                 DWORD      ?
  x                 DWORD      ?
  style             DWORD      ?
  lpszName          DWORD      ?
  lpszClass         DWORD      ?
  ExStyle           DWORD      ?
CREATESTRUCTW ENDS
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 28, 2020, 03:03:35 AM
My version says hWndParent, from Windows.inc, 977412 bytes, 10.1.2012 00:21

So you have an obsolete or "adjusted" Windows.inc :cool:

CREATESTRUCTA STRUCT
  lpCreateParams    DWORD      ?
  hInstance         DWORD      ?
  hMenu             DWORD      ?
  hWndParent        DWORD      ?
  ly                DWORD      ?
  lx                DWORD      ?
  y                 DWORD      ?
  x                 DWORD      ?
  style             DWORD      ?
  lpszName          DWORD      ?
  lpszClass         DWORD      ?
  ExStyle           DWORD      ?
CREATESTRUCTA ENDS
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 28, 2020, 03:07:05 AM
   you're repeating yourself. I alreadu know that. Assembles with  error. it's a special argument ml ?.asm /TAS (take all shit)
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 28, 2020, 03:16:37 AM
You have an obsolete or "adjusted" Windows.inc

Which means whatever source code you post may not run on the machines of other members.

There is a reason why I asked you above to post your Windows.inc
Title: Re: Do mdi children comport menus?
Post by: nidud on November 28, 2020, 03:29:36 AM
deleted
Title: Re: Do mdi children comport menus?
Post by: Vortex on November 28, 2020, 03:32:23 AM
It's easy to verify the authenticity of those files, simple MD5 check :

9ac0409fdc21f94e07b627ccd575b43d *\masm32\include\\windows.inc
0b6c5c13a57db2e34ee7c2232c0665d8 *\masm32\include\winextra.inc


Jochen, could you send your MD5 values?
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 28, 2020, 03:37:07 AM
    it's the way it's in the manual. i don't remember adjusting but probabily happened. take it easy JJ. ...and thanks
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 28, 2020, 03:42:55 AM
Quote from: nidud on November 28, 2020, 03:29:36 AM

https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-createstructw

typedef struct tagCREATESTRUCTW {
  LPVOID    lpCreateParams;
  HINSTANCE hInstance;
  HMENU     hMenu;
  HWND      hwndParent;

Yes I know - the Masm32 SDK version is "wrong", but it works perfectly. You can name it HandleOfMyParent, and it will still work. The point is that we are a community of coders who want to exchange ideas and help each other. That can work only if we use exactly the same include files. As soon as somebody fumbles his *.inc files, it is a big waste of time for those who are trying to be helpful.
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 28, 2020, 03:48:42 AM
Quote from: Vortex on November 28, 2020, 03:32:23 AM
It's easy to verify the authenticity of those files, simple MD5 check :

9ac0409fdc21f94e07b627ccd575b43d *\masm32\include\\windows.inc
0b6c5c13a57db2e34ee7c2232c0665d8 *\masm32\include\winextra.inc


Jochen, could you send your MD5 values?

Sure:

include \masm32\MasmBasic\MasmBasic.inc         ; download (http://masm32.com/board/index.php?topic=94.0)
  Init
  GetHashRev=1
  If_ GetHash(FileRead$(<CL$()>), LastFileSize, md5) Then PrintLine "The MD5 of ", CL$(), " is ", Hex$(xmm0)
EndOfCode


The MD5 of \Masm32\include\Windows.inc is 9AC0409F DC21F94E 07B627CC D575B43D

Source & exe attached, so that xandaz can post his values, too.
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 29, 2020, 06:59:43 AM
   The code became too complex and i'm having a hard time finding a certain glitch. When i close a project and the reopen only one of the source files is loaded. JJ said something about the align_2 issue. i wonder if thta's what you ment...can soomeone help out.
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 29, 2020, 08:10:03 AM
Error A2063: Symbol not defined : CREATESTRUCTW.hwndParent

I will not adjust my Windows.inc for you
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 29, 2020, 08:20:08 AM
    here is goes corrected.
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 29, 2020, 12:02:56 PM
Thanks. I've been able to assemble it, and it runs fine. The WM_MDISETMENU message succeeds without error, but there is no menu in the mdi child. However, if you move the mouse between the main and mdi captions, you will notice that the main menu changes between Edit and Build.

Have you studied Iczelion's tutorial on mdi menus?

http://www.interq.or.jp/chubu/r6/masm32/tute/tute032.html
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 29, 2020, 08:40:00 PM
   Thanks JJ. What was  :skrewy: align_2 issue that you were talking about? The application only loads the full project at runtime. after closing the project it only loads one window. it's strange but i'm not sure that it has something to do with ManageOpenMode. it's spmething far simpler.
Title: Re: Do mdi children comport menus?
Post by: jj2007 on November 29, 2020, 09:57:11 PM
Quote from: xandaz on November 29, 2020, 08:40:00 PMWhat was  :skrewy: align_2 issue that you were talking about?

A name conflict. I tested your code with MasmBasic, which includes essential stuff from the Masm32 SDK; for example: \Masm32\include\dialogs.inc

include \masm32\include\masm32rt.inc  ; pure Masm32

.code
start:
mov ecx, 3
align_2:
  dec ecx
  loopnz align_2
  MsgBox 0, "ok?", "Test:", MB_OK
  exit

end start
Title: Re: Do mdi children comport menus?
Post by: xandaz on November 29, 2020, 10:00:44 PM
   Yeah...well. Problem solved. It was the Final_File flag. it had to be reset. I moved things around a little like in Iczelion's tute but the result is exactlly the same. Thanks JJ