Hi all.

These days I began to rewrite from scratch my program SpaceGlyph on FASM. (You can see how it looks on my web site) So, SpaceGlyph was writen on Delphi and the user interface is very rich - icons, pictures etc.
When I try to make this on assembler, I found that there is many problems and I decide to write some system for uniform handling of menus and toolbars. Something like "Actions" in Delphi.

The atachment is the first version of this system. It's too raw and not optimised, but I think it works pretty good on my computer (Cyrix MII 333MHz, Win95 OSR2). Please test it and post some opinions.

Thanks.
Posted on 2003-01-15 18:17:16 by JohnFound
Use CreatePopupMenu for submenus, otherwise you leak resources.
Posted on 2003-01-15 19:47:10 by comrade
Hi comrade.

Hm, I read the help for the CreatePopupMenu and CreateMenu, but there is no any information about resource leaks. In other hand, my idea was to use one subroutine CreateCoolMenu to create main menus and popup menus. If I must use CreatePopupMenu for popupmenus, I must put some flag - menu type or similar and checks.

How you determine these leaks? Maybe there is some utility program?

To all:
I have another problem with this demo too: If you start the demo, you can see some empty space between the flat buttons and the bottom border of the toolbar. Did someone knows, how I can remove this space?
Posted on 2003-01-16 03:43:02 by JohnFound
The comrade is absolutely right. I checked the MyActions demo and found some resource leaks because of using CreateMenu for submenus. Here is the fixed version.

Thanks comrade :alright:

But I still can't fix the problem with the Toolbar empty space under the buttons. If someone helps me with this, I will be very thankful.
Posted on 2003-01-16 05:56:03 by JohnFound
I forget the file:
:)
Posted on 2003-01-16 05:58:37 by JohnFound
What space?
Posted on 2003-01-16 17:50:28 by comrade
Look at the snapshot:

This gap becomes only when the toolbar is flat.
Posted on 2003-01-17 04:02:53 by JohnFound
Hi !
I have the same gap problem with my toolbar, do you have found a solution ?

Thanks !
Posted on 2003-03-16 13:09:32 by JCP
Hi Readiosys.
Unfortunately I didn't found solution for this problem. But the problem is serious (and maybe it must be discused in MAIN thread of the forum, because this is common problem of the flat toolbars.) The gap between the buttons and bottom edge of the toolbat stays very large when the toolbar is wraped on several rows, like this:
Posted on 2003-03-17 07:05:01 by JohnFound
You have to use the CCS_NORESIZE style for your toolbar and size the toolbar yourself, use TB_GETITEMRECT on the last button (this gets you the height the toolbar should be) and then use MoveWindow (or SetWindowPos) to size the toolbar.
Posted on 2003-03-17 09:10:48 by Joshua
What is a resource leak?
Posted on 2003-03-17 09:42:52 by Odyssey
I just had a look at the program. Very impressive I always wanted to know how add bitmaps to menu items like it is done in delphi. I will now attempt to decipher the code.
Posted on 2003-03-17 09:51:44 by Odyssey

You have to use the CCS_NORESIZE style for your toolbar and size the toolbar yourself, use TB_GETITEMRECT on the last button (this gets you the height the toolbar should be) and then use MoveWindow (or SetWindowPos) to size the toolbar.


Sounds nice: I will try when I get home.
Thanks !
Posted on 2003-03-17 10:27:50 by JCP
Odyssey, a leak is when you allocate something and forget to deallocate it. This is always a bad thing, though not always severe - windows will take care of closing file handles, deallocating heap (etc) when your program shuts down, so small leaks will not matter too much (but SHOULD be tracked down and fixed). Resource leaks tend to be pretty severe, since especially crappy old 9x series of windows are very limited. Yep, on 9x resource leaks can end up in BSODs rather easily.
Posted on 2003-03-17 10:34:21 by f0dder
Thank you Joshua!
Now the "big ugly gap" problem :grin: is fixed.
Here is the last version, and it seems to work good. Some minor changes and code cleaning are made too.
Posted on 2003-03-17 12:32:09 by JohnFound
It worked for me too: thank you very much, Joshua !
Posted on 2003-03-17 13:01:30 by JCP
Glad I could be of service

I do have one remark about the ownerdrawn menu's though: Set the MenuText to size 24 (in display properties), and run the app. See what happens... It's never recommended to hardcode these values.
Also I woudn't include a Disabled toolbar bitmap, the windows default way of telling the user something is disabled is by embossing the text or image. This is an effect that can easily be created on the fly for such small bitmaps. Although you would lose the nice shading effect.

Anyways for an example of what i mean: look at this.
Posted on 2003-08-16 00:21:58 by Joshua
Hi JohnFound

For flat Toolbars,have a look in forum Custom Controls->ManosGrid.

Regards,Manos.
Posted on 2003-08-20 07:51:16 by Anonymous