Author Topic: [SOLVED]Menu items are not clickable  (Read 1385 times)

bluedevil

  • Member
  • **
  • Posts: 207
  • Binary Grinder
    • SCTZine
[SOLVED]Menu items are not clickable
« on: August 31, 2022, 11:37:44 PM »
Hello

I've attached my RadASM project. I used CreateDialogParam and create dialog and menu resources separately. After successfully assembling and linking, the executable dialog pops and i can see the menu items. But I cannot click and open sub menu items? Everything seems fine but i cannot find a workaround.

BTW I have looked товарищ Mikl__'s tut10 samples. I can assemble/link/run that codes successfully. Nevertheless the code i attached below is not working :/
« Last Edit: September 01, 2022, 04:22:55 PM by bluedevil »
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

TimoVJL

  • Member
  • *****
  • Posts: 1318
Re: Menu items are not clickable
« Reply #1 on: August 31, 2022, 11:52:35 PM »
At least WM_INITDIALOG should return TRUE
May the source be with you

bluedevil

  • Member
  • **
  • Posts: 207
  • Binary Grinder
    • SCTZine
Re: Menu items are not clickable
« Reply #2 on: September 01, 2022, 12:23:51 AM »
At least WM_INITDIALOG should return TRUE

Thank you, i have just missed that.
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

jj2007

  • Member
  • *****
  • Posts: 13944
  • Assembly is fun ;-)
    • MasmBasic
Re: Menu items are not clickable
« Reply #3 on: September 01, 2022, 12:47:27 AM »
At least WM_INITDIALOG should return TRUE

True but doesn't solve the problem.

I attach minimum code for creating a window with the Masm64 SDK. Unfortunately, there is no such example in \Masm64\Examples :cool:

bluedevil

  • Member
  • **
  • Posts: 207
  • Binary Grinder
    • SCTZine
Re: Menu items are not clickable
« Reply #4 on: September 01, 2022, 12:57:06 AM »
At least WM_INITDIALOG should return TRUE

True but doesn't solve the problem.

I attach minimum code for creating a window with the Masm64 SDK. Unfortunately, there is no such example in \Masm64\Examples :cool:

Thanks for the code jj, "come stai?" =)

I cannot make menu buttons clickable which the dialog i created with "CreateDialogParam" :/

But i can make it with "DialogboxParam", you can check the attached code below

..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

jj2007

  • Member
  • *****
  • Posts: 13944
  • Assembly is fun ;-)
    • MasmBasic
Re: Menu items are not clickable
« Reply #5 on: September 01, 2022, 01:24:42 AM »
Here is working code:

Code: [Select]
include \masm32\include64\masm64rt.inc
.data
wcx WNDCLASSEX <WNDCLASSEX, 0, WndProc, 0, 0, 1, 2, 3, COLOR_BTNFACE+1, 0, txClass, 4>
txClass db "Masm64GUI", 0 ; class name, will be registered below
txName db "Hello World", 0
.code
WndProc proc uses rsi rdi rbx hWnd, uMsg, wParam, lParam
  .if uMsg==WM_DESTROY
invoke PostQuitMessage, 0
  .endif
  invoke DefWindowProc, hWnd, uMsg, wParam, lParam ; default processing
  ret
WndProc endp
entry_point proc
LOCAL msg:MSG
  wc equ [rbx.WNDCLASSEX] ; we use an equate for better readability
  lea rbx, wcx
  mov wc.hInstance, rv(GetModuleHandle, 0) ; rv ("return value") is a Masm32 macro
  mov wc.hIcon, rv(LoadIcon, rax, IDI_APPLICATION)
  mov wc.hIconSm, rax ; the rv macro returns results in rax
  mov wc.hCursor, rv(LoadCursor, NULL, IDC_ARROW) ; get a cursor
  invoke RegisterClassEx, addr wc ; the window class needs to be registered
  invoke LoadMenu, rv(GetModuleHandle, 0), 100
  ; invoke LoadMenu, wc.hInstance, 100 ; chokes
  mov r11, rax
  mov r10, wc.lpszClassName
  invoke CreateWindowEx, WS_EX_ACCEPTFILES, r10, addr txName,\ ; set window title here
     WS_OVERLAPPEDWINDOW or WS_VISIBLE,\
     600, 150, 600, 400, 0, r11, 0 ; window position: x, y, width, height
     invoke ShowWindow, rax, SW_RESTORE

@@:
invoke GetMessage, addr msg, 0, 0, 0
inc rax
shr rax, 1
je @F ; 0 (OK) or -1 (error)
invoke TranslateMessage, addr msg
invoke DispatchMessage, addr msg
jmp @B
@@:
  invoke ExitProcess, 0
  ret
entry_point endp
end

It assembles and runs fine. However, the rv and invoke macros seem to have glitches - see r11 and rax in CreateWindowEx. Even a simple invoke LoadMenu, wc.hInstance, 100 chokes with "ERROR Unknown argument type -> [rbx.WNDCLASSEX].hInstance"


But i can make it with "DialogboxParam", you can check the attached code below

Works fine, but you really should work with windows, not dialogs.

BugCatcher

  • Member
  • **
  • Posts: 87
Re: Menu items are not clickable
« Reply #6 on: September 01, 2022, 01:30:12 AM »
DefWindowProc not used for dialogs possibly?

BugCatcher

  • Member
  • **
  • Posts: 87
Re: Menu items are not clickable
« Reply #7 on: September 01, 2022, 01:50:25 AM »
Yes remove DefWindowProc

;   .else
;      invoke  DefWindowProc,hWnd,uMsg,wParam,lParam

fearless

  • Member
  • ****
  • Posts: 577
    • Github
Re: Menu items are not clickable
« Reply #8 on: September 01, 2022, 02:53:12 AM »
Here is a RadASM template for creating Dialog As Main x64 using Uasm - and an example project created using the template.
fearless

ASUS Crosshair 8 Hero, AMD 5950X, 32GB, MSI 5700XT, NZXT Kraken Z73, Seasonic 1000W PSU

Github Twitter Mastodon Gitbook

bluedevil

  • Member
  • **
  • Posts: 207
  • Binary Grinder
    • SCTZine
Re: Menu items are not clickable
« Reply #9 on: September 01, 2022, 07:26:10 AM »
Thank you for your replies:

I have fixed it:

* I forgot to add DLGWINDOWEXTRA
Code: [Select]
    mov     wcex.cbWndExtra, DLGWINDOWEXTRA* I forgot to add DLGCLASS to rc(via using dlg editor)

Now my project works, i've added project, check below attachment

Now questions?

Works fine, but you really should work with windows, not dialogs.
@jj why did you say that? I am using RadASM's  dialog editor and it saves my time for designing a simple windows with components?

Yes remove DefWindowProc

;   .else
;      invoke  DefWindowProc,hWnd,uMsg,wParam,lParam

@BugCatcher; your suggestion did not change attitude of my code? Maybe i can use DefDlgProc for dialogs?
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

learn64bit

  • Member
  • **
  • Posts: 188
Re: [SOLVED]Menu items are not clickable
« Reply #10 on: September 02, 2022, 01:38:09 AM »
DialogAsMain.zip -> DialogAsMain.Inc
 Linenumber: 24
  Byte: 34
   0FDh

Is this should be 69h, or which codepage should I use for the "DialogAsMain.Inc" file?

And can you share your "MASM64.ini" file.

bluedevil

  • Member
  • **
  • Posts: 207
  • Binary Grinder
    • SCTZine
Re: [SOLVED]Menu items are not clickable
« Reply #11 on: September 02, 2022, 02:51:44 AM »
DialogAsMain.zip -> DialogAsMain.Inc
 Linenumber: 24
  Byte: 34
   0FDh

Is this should be 69h, or which codepage should I use for the "DialogAsMain.Inc" file?

And can you share your "MASM64.ini" file.

Thank you for noticing. I have made typo on that line.

I have written "ı" instead of i.

More information: https://en.wikipedia.org/wiki/Dotless_I
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github