News:

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

Main Menu

[SOLVED]Menu items are not clickable

Started by bluedevil, August 31, 2022, 11:37:44 PM

Previous topic - Next topic

bluedevil

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 :/
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

TimoVJL

At least WM_INITDIALOG should return TRUE
May the source be with you

bluedevil

Quote from: TimoVJL on August 31, 2022, 11:52:35 PM
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

Quote from: TimoVJL on August 31, 2022, 11:52:35 PM
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

Quote from: jj2007 on September 01, 2022, 12:47:27 AM
Quote from: TimoVJL on August 31, 2022, 11:52:35 PM
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

Here is working code:

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"


Quote from: bluedevil on September 01, 2022, 12:57:06 AMBut 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

DefWindowProc not used for dialogs possibly?

BugCatcher

Yes remove DefWindowProc

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

fearless

Here is a RadASM template for creating Dialog As Main x64 using Uasm - and an example project created using the template.

bluedevil

Thank you for your replies:

I have fixed it:

* I forgot to add DLGWINDOWEXTRA
    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?

Quote from: jj2007 on September 01, 2022, 01:24:42 AM
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?

Quote from: BugCatcher on September 01, 2022, 01:50:25 AM
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

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

Quote from: learn64bit 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.

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