IonicWind Software

IWBasic => General Questions => Topic started by: Brian on November 28, 2017, 08:39:22 AM

Title: Removing @MAXBOX
Post by: Brian on November 28, 2017, 08:39:22 AM
Hello,

I am sure I have seen this somewhere, but how do you remove the @MAXBOX icon from the titlebar? It's not enough just to remove the constant from the OPENWINDOW command, as that just greys it out

Brian
Title: Re: Removing @MAXBOX
Post by: Egil on November 28, 2017, 10:38:49 AM
There was a discussion on using MODIFYSTYLE many years ago, but using that command for @maxbox just greys it out.
So I just used the style @TOOLWINDOW instead as I neither needed @maxbox nor @minbox at the time.
Maybe you can use the same method.


Egil
Title: Re: Removing @MAXBOX
Post by: fasecero on November 28, 2017, 06:58:49 PM
Hello  :),

After some research and some tests, I think it's not possible. If you omit both @MAXBOX and @MINBOX flags, the window will have only the close button. If you ommit just @MAXBOX, Windows draw the maximize box disabled to keep the graphics layout consistent for all windows. It seems that there's no way around this, maybe someone else will find a solution ???
Title: Re: Removing @MAXBOX
Post by: jalih on November 28, 2017, 11:48:52 PM
You could probably handle WM_NCPAINT window message and draw the minbox button yourself...
Title: Re: Removing @MAXBOX
Post by: Andy on November 29, 2017, 01:42:57 AM
Brian,

I made an example for you this morning, it just has the two boxes I think you want (min and close).

The min and close boxes work of course, the caption is just a static, so you can change the text / colour any time you want to.

The window border is just a rectangle, again you can change the colour should you wish.

Yes, I'm sure someone will come up with an alternative, but this one is up and running for you.

You could add the pictures into a resource if you wanted - let me know if this helps please.

Andy.
:)
Title: Re: Removing @MAXBOX
Post by: Brian on November 29, 2017, 03:24:13 AM
Thanks all for looking at this. I have just tried Andy's solution (thanks, Andy) and, while it works well, after putting in a File menu, I couldn't see it because of the rectangle drawn on the window. Going out today, so will look later on

Was out last night in Manchester at a Divine Comedy concert - they were absolutely superb. Got in just after midnight

Brian
Title: Re: Removing @MAXBOX
Post by: LarryMc on November 29, 2017, 12:11:06 PM
@Jalih
I tried using WM_NCPAINT then DrawFrameControl( hdc,wParam,DFC_CAPTION,DFCS_CAPTIONMIN)

but couldn't get it to work for some reason
Title: Re: Removing @MAXBOX
Post by: fasecero on November 29, 2017, 03:11:51 PM
Hey Larry, this can serve as a starting point



$INCLUDE "windowssdk.inc"
$include "commctrl.inc"

INT SUBCLASS_ID = 12345

WINDOW w1
OPENWINDOW w1,0,0,244,250,@CAPTION | @SIZE | @MINBOX| @MAXBOX,0,"",&mainhandler
SetWindowSubclass(w1.hwnd, &MySubclassProc, SUBCLASS_ID, 0)
CENTERWINDOW w1
WAITUNTIL ISWINDOWCLOSED(w1)

SUB mainhandler(), INT
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
RemoveWindowSubclass(w1.hwnd, &MySubclassProc, SUBCLASS_ID)
CLOSEWINDOW w1
ENDSELECT
RETURN 0
ENDSUB

SUB MySubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
SELECT (uMsg)
case WM_NCPAINT
HDC hdc
WINRECT rc
HBRUSH b
HPEN pe
hdc=GetDCEx(hwnd,wParam,DCX_WINDOW|DCX_CACHE|DCX_INTERSECTRGN|DCX_LOCKWINDOWUPDATE)
GetWindowRect(hwnd,&rc)
b=CreateSolidBrush(RGB(0,180,180))
SelectObject(hdc,B)
pe=CreatePen(PS_SOLID, 1, RGB(90, 90, 90))
SelectObject(hdc,pe)
Rectangle(hdc,0,0,(rc.right-rc.left),(rc.bottom-rc.top))
DeleteObject(pe)
DeleteObject(B)
ReleaseDC(hwnd,hdc)
RedrawWindow(hwnd,&rc,wParam,RDW_UPDATENOW)
return 0
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB





Title: Re: Removing @MAXBOX
Post by: Andy on November 30, 2017, 02:16:07 AM
Brian,

Working on the menu items for you and having some success, but I don't think I'll have it done for today.

Andy.
Title: Re: Removing @MAXBOX
Post by: Andy on December 01, 2017, 06:13:23 AM
Brian,

Here's an update for you....

I have managed to make what looks like menu headings and items - I've done it with (at the moment) static controls - it's a very interesting problem you've posed for me.

No doubt someone else will come up with something else.

Anyway, this is a half way house (not finished yet) but you'll see what I'm getting at I'm sure, trying to do this in such a way that you could use it in any program.

Have a play around - as said before - not finished yet - but interesting!!!

Andy.
Title: Re: Removing @MAXBOX
Post by: Andy on December 02, 2017, 02:31:13 AM
With this update, you can now move the mouse from one menu title to another after clicking any one menu title, the program will now display the new menu titles you are over.

It also now adjusts the length of each group of menu items to fit the largest of the group.

Still not finished yet, but getting there - slowly.

Andy.
Title: Re: Removing @MAXBOX
Post by: Brian on December 02, 2017, 06:45:42 AM
Andy,

Will be taking a look later. I was looking up the font name for Windows titlebars, and in Windows 10 the default font is Segoe UI with a size of 9 (they changed it from 10, for some reason). I have kept it at 10 - 9 is far too small

Brian
Title: Re: Removing @MAXBOX
Post by: Andy on December 03, 2017, 05:45:32 AM
Brian,

Thanks for info about the font for the menus, have amended it.

This update allows you to add an icon for any menu item, again, not finished yet, did this this morning.

By the way, does anyone know the default colour for a menu item (grey) and the colour for when the mouse is over it (blue)?

Andy.
Title: Re: Removing @MAXBOX
Post by: jalih on December 03, 2017, 10:37:18 AM
Quote from: Andy on December 03, 2017, 05:45:32 AM
By the way, does anyone know the default colour for a menu item (grey) and the colour for when the mouse is over it (blue)?

Google: GetSysColor and GetSysColorBrush


I am currently trying to use DWM for custom window drawing but having some problems. I try to use current theme but keep getting XP style buttons. There is still some more work to do...
Title: Re: Removing @MAXBOX
Post by: fasecero on December 03, 2017, 01:24:33 PM
Jalih,

That's good news, no doubt it would be great to customize the window frame. I was always tempted to make a window of my own, like you guys are trying, but always dismiss the idea because it seemed (and still seems to me) a very hard thing to do. I'm sure you wont need it, but just in case there is an old article explaining everything that is needed to do it

https://www.codeproject.com/Articles/20497/Draw-Skin-Window-Using-Pure-Win-API
Title: Re: Removing @MAXBOX
Post by: LarryMc on December 03, 2017, 01:49:30 PM
Quote from: jalih on December 03, 2017, 10:37:18 AM
.... but having some problems. I try to use current theme but keep getting XP style buttons. There is still some more work to do...

And I'm sure you have your MANIFEST file in place...
Title: Re: Removing @MAXBOX
Post by: jalih on December 03, 2017, 11:48:17 PM
Quote from: fasecero on December 03, 2017, 01:24:33 PM
I'm sure you wont need it, but just in case there is an old article explaining everything that is needed to do it

https://www.codeproject.com/Articles/20497/Draw-Skin-Window-Using-Pure-Win-API

Thanks for the link, article seems to describe an old way for drawing custom window frame. I am extending window frame into client area. This removes the need to handle WM_NCPAINT, all the painting can be done in WM_PAINT. Now program must also draw titlebar caption title and icon, these are not done automatically.
Title: Re: Removing @MAXBOX
Post by: jalih on December 03, 2017, 11:51:56 PM
Quote from: LarryMc on December 03, 2017, 01:49:30 PM

And I'm sure you have your MANIFEST file in place...

You are right, it may be an issue with my manifest file. I have to investigate this...
Title: Re: Removing @MAXBOX
Post by: Andy on December 05, 2017, 03:10:46 AM
I've now included the following:

1. Separators for the menu items.
2. Menu titles are highlighted when the mouse is over them.
3. Clicking away from the menu items (when displayed) makes them hidden.
4. Amended the code to extend the menu item starting position / length in case the item does not have an icon associated with it, this means the full line is highlighted when the mouse is over it.

To do:

Menu popup items, and enable / disable menu items.  The last two should be easy as they are only normal static controls.

When I've done the above, most of the menu functions will be there for any one to use, maybe I'll put it in an include file to keep a program written to something simple and easy to understand when using these commands.

Andy.
Title: Re: Removing @MAXBOX
Post by: Brian on December 05, 2017, 03:35:42 AM
Andy,

You are doing great. Unfortunately, Christmas seems to be getting in the way of things at the moment! Going out now, will test your latest some time today

Brian
Title: Re: Removing @MAXBOX
Post by: Andy on December 05, 2017, 05:21:49 AM
Thanks Brian,

No problem about the busy time for you, it's Christmas time (nearly), I have time to work on this it's interesting.

I am getting there with this (bit by bit).

Andy.
Title: Re: Removing @MAXBOX
Post by: LarryMc on December 05, 2017, 12:35:16 PM
Andy,
Did you already say why you are putting all this in an "include" file a opposed to making a "lib " file?

LarryMc
Title: Re: Removing @MAXBOX
Post by: Andy on December 05, 2017, 10:25:38 PM
Larry,

Can't remember if I already mentioned it, just wondering which way to go on it.

Andy.

Title: Re: Removing @MAXBOX
Post by: LarryMc on December 05, 2017, 11:55:12 PM
As fast as machines are nowadays I don't guess it really matters.
Say someone is writing a 100 line program using the minimum number calls to functions in your inc files

1)When it is in an "include file"
   a) the compiler has to compile all the lines in your include file
   b) the compiler compiles the 100 line program
   c) the linker links into the exe only your functions that are actually called plus any constants declared in your include file

2)When it is in a "lib file"
   you still supply include file but only has function and constant DECLARATIONs
   you supply precompiled lib file of all functions instead of user having to do it every time.
   a) compiler has to compile your very small include file
   b) the compiler compiles the 100 line program
   c) the linker links into the exe only your functions that are actually called from the lib plus any constants declared in your include file

Advantage of 2 over 1
#1 reason in old days was speed
now would be to protect your code
to keep different versions from floating around soas to aid in troubleshooting (everyone on same page)

That's my story and I'm sticking to it.
And it I ever do another offering(if I ever get another idea in this ole head), you can bet your last dollar or pound or what ever it will be in the form of a lib. LOL

LarryMc

Title: Re: Removing @MAXBOX
Post by: Andy on December 06, 2017, 03:59:09 AM
Larry,

Think that's good advice, will look into it.

I've now managed (well at least one pop up menu), my next task is to be able to make multiple pop ups.

When you move over the EPopup > menu item, the popup items appear.

When you move off the EPopup > menu item the popup items are hidden as you would expect them to do.

Attached is the best screen shot I can do at the moment.

Andy.
Title: Re: Removing @MAXBOX
Post by: Andy on December 08, 2017, 04:30:12 AM
Attached is the latest update... version 1 of the custom window lib / include files.

I've put a lot of the code into a lib file, which makes our own programs smaller and easier to understand.

You now have multiple popup menus for each menu title, including separators, and icons made easy.

I haven't got as far as separators / icons for pop up items yet, and no you can't have a pop up within a pop up yet.

Think this is looking good now so far.

As always, copy the lib file to your IWBDev \ libs folder, and the inc file to your IWBDev \ Include folder.

Andy.
Title: Re: Removing @MAXBOX
Post by: Brian on December 23, 2017, 05:05:20 AM
Hi,

Just had a quick mess with the window code. I thought maybe I could restrict the window's size by measuring the caption text, and then not allowing the window to be smaller than the length of the text. This works somewhat, but I can't figure out how to stop the window being wider than its initial width

Seems like text widths are different than window pixel widths

Brian
Title: Re: Removing @MAXBOX
Post by: Andy on December 23, 2017, 05:35:46 AM
Brian,

I also have code to do that too!

Will Get back to you today.

Andy.
Title: Re: Removing @MAXBOX
Post by: Andy on December 23, 2017, 06:07:29 AM
Brian,

I have added two optional values into the WindowMinSize routine, so you can set a maximum X and Y size for the window.

Here I've just set it to it's original size of 600 x 400.


case WM_GETMINMAXINFO '<-- Must include this section.
                        WindowMinSize(420,300,600,400) '<-- Min X / Min Y size of the window - here 420 across, 300 down.
                                              '<-- Last two parameters, original X / Y window size.



Hope this helps! - see attachment - don't forget to move those inc / libs files to C:\IWBDev folders.

Andy.
Title: Re: Removing @MAXBOX
Post by: Brian on December 23, 2017, 06:52:12 AM
Excellent - good stuff. Works better than my efforts

Brian
Title: Re: Removing @MAXBOX
Post by: Andy on December 23, 2017, 07:00:06 AM
No problem Brian,

A little Christmas present from me!

Andy.
:)