#include Once "window9.bi"

Function Messbox(sCaption As String , sText As String , flag As Long  = MB_OK , ParentWin As Hwnd = 0)	As Long Export
	
	Dim Box As HWND
	
	If flag = MB_OK Then
	
		Box = gtk_message_dialog_new(Cast(Any Ptr,ParentWin), GTK_DIALOG_MODAL, _
		GTK_MESSAGE_INFO, GTK_BUTTONS_OK, g_locale_to_utf8(sText,Len(sText) ,0,0,0) )

	Elseif 	flag = MB_YESNO Then

		Box = gtk_message_dialog_new(Cast(Any Ptr,ParentWin), GTK_DIALOG_MODAL, _
		GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, g_locale_to_utf8(sText,Len(sText) ,0,0,0) )
		
	Elseif flag = MB_YESNOCANCEL Then
	
		Box = gtk_message_dialog_new(Cast(Any Ptr,ParentWin), GTK_DIALOG_MODAL, _
		GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, g_locale_to_utf8(sText,Len(sText) ,0,0,0) )	

		gtk_dialog_add_buttons(GTK_DIALOG(Box),_
			       GTK_STOCK_YES,_
			       GTK_RESPONSE_YES,_
			       GTK_STOCK_NO,_
			       GTK_RESPONSE_NO,_
			       GTK_STOCK_CANCEL,_
			       GTK_RESPONSE_CANCEL,_
			       NULL)
		
		gtk_dialog_set_default_response (GTK_DIALOG(Box),GTK_RESPONSE_YES)

	Endif
	
	gtk_window_set_title(GTK_WINDOW(Box), g_locale_to_utf8(sCaption,Len(sCaption),0,0,0))
	
	Dim As gint result  = gtk_dialog_run(GTK_DIALOG(Box))
	
	If flag = MB_YESNO Orelse flag = MB_YESNOCANCEL Then
	
		If result = GTK_RESPONSE_NO Then 
	
			Messbox = IDNO
			
		Elseif 	result = GTK_RESPONSE_YES Then 
		
			Messbox = IDYES
			
		Else
		
			Messbox = IDCANCEL

		Endif
		
	Else
	
		Messbox = IDOK

	Endif
	
	gtk_widget_destroy(Box) 
	
End Function