Author Topic: fully programmatic menu creation?  (Read 880 times)

Daniel G

  • Newbie
  • *
  • Thank You
  • -Given: 8
  • -Receive: 0
  • Posts: 8
    • View Profile
fully programmatic menu creation?
« on: September 04, 2019, 03:13:52 pm »
Hello all,

I'm looking into the feasibility of porting some GUI code to OS/2. One of the things needed is to create the menubar and menus completely in code.

From skimming online books, I gather that this is possible, but apparently not as straightforward as calling single API methods like win32's CreateMenu, AppendMenu, SetMenu, etc.

Would anyone happen to have or know of some example code that does this?

Neil Waldhauer

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 31
  • Posts: 460
    • View Profile
    • Blonde Guy
Re: fully programmatic menu creation?
« Reply #1 on: September 04, 2019, 03:47:40 pm »
There is some example code in the Toolkit help under Menus.

Probably you can create the equivalent of the Win32 API out of the Presentation Manager messages, which, by the way, are identical to the messages in Win32.
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

David Graser

  • Hero Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 57
  • Posts: 505
    • View Profile
Re: fully programmatic menu creation?
« Reply #2 on: September 04, 2019, 06:06:21 pm »

Bogdan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 84
    • View Profile
Re: fully programmatic menu creation?
« Reply #3 on: September 04, 2019, 07:34:21 pm »
but apparently not as straightforward as calling single API methods like win32's CreateMenu, AppendMenu, SetMenu, etc.
At least the mentioned functions will behave the same as their Win32 counterparts.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 393
  • -Receive: 79
  • Posts: 2377
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: fully programmatic menu creation?
« Reply #4 on: September 05, 2019, 02:44:47 am »
Welcome to the forum Daniel G.

I don't have the straight answer to it, but we had tried to consolidate the development resources on the EDM/2 wiki: http://www.edm2.com

There are some OS/2 development related books here: http://www.edm2.com/index.php/List_of_OS/2_Software_Development_Related_Books

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 11
  • -Receive: 149
  • Posts: 2117
    • View Profile
Re: fully programmatic menu creation?
« Reply #5 on: September 05, 2019, 04:34:21 am »
OS/2 and Windows are actually closely related and share many functions though often the OS/2 are prefixed, Dos for the low level stuff, Win for windows functions and such. Of course Windows has also evolved a lot compared to OS/2 (which has evolved in a different direction) so while OS/2 only has _beginthread, Windows now also has _beginthreadex for example.

Andi B.

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 21
  • Posts: 434
    • View Profile
Re: fully programmatic menu creation?
« Reply #6 on: September 05, 2019, 01:11:51 pm »
Which compiler suite do you want to use? And from which system/GUI toolkit do you want to port? Old windows code or from latest VS framework?

Daniel G

  • Newbie
  • *
  • Thank You
  • -Given: 8
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: fully programmatic menu creation?
« Reply #7 on: September 05, 2019, 04:25:52 pm »
Quote
There is some example code in the Toolkit help under Menus.
I looked there at your suggestion but it seemed to be the same information I read in the Warp 3 PM Programming Guide - ie, "it's possible to manually construct a menu template in memory" but not going into precise detail about doing that. But again, I have been skimming while working on something else (trying to multitask a bit here), so I haven't yet sat down to read through the docs line by line, much less start poking around in code.

Quote
https://ecsoft2.org/books
Bookmarked, thank you.

Quote
At least the mentioned functions will behave the same as their Win32 counterparts.
Quote
OS/2 and Windows are actually closely related and share many functions
Until your comments I didn't know about Open32 and all that! I guess I can just use my existing Win32 code, or try to, to see how far that gets me before resorting to original OS/2 API calls.

Quote
Welcome to the forum Daniel G.
Thank you, and thank you for your assistance in joining the forum.

Quote
Which compiler suite do you want to use?
I'm probably going to use gcc with QtCreator as my IDE. Sad about no gdb but I usually use printfs for debugging anyway. But if that gives me trouble there's always OpenWatcom or VisualAge.

Quote
And from which system/GUI toolkit do you want to port?
I'm attempting to port my OpenWL library to OS/2, kind of for fun, kind of as a test to see how realistic it will be to support exotic platforms in general. This is part of something potentially larger but I don't want to run my mouth too much :D

Rich Walsh

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 11
  • Posts: 96
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: fully programmatic menu creation?
« Reply #8 on: September 05, 2019, 09:12:56 pm »
I'm looking into the feasibility of porting some GUI code to OS/2. One of the things needed is to create the menubar and menus completely in code.

From skimming online books, I gather that this is possible, but apparently not as straightforward as calling single API methods like win32's CreateMenu, AppendMenu, SetMenu, etc.

Creating menus programmatically is quite easy but it isn't done using API calls that resemble those in Windows because the windowing model is different.

A top-level OS/2 Presentation Manager window does not have a non-client area where the OS draws stuff like menus and titlebars for you. Instead, each of these design elements is a separately created window of the appropriate class whose size and position is coordinated by the top-level "frame window".

Menubars, popup menus, min/max/close buttons, and system menus are all windows of class WC_MENU. Like any other window, they are created using WinCreateWindow() and are manipulated by sending them window messages such as MM_INSERTITEM. The end result is the same as CreateMenu() and AppendMenu() but the methodology is different.

To get a better understanding of PM windowing, I highly recommend PMTree. It provides a graphical display of the OS/2 windowing hierarchy for every top-level window open on the Desktop. You'll quickly discover there's a lot more to OS/2 windows than Windows' windows.

FWIW... on a practical note: in cases where you need to create custom menus, it is often easier to create and load conventional menu template resources, then customize them by adding or removing items, rather than starting from scratch.

Daniel G

  • Newbie
  • *
  • Thank You
  • -Given: 8
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: fully programmatic menu creation?
« Reply #9 on: September 07, 2019, 03:25:55 am »
Creating menus programmatically is quite easy but it isn't done using API calls that resemble those in Windows because the windowing model is different.

Thank you for the detailed response, and the link to the PMTree software - very helpful.

Unfortunately in my case I can't use conventional resource-based menus, because of the cross-platform nature of the library I'm creating. I mean, I could, but the idea is to make code written against the library as portable as possible, and having to make menus with platform-specific tools just adds more complexity to porting code. (And they would still have to be wired in code to the abstract "actions" - defeating the purpose of not doing it 100% programmatically to begin with).

Doug Clark

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 14
  • Posts: 176
    • View Profile
Re: fully programmatic menu creation?
« Reply #10 on: September 08, 2019, 12:23:44 am »
If you are willing to consider using a specific compiler and library one alternative is using the IBM Open Class Library. I am attaching some sample code for dynamically creating menus in code without resources from the book Power GUI Programming with VisualAge C++ .  The book describes the library that came with VisualAge C++ version 3, but version 4 also has similar capabilities.

I don't see any irony in using a GUI library to create a GUI library.  Especially since the Open Class Library never included Mac or Linux.

Daniel G

  • Newbie
  • *
  • Thank You
  • -Given: 8
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: fully programmatic menu creation?
« Reply #11 on: September 09, 2019, 09:29:57 am »
I don't see any irony in using a GUI library to create a GUI library.
I don't have an issue with the approach (for example, I'm relying on gtkmm on linux which is a few layers removed from raw x11) ... but is there another way to obtain the class library other than using VisualAge? I had issues trying to install it (3.0), would never complete installation after the initial reboot.

André Heldoorn

  • Hero Member
  • *****
  • Thank You
  • -Given: 117
  • -Receive: 19
  • Posts: 786
    • View Profile
Re: fully programmatic menu creation?
« Reply #12 on: September 09, 2019, 11:33:56 am »
VisualAge? I had issues trying to install it (3.0), would never complete installation after the initial reboot.

Edit the LIBPATH in CONFIG.SYS before the reboot, to move the DLL directories (plural) of the OS back in front of the outdated DLLs of VAC++. Or edit CONFIG.SYS afterwards if you've forgotten that, by booting to a prompt and becoming friends with e.g. TEDIT to fix the LIBPATH order.
« Last Edit: September 09, 2019, 11:40:44 am by André Heldoorn »

Daniel G

  • Newbie
  • *
  • Thank You
  • -Given: 8
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: fully programmatic menu creation?
« Reply #13 on: September 09, 2019, 09:43:56 pm »
Edit the LIBPATH in CONFIG.SYS before the reboot, ...
Ah, thank you. I will give that a try!



Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 11
  • -Receive: 149
  • Posts: 2117
    • View Profile
Re: fully programmatic menu creation?
« Reply #14 on: September 10, 2019, 12:54:06 am »
I think there are a few other edits needed. Putting the toolkit in front of ibmcpp in the PATH, INCLUDE, LIB and ibmcpp last (after the system and the toolkit) in SOMIR at least.