March 29, 2024, 01:20:27 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Removing @MAXBOX

Started by Brian, November 28, 2017, 08:39:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

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

Egil

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
Support Amateur Radio  -  Have a ham  for dinner!

fasecero

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 ???

jalih

You could probably handle WM_NCPAINT window message and draw the minbox button yourself...

Andy

November 29, 2017, 01:42:57 AM #4 Last Edit: November 29, 2017, 02:02:50 AM by Andy
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.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

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

LarryMc

@Jalih
I tried using WM_NCPAINT then DrawFrameControl( hdc,wParam,DFC_CAPTION,DFCS_CAPTIONMIN)

but couldn't get it to work for some reason
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

fasecero

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






Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

December 01, 2017, 06:13:23 AM #9 Last Edit: December 01, 2017, 06:15:11 AM by Andy
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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

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

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

jalih

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...

fasecero

December 03, 2017, 01:24:33 PM #14 Last Edit: December 03, 2017, 01:31:19 PM by fasecero
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

LarryMc

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...
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

jalih

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.

jalih

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...

Andy

December 05, 2017, 03:10:46 AM #18 Last Edit: December 05, 2017, 03:28:16 AM by Andy
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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

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

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Andy,
Did you already say why you are putting all this in an "include" file a opposed to making a "lib " file?

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Larry,

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

Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

December 06, 2017, 03:59:09 AM #24 Last Edit: December 06, 2017, 04:02:11 AM by Andy
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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.