MDI: окна не добавляються в список меню

Тема в разделе "WASM.BEGINNERS", создана пользователем zzzyab, 28 июн 2005.

Статус темы:
Закрыта.
  1. zzzyab

    zzzyab New Member

    Публикаций:
    0
    Регистрация:
    13 май 2004
    Сообщения:
    115
    Все вроде правильно, окна создаю через CreateMDIСhild

    И пример в статье про MDI у меня нерабочий.

    Весь набор и сам код:
    Код (Text):
    1.  
    2. .486
    3. .model flat
    4. include kernel.inc
    5. include user.inc
    6. include comdlg.inc
    7. include comctl.inc
    8. include iee.inc
    9. min_h   equ 70h
    10. min_w   equ 12ah
    11. .code
    12. assume fs:nothing
    13. public _start
    14.  
    15. FW_MDICHILD equ 500h
    16.  
    17. err_heap    equ 0
    18. err_mem     equ 4
    19. err_class   equ 8
    20. err_wnd     equ 12
    21. err_size    equ 16
    22. err_:
    23.     ret
    24. _start:
    25.    
    26.     push    excpt1_
    27.     push    dword ptr fs:[0]
    28.     mov fs:[0],esp
    29.  
    30.     xor ebx,ebx
    31.     mov esi,esp
    32.     push    ebx
    33.     call    GetModuleHandle
    34.     mov hinst,eax
    35.     call    GetProcessHeap
    36.     push    1024
    37.     push    HEAP_ZERO_MEMORY
    38.     push    eax
    39.     call    HeapAlloc
    40.     test    eax,eax
    41.     jnz @f
    42.     xor ecx,ecx
    43. err1_:
    44.     pop dword ptr fs:[0]
    45.     add esp,4
    46.     ret
    47. @@:
    48.     mov heap,eax
    49.     push    PAGE_READWRITE
    50.     push    MEM_COMMIT
    51.     push    200000h
    52.     push    0
    53.     call    VirtualAlloc
    54.     test    eax,eax
    55.     jnz @f
    56.     mov ecx,err_mem
    57.     jmp err1_
    58. @@:
    59.     mov hmem,eax
    60.     push    ebx
    61.     push    offset nclass
    62.     push    offset nmenu
    63.     push    COLOR_MENU+1
    64.     push    IDC_ARROW
    65.     push    ebx
    66.     call    LoadCursor
    67.     push    eax
    68.     push    IDI_WINLOGO
    69.     push    ebx
    70.     call    LoadIcon
    71.     push    eax
    72.     mov ecx,hinst
    73.     push    ecx
    74.     push    ebx
    75.     push    ebx
    76.     push    wndproc
    77.     push    CS_HREDRAW+CS_VREDRAW
    78.     push    48
    79.     push    esp
    80.     call    RegisterClassEx
    81.     test    eax,eax
    82.     jnz @f
    83.     mov esp,esi
    84.     mov ecx,err_class
    85.     push    end_
    86.     jmp err_
    87. @@:
    88.     mov edx,DefMDIChildProc
    89.     mov [esp+8],edx
    90.     mov ecx,COLOR_WINDOW+1
    91.     mov [esp+32],ecx
    92.     lea eax,nmdiclass
    93.     mov [esp+40],eax
    94.     push    esp
    95.     call    RegisterClassEx
    96.     mov esp,esi
    97.     test    eax,eax
    98.     jnz @f
    99.     mov ecx,err_class
    100.     push    end_
    101.     jmp err_
    102. @@:
    103.     push    ebx
    104.     mov eax,hinst
    105.     push    eax
    106.     push    ebx
    107.     push    ebx
    108.     mov ecx,CW_USEDEFAULT
    109.     push    ecx
    110.     push    ecx
    111.     push    ecx
    112.     push    ecx
    113.     push    WS_OVERLAPPEDWINDOW+WS_VISIBLE
    114.     push    offset nwnd
    115.     push    offset nclass
    116.     push    ebx
    117.     call    CreateWindowEx
    118.     mov ecx,err_wnd
    119.     test    eax,eax
    120.     jz  err_
    121.     push    eax
    122.     mov hwnd,eax
    123.     call    UpdateWindow
    124.     sub esp,28
    125.     mov msg,esp
    126. cycl_msg:
    127.     push    ebx
    128.     push    ebx
    129.     push    ebx
    130.     mov edx,msg
    131.     push    edx
    132.     call    GetMessage
    133.     test    eax,eax
    134.     jnz @f
    135.     add esp,28
    136. end_:
    137.     pop dword ptr fs:[0]
    138.     add esp,4
    139. excpt1_:
    140.     mov ecx,hmem
    141.     push    MEM_RELEASE
    142.     push    ebx
    143.         push    ecx
    144.     call    VirtualFree
    145.     mov eax,1
    146.     ret
    147. @@:
    148.     cmp eax,-1
    149.     jnz @f
    150.     push    end_
    151.     jmp err_
    152. @@:
    153.     mov edx,msg
    154.     push    edx
    155.     call    TranslateMessage
    156.     mov ecx,msg
    157.     push    ecx
    158.     call    DispatchMessage
    159.     jmp cycl_msg
    160. align 4
    161. wndproc:
    162.     mov eax,[esp+8]
    163.     xor ebx,ebx
    164.     cmp eax,WM_CREATE
    165.     je  create
    166.     cmp eax,WM_DESTROY
    167.     je  destroy
    168.     cmp     eax,WM_COMMAND
    169.     je  command
    170.     cmp eax,WM_GETMINMAXINFO
    171.     je  minmax
    172. ;   cmp eax,WM_WINDOWPOSCHANGED
    173. ;   je  poschng
    174. frmproc:
    175.     pop ecx
    176.     pop edx
    177.     mov eax,hmdiclnt
    178.     push    eax
    179.     push    edx
    180.     push    ecx
    181.     jmp DefFrameProc
    182. destroy:
    183.     push    ebx
    184.     call    PostQuitMessage
    185.     xor eax,eax
    186.     ret 16
    187. minmax:
    188.     mov eax,[esp+16]
    189.     mov ecx,min_w
    190.     mov edx,min_h
    191.     add eax,18h
    192.     mov [eax],ecx
    193.     mov [eax+4],edx
    194.     xor eax,eax
    195.     ret 16
    196. create:
    197.  
    198.     push    ICC_TREEVIEW_CLASSES+ICC_BAR_CLASSES
    199.     push    8
    200.     push    esp
    201.     call    InitCommonControlsEx
    202.  
    203. ;   push    1
    204. ;   mov ecx,[esp+16]
    205. ;   push    ecx
    206. ;   push    ebx
    207. ;   push    WS_CHILD+WS_VISIBLE
    208. ;   call    CreateStatusWindow
    209. ;   test    eax,eax
    210. ;   jnz @f
    211. ;   mov ecx,err_wnd
    212. ;   push    destroy
    213. ;   jmp err_
    214. @@:
    215. ;   mov hstatus,eax
    216.  
    217.     push    1
    218.     mov edx,[esp+16]
    219.     push    edx
    220.     call    GetMenu
    221.     push    eax
    222.     call    GetSubMenu
    223.     push    eax
    224.     push    FW_MDICHILD
    225.     mov ecx,esp
    226.     push    't'
    227.     push    'neil'
    228.     push    'cidm'
    229.     mov edx,esp
    230.  
    231.     push    ecx
    232.     mov eax,hinst
    233.     push    eax
    234.     push    0cach
    235.     mov ecx,[esp+44]
    236.     push    ecx
    237.     push    ebx
    238.     push    ebx
    239.     push    ebx
    240.     push    ebx
    241.     push    WS_CLIPCHILDREN+WS_CHILD+WS_HSCROLL+WS_VSCROLL+WS_VISIBLE
    242.     push    ebx
    243.     push    edx
    244.     push    ebx
    245.     call    CreateWindowEx
    246.     add esp,28
    247.     test    eax,eax
    248.     jnz @f
    249.     mov ecx,err_wnd
    250.     push    destroy
    251.     jmp err_
    252. @@:
    253.     mov hmdiclnt,eax
    254.     xor eax,eax
    255.     ret 16
    256. poschng:
    257.     push    ebx
    258.     push    ebx
    259.     push    5
    260.     mov eax,hstatus
    261.     push    eax
    262.     call    SendMessage
    263.     jmp frmproc
    264.     xor eax,eax
    265.     ret 16
    266. command:
    267.     mov eax,[esp+12]
    268.     and eax,0ffffh
    269.     cmp eax,IDM_WINDOW
    270.     jae frmproc
    271.     sub eax,100h
    272.     jmp [_cmd+eax]
    273. _cmdopen:
    274.     push    ebx
    275.     mov eax,hinst
    276.     push    eax
    277.     mov edx,hmdiclnt
    278.     push    edx
    279.     sub esp,16
    280.     push    esp
    281.     push    edx
    282.     call    GetClientRect
    283.     push    WS_VISIBLE+WS_HSCROLL+WS_VSCROLL
    284.     lea eax,nwnd
    285.     push    eax
    286.     lea ecx,nmdiclass
    287.     push    ecx
    288.     call    CreateMDIWindow
    289.  
    290.     xor eax,eax
    291.     ret 16
    292. _cmdsave:
    293.     xor eax,eax
    294.     ret 16
    295. _cmdquit:
    296.     jmp destroy
    297.  
    298. align 4
    299. _cmd    dd _cmdopen,_cmdsave,_cmdquit
    300.  
    301.  
    302. nmenu db 'MENU1',0
    303. nclass db 'IEE01',0
    304. nmdiclass db 'GENMDIWND',0
    305. nwnd db 'IEE',0
    306. name_about db 'ABOUT',0
    307.  
    308. .data?
    309. align 4
    310. msg dd ?
    311. hinst   dd ?
    312. hwnd    dd ?
    313. hmdiclnt dd ?
    314. hstatus dd ?
    315. hmdichld dd ?
    316. heap    dd ?
    317. hmem    dd ?
    318.  
    319. end
    320.  
    [​IMG] 1018456522__Iee.zip
     
  2. q_q

    q_q New Member

    Публикаций:
    0
    Регистрация:
    5 окт 2003
    Сообщения:
    1.706
    zzzyab

    У тебя
    Код (Text):
    1. ...
    2.   push  1
    3.   mov   edx,[esp+16]
    4.   push  edx
    5.   call  GetMenu
    6.   push  eax
    7.   call  GetSubMenu
    8.   push  eax
    9.   push  FW_MDICHILD
    10.   mov   ecx,esp
    11. ...
    а надо
    Код (Text):
    1. ...
    2.   push  FW_MDICHILD
    3.   push  1
    4.   mov   edx,[esp+20]
    5.   push  edx
    6.   call  GetMenu
    7.   push  eax
    8.   call  GetSubMenu
    9.   push  eax
    10.   mov   ecx,esp
    11. ...
    ибо CLIENTCREATESTRUCT выглядит так
    Код (Text):
    1. typedef struct {
    2.     HANDLE hWindowMenu;
    3.     UINT idFirstChild;
    4. } CLIENTCREATESTRUCT, *LPCLIENTCREATESTRUCT;
     
  3. zzzyab

    zzzyab New Member

    Публикаций:
    0
    Регистрация:
    13 май 2004
    Сообщения:
    115
    Сбасибо - заработало
     
Статус темы:
Закрыта.