MyTetra Share
Делитесь знаниями!
disabling the maximize function on a db window
Время создания: 23.06.2018 08:11
Текстовые метки: dark basic window maximize
Раздел: Dark Basic


FORUM HOMESEARCHPROFILEMESSAGES (0)MY THREADSLOGOUT

developer forums Banner image

DarkBASIC Discussion / disabling the maximize function on a db window

Author

Message


TheComet

10 YEARS OF SERVICE

User Offline

Joined: 18th Oct 2007

Location: I`m under ur bridge eating ur goatz.

DBPro Master

Earn Badges

Posted: 15th May 2009 08:17 Link

Hello!


How do I disable the middle button of the three buttons on the top right corner, so the user can not maximize the window, but minimize and exit it?


TheComet


Peachy, and the Chaos of the Gems



Latch

11 YEARS OF SERVICE

User Offline

Joined: 23rd Jul 2006

Location:

Earn Badges

Posted: 15th May 2009 09:49 Link

The following will deactivate the maximize button:



set window on

set window title "Deactivate Maximize Button"


rem variables and constants

user32=1

GWL_STYLE = (-16)

WS_MAXIMIZEBOX = 65536

WS_MINIMIZEBOX = 131072


load dll "user32.dll",user32


rem query window handle

hwnd=call dll(user32,"GetActiveWindow")


rem get the current window style - this has min max info

curstyle=call dll(user32,"GetWindowLongA",hwnd,GWL_STYLE)


rem this is just a test to see if MAXIMIZEBOX is included in the current style

print curstyle & WS_MAXIMIZEBOX


rem should be able to adjust the style by subtracting the max button from the

rem current style

newstyle=curstyle-WS_MAXIMIZEBOX


rem write the new style to the window

result=call dll(user32,"SetWindowLongA",hwnd,GWL_STYLE,newstyle)

print result


rem get the current window style - this has min max info

curstyle=call dll(user32,"GetWindowLongA",hwnd,GWL_STYLE)


rem this is just a test to see if MAXIMIZEBOX is included in the current style

print curstyle & WS_MAXIMIZEBOX

+ Code Snippet


set window on

set window title "Deactivate Maximize Button"

rem variables and constants

user32=1

GWL_STYLE = (-16)

WS_MAXIMIZEBOX = 65536

WS_MINIMIZEBOX = 131072

load dll "user32.dll",user32

rem query window handle

hwnd=call dll(user32,"GetActiveWindow")

rem get the current window style - this has min max info

curstyle=call dll(user32,"GetWindowLongA",hwnd,GWL_STYLE)

rem this is just a test to see if MAXIMIZEBOX is included in the current style

print curstyle & WS_MAXIMIZEBOX

rem should be able to adjust the style by subtracting the max button from the

rem current style

newstyle=curstyle-WS_MAXIMIZEBOX

rem write the new style to the window

result=call dll(user32,"SetWindowLongA",hwnd,GWL_STYLE,newstyle)

print result

rem get the current window style - this has min max info

curstyle=call dll(user32,"GetWindowLongA",hwnd,GWL_STYLE)

rem this is just a test to see if MAXIMIZEBOX is included in the current style

print curstyle & WS_MAXIMIZEBOX



Enjoy your day.

t10dimensional

9 YEARS OF SERVICE

User Offline

Joined: 22nd Mar 2009

Location: Code Cave, USA

Earn Badges

Posted: 16th May 2009 03:55 Edited at: 16th May 2009 03:57 Link

WHen i tryed that code my computer said

Quote: "

Program Error


DB.exe has generated errors and will be closed by Windows. You

will need to restart the program.



An error log is being created

...........................|----------------|

...........................|......(OK).......|

...........................|----------------|

"



Whats wrong with my computer?


If at first you don't succeed-Pause-Go to last checkpoint

Libervurto

11 YEARS OF SERVICE

User Offline

Joined: 30th Jun 2006

Location: On Toast

Earn Badges

Posted: 16th May 2009 04:28 Link

Isn't there a SET WINDOW thing that lets you hide the buttons?


Riddle: The more you take, the more you leave behind. What are they? Answer

Caleb1994

9 YEARS OF SERVICE

User Offline

Joined: 10th Oct 2008

Location: The Internet you idiot!

Earn Badges

Posted: 16th May 2009 04:30 Edited at: 16th May 2009 04:32 Link

Thats a error in the WinAPI Commands not your computer.




Edit:



Wait nevermind just ran it thats something with your computer.



Hey latch. how do you make it so the button is grayed? cuz right now it just doesn't work.


New Site! Check it out \/

spt games

9 YEARS OF SERVICE

User Offline

Joined: 14th Apr 2009

Location: United Kingdom

Earn Badges

Posted: 16th May 2009 04:53 Link

Are you running the Lite version of DB? DB Lite is not compatible with the enhancement pack (See DB Lite info).


This might mean that DLLs cannot be loaded and as a result cause a fatal error. Can anyone confirm this to be true?

Latch

11 YEARS OF SERVICE

User Offline

Joined: 23rd Jul 2006

Location:

Earn Badges

Posted: 16th May 2009 05:16 Link

Quote: "Isn't there a SET WINDOW thing that lets you hide the buttons?"


It's an all or nothing command in DBC - set window layout - you can't pick and choose individual buttons.


Quote: "Hey latch. how do you make it so the button is grayed? cuz right now it just doesn't work."



Did you try clicking on the maximize button? It will not let you maximize the screen and then grey out. In order to see the button become grey the window has to be refreshed with the new settings in place.


So, add this command to the end:


RESTORE WINDOW


and the max button will appear grey.



set window on

set window title "Deactivate Maximize Button"


rem variables and constants

user32=1

GWL_STYLE = (-16)

WS_MAXIMIZEBOX = 65536

WS_MINIMIZEBOX = 131072


load dll "user32.dll",user32


rem query window handle

hwnd=call dll(user32,"GetActiveWindow")


rem get the current window style - this has min max info

curstyle=call dll(user32,"GetWindowLongA",hwnd,GWL_STYLE)


rem this is just a test to see if MAXIMIZEBOX is included in the current style

print curstyle & WS_MAXIMIZEBOX


rem should be able to adjust the style by subtracting the max button from the

rem current style

newstyle=curstyle-WS_MAXIMIZEBOX


rem write the new style to the window

result=call dll(user32,"SetWindowLongA",hwnd,GWL_STYLE,newstyle)

print result


rem get the current window style - this has min max info

curstyle=call dll(user32,"GetWindowLongA",hwnd,GWL_STYLE)


rem this is just a test to see if MAXIMIZEBOX is included in the current style

print curstyle & WS_MAXIMIZEBOX


restore window

+ Code Snippet


set window on

set window title "Deactivate Maximize Button"

rem variables and constants

user32=1

GWL_STYLE = (-16)

WS_MAXIMIZEBOX = 65536

WS_MINIMIZEBOX = 131072

load dll "user32.dll",user32

rem query window handle

hwnd=call dll(user32,"GetActiveWindow")

rem get the current window style - this has min max info

curstyle=call dll(user32,"GetWindowLongA",hwnd,GWL_STYLE)

rem this is just a test to see if MAXIMIZEBOX is included in the current style

print curstyle & WS_MAXIMIZEBOX

rem should be able to adjust the style by subtracting the max button from the

rem current style

newstyle=curstyle-WS_MAXIMIZEBOX

rem write the new style to the window

result=call dll(user32,"SetWindowLongA",hwnd,GWL_STYLE,newstyle)

print result

rem get the current window style - this has min max info

curstyle=call dll(user32,"GetWindowLongA",hwnd,GWL_STYLE)

rem this is just a test to see if MAXIMIZEBOX is included in the current style

print curstyle & WS_MAXIMIZEBOX

restore window





Enjoy your day.

t10dimensional

9 YEARS OF SERVICE

User Offline

Joined: 22nd Mar 2009

Location: Code Cave, USA

Earn Badges

Posted: 16th May 2009 05:21 Edited at: 16th May 2009 05:45 Link

IT JUST MADE ME LOSE ALL MY CODE


Alright got my code back


I think it's just my suckey computer it has a old grafics card that


can only do set display mode 640,480,16 and usally thats it.


If at first you don't succeed-Pause-Go to last checkpoint

Latch

11 YEARS OF SERVICE

User Offline

Joined: 23rd Jul 2006

Location:

Earn Badges

Posted: 16th May 2009 05:41 Edited at: 16th May 2009 05:44 Link

That's very strange. Anyone else having that problem?


What version of DB are you using, and what version of windows? And are you using DarkEdit or the default black screen editor? I noticed my code vanishes when I use the db editor, but if I move thslider on the side, it all reappears.


Try typing this at the top of a new DB program as the only command


SET WINDOW ON


and press F5


It should open the CLI in windowed mode.


Now type one line at a time from the above program pressing ENTER after each line in the CLI.


You'll know which line is causing the problem after you type it and press enter. Make sure you've saved anything you want to keep in case the bad behaviour returns.


Enjoy your day.

t10dimensional

9 YEARS OF SERVICE

User Offline

Joined: 22nd Mar 2009

Location: Code Cave, USA

Earn Badges

Posted: 16th May 2009 05:48 Edited at: 16th May 2009 05:52 Link

SET WINDOW ON


It could not do it.I can only do


SET DISPLAY MODE 640,480,16


is that why


version 1.12


windows 2000 i think


If at first you don't succeed-Pause-Go to last checkpoint

Latch

11 YEARS OF SERVICE

User Offline

Joined: 23rd Jul 2006

Location:

Earn Badges

Posted: 16th May 2009 05:54 Link

Do you have a trial version of DB or something? The SET WINDOW ON command shouldn't cause trouble.


And using SET DISPLAY MODE, you should be able to set any display that your graphics card and monitor can handle.


Enjoy your day.

t10dimensional

9 YEARS OF SERVICE

User Offline

Joined: 22nd Mar 2009

Location: Code Cave, USA

Earn Badges

Posted: 16th May 2009 06:12 Edited at: 16th May 2009 06:16 Link

I guess I have a terrible graphics card because i can't do 32bits


or almost any other displaye modes.I think I could get a better


graphic card from school they have a bunch of computers they are


thinking of just trashing.


no, I have the full version of db v1.12


If at first you don't succeed-Pause-Go to last checkpoint

Latch

11 YEARS OF SERVICE

User Offline

Joined: 23rd Jul 2006

Location:

Earn Badges

Posted: 16th May 2009 06:26 Link

I see. Here, try this screen display mode selector that was written by TDK_Man a few years ago . Though we're getting off topic a bit, you should be able to see all the available scree n modes and be able to click and select one:



Rem ***** Display Mode Selector Function Demo *****

Rem ***** By TDK_Man December 2006 *****


`Set Display Mode 800,600,16: Rem <<< Set whatever mode you want here

DisplayMode$=SelectScreenMode(): Rem <<< This calls the function. On return the new mode is already set

Center Text Screen Width()/2,Screen Height()/2, "Now In Screen Mode "+DisplayMode$: Rem <<< Selected screen mode returned in string (Eg 800x600x32)


Wait Key

End


Function SelectScreenMode()

Set Text Font "Arial",1: Set Text Size 14

Perform Checklist For Display Modes

ListNum = Checklist Quantity()

TRows = ListNum/4: TColumns = 4: THeight = Text Height("X")

BoxHeight = THeight*TRows+40: BoxWidth = TColumns*90

X=(Screen Width() - BoxWidth)/2: Y=(Screen Height() - BoxHeight)/2

Ink RGB(255,255,255),0: Box X,Y,X+BoxWidth,Y+BoxHeight

Ink RGB(180,180,180),0: Box X+1,Y+1,X+BoxWidth,Y+BoxHeight

Ink RGB(220,220,220),0: Box X+1,Y+1,X+BoxWidth-1,Y+BoxHeight-1

Ink RGB(255,255,255),0: Center Text Screen Width() / 2,Y+5,"Please Select The Required Screen Mode:"

Ink 0,0: Center Text Screen Width() / 2-1,Y+4,"Please Select The Required Screen Mode:"

TextLPos = X+10: TextTPos = Y+30: RowCount=0: Ink 0,0

For N=1 To ListNum

Text TextLPos,TextTPos,CHECKLIST STRING$(N)

Inc TextTPos,THeight: Inc RowCount

If RowCount = TRows

RowCount=0: TextTPos = Y+30

Inc TextLPos,90

Endif

Next N

Get Image 10000,X,Y,X+BoxWidth,Y+BoxHeight

Ink RGB(120,120,220),0: Set Text Transparent

Repeat

Mx=MouseX(): My=MouseY(): Mc=MouseClick()

If Mx>(X+10) and Mx<(X+BoxWidth-10) and My>(Y+10) and My<(Y+BoxHeight-10)

OverColumn = (Mx-(X+10))/90: OverRow = (My-(Y+30))/THeight

ItemNum = OverColumn*10+OverRow+1

If OldItemNum <> ItemNum

Paste Image 10000,X,Y

Text OverColumn*90+X+10,OverRow*THeight+30+Y,CHECKLIST STRING$(ItemNum)

OldItemNum = ItemNum

Endif

Endif

Until Mc=1

Mode$ = CHECKLIST STRING$(ItemNum)

Delete Image 10000

BitDepth = VAL(Right$(Mode$,2))

NewMode$=Left$(Mode$,Len(Mode$)-3)

For N=1 To Len(Mode$)

If Mid$(NewMode$,N)="x"

XRez = VAL(Left$(NewMode$,N-1))

YRez = VAL(Right$(NewMode$,Len(NewMode$)-N))

Exit

Endif

Next N

Set Display Mode XRez, YRez, BitDepth

Ink RGB(255,255,255),0

EndFunction Mode$

+ Code Snippet


Rem ***** Display Mode Selector Function Demo *****

Rem ***** By TDK_Man December 2006 *****

`Set Display Mode 800,600,16: Rem <<< Set whatever mode you want here

DisplayMode$=SelectScreenMode(): Rem <<< This calls the function. On return the new mode is already set

Center Text Screen Width()/2,Screen Height()/2, "Now In Screen Mode "+DisplayMode$: Rem <<< Selected screen mode returned in string (Eg 800x600x32)

Wait Key

End

Function SelectScreenMode()

Set Text Font "Arial",1: Set Text Size 14

Perform Checklist For Display Modes

ListNum = Checklist Quantity()

TRows = ListNum/4: TColumns = 4: THeight = Text Height("X")

BoxHeight = THeight*TRows+40: BoxWidth = TColumns*90

X=(Screen Width() - BoxWidth)/2: Y=(Screen Height() - BoxHeight)/2

Ink RGB(255,255,255),0: Box X,Y,X+BoxWidth,Y+BoxHeight

Ink RGB(180,180,180),0: Box X+1,Y+1,X+BoxWidth,Y+BoxHeight

Ink RGB(220,220,220),0: Box X+1,Y+1,X+BoxWidth-1,Y+BoxHeight-1

Ink RGB(255,255,255),0: Center Text Screen Width() / 2,Y+5,"Please Select The Required Screen Mode:"

Ink 0,0: Center Text Screen Width() / 2-1,Y+4,"Please Select The Required Screen Mode:"

TextLPos = X+10: TextTPos = Y+30: RowCount=0: Ink 0,0

For N=1 To ListNum

Text TextLPos,TextTPos,CHECKLIST STRING$(N)

Inc TextTPos,THeight: Inc RowCount

If RowCount = TRows

RowCount=0: TextTPos = Y+30

Inc TextLPos,90

Endif

Next N

Get Image 10000,X,Y,X+BoxWidth,Y+BoxHeight

Ink RGB(120,120,220),0: Set Text Transparent

Repeat

Mx=MouseX(): My=MouseY(): Mc=MouseClick()

If Mx>(X+10) and Mx<(X+BoxWidth-10) and My>(Y+10) and My<(Y+BoxHeight-10)

OverColumn = (Mx-(X+10))/90: OverRow = (My-(Y+30))/THeight

ItemNum = OverColumn*10+OverRow+1

If OldItemNum <> ItemNum

Paste Image 10000,X,Y

Text OverColumn*90+X+10,OverRow*THeight+30+Y,CHECKLIST STRING$(ItemNum)

OldItemNum = ItemNum

Endif

Endif

Until Mc=1

Mode$ = CHECKLIST STRING$(ItemNum)

Delete Image 10000

BitDepth = VAL(Right$(Mode$,2))

NewMode$=Left$(Mode$,Len(Mode$)-3)

For N=1 To Len(Mode$)

If Mid$(NewMode$,N)="x"

XRez = VAL(Left$(NewMode$,N-1))

YRez = VAL(Right$(NewMode$,Len(NewMode$)-N))

Exit

Endif

Next N

Set Display Mode XRez, YRez, BitDepth

Ink RGB(255,255,255),0

EndFunction Mode$



Enjoy your day.

Caleb1994

9 YEARS OF SERVICE

User Offline

Joined: 10th Oct 2008

Location: The Internet you idiot!

Earn Badges

Posted: 16th May 2009 06:32 Link

WOW! is that windows 98 latch!?



and i forgot about repainting the window lol whoops.


althought the Restore and Minimize window commands never work correctly for me. if i have to do that i use ShowWindow function from winAPI that works nicely


New Site! Check it out \/

TheComet

10 YEARS OF SERVICE

User Offline

Joined: 18th Oct 2007

Location: I`m under ur bridge eating ur goatz.

DBPro Master

Earn Badges

Posted: 16th May 2009 06:35 Link

It worked perfectly for me, thanks Latch!


And while we are at windows, how can I make it that if the window is minimized or behind other windows that it doesn't take up 100% CPU usage?


TheComet


Peachy, and the Chaos of the Gems



Latch

11 YEARS OF SERVICE

User Offline

Joined: 23rd Jul 2006

Location:

Earn Badges

Posted: 16th May 2009 06:43 Link

@TheComet


100% CPU usage


Quote: "WOW! is that windows 98 latch!?"


The ideal environment for DarkBASIC Classic! If you have an old machine around, try it out. You'll be amazed at the performance of DB without having to implement any work arounds.


Enjoy your day.

t10dimensional

9 YEARS OF SERVICE

User Offline

Joined: 22nd Mar 2009

Location: Code Cave, USA

Earn Badges

Posted: 16th May 2009 06:50 Link

it only works on the ones with 16 on the end and i can only do about half of them


If at first you don't succeed-Pause-Go to last checkpoint

TheComet

10 YEARS OF SERVICE

User Offline

Joined: 18th Oct 2007

Location: I`m under ur bridge eating ur goatz.

DBPro Master

Earn Badges

Posted: 16th May 2009 07:03 Link

@Latch


Wow! I got it down to 12% CPU usage!


Thanks a lot again!!


TheComet


Peachy, and the Chaos of the Gems



Caleb1994

9 YEARS OF SERVICE

User Offline

Joined: 10th Oct 2008

Location: The Internet you idiot!

Earn Badges

Posted: 16th May 2009 07:16 Link

That makes sense i geuss sense it was made for 98 right? I think we still have a 98 disk laying around. but no extra computer haha


New Site! Check it out \/

Caleb1994

9 YEARS OF SERVICE

User Offline

Joined: 10th Oct 2008

Location: The Internet you idiot!

Earn Badges

Posted: 16th May 2009 07:53 Edited at: 16th May 2009 07:55 Link

OMG! i just tried the System Sleep thing (Hadn't tried yet) i got 1-5 cpu usage and at most a 35 percent spike! dang! thats amzing!



Wow never noticed in the task manager it said how many handles there were.... dange 13643 hahaha erey thing is made oup of those so it's understandable lol



I'm going to watch the number as i close firefox lol


New Site! Check it out \/

Latch

11 YEARS OF SERVICE

User Offline

Joined: 23rd Jul 2006

Location:

Earn Badges

Posted: 16th May 2009 08:21 Link

For the 100% CPU cap, I think Benjamin came up with the kernel sleeping method and Robert The Robot tested out different scenarios and put together a nice complete solution for DBC use.


Enjoy your day.

Caleb1994

9 YEARS OF SERVICE

User Offline

Joined: 10th Oct 2008

Location: The Internet you idiot!

Earn Badges

Posted: 16th May 2009 11:24 Link

Sweet


All the original questions are answered on this post right? cuz we are off topic i think.


New Site! Check it out \/

This thread has not been posted in for more than 90 days and has been locked!


Server time is: 2018-06-23 04:07:45

Your offset time is: 2018-06-23 15:07:45

© Copyright 2018

Acceptable Usage Policy

 
MyTetra Share v.0.53
Яндекс индекс цитирования