Don't ask me again

BlitzMax Forums/BlitzMax GUI Programming/Don't ask me again

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You can get rid of the system menu (the close button is part of this so if you want a close button you'll need a way to add your own custom button)

Note the calls to SetWindowLong() - to modify the window style - and SetWindowPos() to force the changes to update the window

SuperStrict

Extern "win32"
	Function MessageBeep:Byte(nType:Int)
	Function SetWindowLong:Int(hwnd:Int,index:Int,value:Int)="SetWindowLongA@12"
	Function GetWindowLong:Int(hWnd:Int, index:Int)="GetWindowLongA@8"
EndExtern

Notify "Real MessageBox"
MessageBoxPlus("My MessageBox")



Function MessageBoxPlus:Int(message$)
	Local w:Int=168
	Local h:Int=126
	
	messagebeep $40
		
	Local bw:Int=75
	Local bh:Int=23
	Local bi:Int=11
		
	Local win:TGadget=CreateWindow(AppTitle$,(Desktop().ClientWidth()-w)/2,(Desktop().ClientHeight()-h)/2,w,h,Null,WINDOW_TITLEBAR)

	' Modify the window's style
	Local hWnd:Int = QueryGadget(win, QUERY_HWND )
	Local style:Int = GetWindowLong(hWnd, GWL_STYLE ) & (~WS_SYSMENU)
	SetWindowLong( hWnd, GWL_STYLE, style  )
	' Must call SetWindowPos to force the frame to update
	SetWindowPos( hWnd, 0,0,0,0,0, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER )


	Local button:TGadget=CreateButton("OK",(win.clientwidth()-bw)/2,win.clientheight()-bh-2-bi,bw,bh,win)
	ActivateGadget button
	setfocus QueryGadget(button,QUERY_HWND)

	'w=TextWidth(message)
	
	w=80
	h=16
	
	CreateLabel message,(win.clientwidth()-w)/2,(win.clientheight()-h-bh-bi)/2,w,h,win,LABEL_CENTER

	
	Repeat
		Select WaitEvent()
			Case EVENT_GADGETACTION
				Select EventSource()
					Case button
						Exit
				EndSelect
			Case EVENT_WINDOWCLOSE
				Select EventSource()
					Case win
						Exit
				EndSelect
		EndSelect
		
	Forever
	FreeGadget win
	Return 0
EndFunction