News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

creating a dialogue without resource compiler

Started by Mikl__, July 29, 2015, 06:12:20 PM

Previous topic - Next topic

Mikl__

Good day!
Does anyone have an example of creating a dialogue with the menu without resource compiler? Through DialogBoxIndirectParam or otherwise? Thank you very much....

jj2007

You need to handle WM_INITDIALOG:

  CASE WM_INITDIALOG
mov esi, rv(CreateMenu) ; create the main menu
mov edi, rv(CreatePopupMenu) ; create a sub-menu
invoke AppendMenu, esi, MF_POPUP, edi, chr$("&File") ; add it to the main menu
mov ebx, rv(CreatePopupMenu) ; create a sub-menu
invoke AppendMenu, ebx, MF_STRING, 121, chr$("&asm") ; fill it
invoke AppendMenu, ebx, MF_STRING, 122, chr$("&inc") ; with various
invoke AppendMenu, ebx, MF_STRING, 123, chr$("&rc") ; options
invoke AppendMenu, edi, MF_POPUP, ebx, chr$("&Dir") ; and add it to the main menu as "Dir"
invoke AppendMenu, edi, MF_STRING, 102, chr$("&Save") ; one more main item
invoke SetMenu, hDlg, esi ; attach menu to main window


Full example attached, but caution, it's MasmBasic ;-)

dedndave

i don't have an example handy
however, in the file \masm32\include\dialogs.inc
you will find several macros that may be used to create dialog boxes and controls
very helpful if you want to understand how to roll your own

the file \masm32\m32lib\gettext.asm is one example of how they might be used

dedndave

as for creating menus, here's another example...

http://masm32.com/board/index.php?topic=4104.msg43527#msg43527

and, in this thread, i demonstrate a routine that creates a menu from a table
it creates a main menu and uses the same routine to create a right-click context menu

http://masm32.com/board/index.php?topic=4124.msg43702#msg43702


Mikl__

Good evening!
jj2007, dedndave thank you for responding, I'll taste your examples
jj2007,
not afraid that the example in MasmBasic -- for real hacker it isn't a Problem!

rrr314159

Quote from: Mikl__not afraid that the example in MasmBasic -- for real hacker it isn't a Problem!

Never thought to hack MasmBasic! Reason I don't use it, there's no source (except the macros, which I have borrowed from). Maybe this is a way I could go ahead with it - hack and create my own source! Well, as soon as I find X months / years to spend on it ... It's probably illegal, but that's only Italian law, and here in the US we simply ask "How many divisions does the Pope have?" :biggrin:
I am NaN ;)

jj2007

Quote from: rrr314159 on July 30, 2015, 01:01:34 AMNever thought to hack MasmBasic! Reason I don't use it, there's no source

HA :badgrin:

MasmBasic.inc, lines 800...1115 or so has the Dlg macros, and they are pretty standalone, and even commented. So there is a source, but attention, it's written in a way that brain damage is programmed 8)

rrr314159

Certainly I didn't study it much, but did skim the macro file and get some ideas, even snippets. But there are supporting .asm modules in the lib; I was referring to those. For instance I once looked at "Recall" macro. I don't recall details, so may be wrong (redundant phrase, for sure), but I believe it winds up calling a lib function for the heavy lifting. I'm glad to see MasmBasic gets a fair amount of attention, deservedly, but for me, I can't rely on something I can't follow right down to the silicon when necessary (or just curious). That's why I write approx. all my own code, no libraries beyond the necessaries. But per your post next time I deal with dialogs I'll check those lines you mention, and borrow as appropriate :biggrin: with attribution of course
I am NaN ;)

Zen

MIKI__,
...As Dave pointed out, the file, dialogs.inc is the best place to start.
There are also several examples available in: ...\masm32\examples\dialogs,...and,......\masm32\examples\dialogs_later,...
Zen

Vortex

Another method is to extract the binary resource data from the compiled resource file ( .res )

    .IF uMsg==WM_INITDIALOG

            invoke  LoadIcon,NULL,IDI_APPLICATION
            invoke  SendMessage,hWnd,WM_SETICON,ICON_SMALL,eax
            lea     eax,[Resource+080h]
            invoke  LoadMenuIndirect,eax
            invoke  SetMenu,hWnd,eax

Mikl__

Vortex, thank you very much!
Hi, Zen!
in what version of masm32 are \masm32\examples\dialogs and \masm32\examples\dialogs_later? May you attach this samples with asm/exe-files?

hutch--

Its in the current version, just download the current version.