B+ window has a Minimize gadget

BlitzPlus Forums/BlitzPlus Programming/B+ window has a Minimize gadget

Sphinx(Posted 2004) [#1]
Hi all

Here is the code I wanted to share with you which will show the minimize and close gadgets for the blitz+ window. Also you can download the source and lib file here :

http://www.ancientsoft.com/downloads/MyWindowed.zip

Const GWL_STYLE = -16		; Retrieve the window styles of the window
Const WS_SYSMENU = 13107200 	; &H80000 = The window has a system menu on its title bar
Const WS_MINIMIZEBOX = 131072	; &H20000 = The window has a minimize button (The WS_SYSMENU window style must also be specified)


Graphics 640,480,16,2

	hWND=FindWindow("","blitzcc") 				;Get the handle of the BlitzCC window (You should change that to the AppTitle you specified if you did)
	WLong = GetWindowLong(hWND, GWL_STYLE) 			;Now get the attribute/style of this window
	WLong = WLong Or WS_SYSMENU Or WS_MINIMIZEBOX		;(Or-ing to add attribute/style if it is not applied)
	SetWindowLong (hWND, GWL_STYLE, WLong)			;Change the attribute/style of the BlitzCC window to show the minimize button
	SetWindowText (hWnd,"My B+ window can be minimized :)") ;Now change the title to whatever you like
	ShowWindow(hWND,0) : ShowWindow(hWND,1) 		;make sure the changes will take effect

While Not KeyHit(1)
Wend


You must put a text file called Minimize.decls in the userlibs folder of BlitzPlus
and type the following in it :

.lib "user32.dll" 
GetWindowLong% (hwnd%, nIndex%) : "GetWindowLongA"
SetWindowLong% (hwnd%, nIndex%, dwNewLong%) : "SetWindowLongA"
FindWindow% (NullString, WindowText$) : "FindWindowA"
SetWindowText% (hwnd%, lpString$) : "SetWindowTextA"
SetWindowPos% (hwnd%, hWndInsertAfter%, x% ,y% , cx%, cy%, wFlags% ) : "SetWindowPos" 
ShowWindow% (hwnd%, nCmdShow%): "ShowWindow"



Grisu(Posted 2004) [#2]
Have u also found out a technique adding and checking a "maximise" button in windowed mode?
I'm searching for a way that when a such a button is clicked, my program will switch to fullscreen mode.


Sphinx(Posted 2004) [#3]
I Will see what I can do :)


pantsonhead.com(Posted 2004) [#4]
Hope you didn't work too long on this Sphinx

It's been in the Code archives for a while

http://www.blitzbasic.com/codearcs/codearcs.php?code=897


Sphinx(Posted 2004) [#5]
Well, mine is different and I think is better as it works directly on the Blitzcc window

You do not need to add a window gadget and make the code necessary for flipping in full screen mode and the one necessary for Canvas .... if you know what I mean!!


matt!(Posted 2004) [#6]
I've got the minimize button to work, but I'm having no joy with the close button. I am creating my window with the Graphics command.


Eikon(Posted 2004) [#7]
@Matt: If all else fails you can try mine:
http://www.blitzbasic.com/Community/posts.php?topic=33724

If it works for you I might be able to move it all to userlib and axe the DLL. Let me know.

*edit*

@Matt: Better idea ;)


matt!(Posted 2004) [#8]
I swapped to CreateWindow rather than Graphics and it all slotted into place. Thanks!