Page 1 sur 1

MessageRequester personnalisé

Publié : ven. 27/mai/2016 11:33
par microdevweb
Bonjour

Voila un code pour un MessageRequesterpersonnalisé, il s'utilise exactement comme le MessageRequester de PureBasic deux constante supplémentaire existe #PB_MessageRequester_NoYes et #PB_MessageRequester_NoYesCancel

MessageRequester(Title,Text,Flag=#PB_MessageRequester_Ok,Image=-1,CurrentLanguage=0)

Image --> si vous voulez ajouter une icone
CurrentLanguage --> pour changer la langue 0 FR 1 EN

Note: Seul gros HIC, n'est pas compatible si vous utilisé les BindEvent (je vais essayé de contourner ce problème)

Code : Tout sélectionner

;{ Code à coller en début d'application
#PB_MessageRequester_NoYes=$FF
#PB_MessageRequester_NoYesCancel=$FF2

Procedure OpenMessageRequester(Title.s,Text.s,Flag,Image,CurrentLanguage)
    ; Paramètres personalisables
    Protected Margin=10 
    Protected MinimumWF=260 ; Largeur minimum de la fenêtre
    Protected FontTxt=LoadFont(#PB_Any,"Arial",9,#PB_Font_HighQuality)
    Protected FontBT=LoadFont(#PB_Any,"Arial",9,#PB_Font_HighQuality)
    Protected FontTitle=LoadFont(#PB_Any,"Arial",10,#PB_Font_HighQuality)
    Protected BgColor=$B8B8B8
    Protected TitleBgColor=$4F4F4F
    Protected TitleFgColor=$4FA5FF
    Protected TextFgColor=$171717
    Protected TitleHeight=32
    Protected FlagW=#PB_Window_WindowCentered|#PB_Window_Invisible|#PB_Window_BorderLess
    Protected Form,WF,HF,TW,TH,BtH=30,BtW=70,X,Y
    Protected btYes,btNo,btChancel
    Protected Event,Type
    Protected MotherWindow=GetActiveWindow()
    Protected MainContainer,MainCanvas
    
    ;Langue
    Enumeration 
        #Yes
        #No
        #Chancel
    EndEnumeration
    Enumeration
        #Fr
        #En
     EndEnumeration   
     Dim msg.s(#Chancel,#En)
     msg(#Yes,#Fr)="Oui"
     msg(#Yes,#En)="Yes"
     msg(#No,#Fr)="Non"
     msg(#No,#En)="No"
     msg(#Chancel,#Fr)="Annuler"
     msg(#Chancel,#En)="Chancel"
    ; Désactive la fenêtre mère
    DisableWindow(MotherWindow,#True)
    ; Ouverture de la fenêtre
    Form=OpenWindow(#PB_Any,0,0,100,100,Title,FlagW,WindowID(MotherWindow))
    ; Calcul de la taille nécessaire
    StartDrawing(WindowOutput(Form))
    DrawingFont(FontID(FontTxt))
    TW=TextWidth(Text)
    TH=TextHeight(Text)
    DrawingFont(FontID(FontTitle))
    If TextWidth(Title)+(margin*2)>TW
        TW=TextWidth(Title)+(margin*2)
    EndIf
    If Image>-1
        TW+TitleHeight
    EndIf
    WF=TW+(Margin*2)
    HF=TH+(Margin*7)+TitleHeight
    StopDrawing()
    If WF<MinimumWF
        WF=MinimumWF
    EndIf
    ; Redimentionne la fenêtre
    X=(WindowX(MotherWindow)+(WindowWidth(MotherWindow)/2))-(WF/2)
    Y=(WindowY(MotherWindow)+(WindowHeight(MotherWindow)/2))-(HF/2)
    ResizeWindow(Form,X,Y,WF,HF)
    ; Création du container
    MainContainer=ContainerGadget(#PB_Any,0,0,WF,HF,#PB_Container_Raised)
    ; Création et dessin du Canvas
    MainCanvas=CanvasGadget(#PB_Any,0,0,WF,HF)
    StartDrawing(CanvasOutput(MainCanvas))
    DrawingMode(#PB_2DDrawing_Default)
    DrawingFont(FontID(FontTitle))
    Box(0,0,WF,HF,BgColor)
    Box(0,0,WF,TitleHeight,TitleBgColor)
    If Image>-1
        Y=2
        X=WF-(TitleHeight+4)
        DrawingMode(#PB_2DDrawing_AlphaClip)
        DrawImage(ImageID(Image),X,Y,TitleHeight-4,TitleHeight-4)
    EndIf
    X=Margin
    Y=(TitleHeight/2)-(TextHeight(Title)/2)
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawText(X,Y,Title,TitleFgColor)
    X=(WF/2)-(TextWidth(Text)/2)
    Y=Margin+TitleHeight
    DrawingFont(FontID(FontTxt))
    DrawText(X,Y,Text,TextFgColor)
    StopDrawing()
    DisableGadget(MainCanvas,#True)
    Y+TH+(Margin)*2
    Select Flag
        Case #PB_MessageRequester_Ok
            X=(WF/2)-(BtW/2)
            btYes=ButtonGadget(#PB_Any,X,Y,btW,btH,"Ok")
            SetGadgetData(btYes,#PB_MessageRequester_Ok)
            SetGadgetFont(btYes,FontID(FontBT))
            AddKeyboardShortcut(Form,#PB_Shortcut_Return,#PB_MessageRequester_Ok)
        Case #PB_MessageRequester_YesNo
            X=(WF/2)-(((BtW*2)+Margin)/2)
            btYes=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#Yes,CurrentLanguage))
            SetGadgetData(btYes,#PB_MessageRequester_Yes)
            SetGadgetFont(btYes,FontID(FontBT))
            AddKeyboardShortcut(Form,#PB_Shortcut_Return,#PB_MessageRequester_Yes)
            SetActiveGadget(btYes)
            X+BtW+Margin
            btNo=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#No,CurrentLanguage))
            SetGadgetData(btNo,#PB_MessageRequester_No)
            SetGadgetFont(btNo,FontID(FontBT))
            AddKeyboardShortcut(Form,#PB_Shortcut_Escape,#PB_MessageRequester_No)
        Case #PB_MessageRequester_NoYes
            X=(WF/2)-(((BtW*2)+Margin)/2)
            btNo=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#No,CurrentLanguage))
            SetGadgetData(btNo,#PB_MessageRequester_No)
            SetGadgetFont(btNo,FontID(FontBT))
            AddKeyboardShortcut(Form,#PB_Shortcut_Return,#PB_MessageRequester_No)
            AddKeyboardShortcut(Form,#PB_Shortcut_Escape,#PB_MessageRequester_No)
            X+BtW+Margin
             btYes=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#Yes,CurrentLanguage))
            SetGadgetData(btYes,#PB_MessageRequester_Yes)
            SetGadgetFont(btYes,FontID(FontBT))
            SetActiveGadget(btYes)
        Case #PB_MessageRequester_YesNoCancel
            X=(WF/2)-(((BtW*3)+(Margin*2))/2)
            btYes=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#Yes,CurrentLanguage))
            SetGadgetData(btYes,#PB_MessageRequester_Yes)
            SetGadgetFont(btYes,FontID(FontBT))
            AddKeyboardShortcut(Form,#PB_Shortcut_Return,#PB_MessageRequester_Yes)
            X+BtW+Margin
            btNo=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#No,CurrentLanguage))
            SetGadgetData(btNo,#PB_MessageRequester_No)
            SetGadgetFont(btNo,FontID(FontBT))
            X+BtW+Margin
             btChancel=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#Chancel,CurrentLanguage))
            SetGadgetData(btChancel,#PB_MessageRequester_Cancel)
            SetGadgetFont(btChancel,FontID(FontBT))
            AddKeyboardShortcut(Form,#PB_Shortcut_Escape,#PB_MessageRequester_Cancel)
        Case #PB_MessageRequester_NoYesCancel
            X=(WF/2)-(((BtW*3)+(Margin*2))/2)
            btNo=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#No,CurrentLanguage))
            SetGadgetData(btNo,#PB_MessageRequester_No)
            SetGadgetFont(btNo,FontID(FontBT))
            AddKeyboardShortcut(Form,#PB_Shortcut_Return,#PB_MessageRequester_No)
            X+BtW+Margin
            btYes=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#Yes,CurrentLanguage))
            SetGadgetData(btYes,#PB_MessageRequester_Yes)
            SetGadgetFont(btYes,FontID(FontBT))
            X+BtW+Margin
            btChancel=ButtonGadget(#PB_Any,X,Y,btW,btH,msg(#Chancel,CurrentLanguage))
            SetGadgetData(btChancel,#PB_MessageRequester_Cancel)
            SetGadgetFont(btChancel,FontID(FontBT))
            AddKeyboardShortcut(Form,#PB_Shortcut_Escape,#PB_MessageRequester_Cancel)
    EndSelect
    CloseGadgetList()
    HideWindow(Form,#False)
    Repeat
        Event=WaitWindowEvent()
        Select Event
            Case #PB_Event_Gadget
                Type=GetGadgetData(EventGadget())
                CloseWindow(Form)
                DisableWindow(MotherWindow,#False)
                ProcedureReturn Type
            Case #PB_Event_Menu
                Type=EventMenu()
                CloseWindow(Form)
                DisableWindow(MotherWindow,#False)
                ProcedureReturn Type
        EndSelect
    ForEver 
EndProcedure

Macro MessageRequester(Title,Text,Flag=#PB_MessageRequester_Ok,Image=-1,CurrentLanguage=0)
    OpenMessageRequester(Title,Text,Flag,Image,CurrentLanguage)
EndMacro
;} FIN de Code à coller en début d'application

; Code de teste
Enumeration 
    #BtOk
    #BtYesNo
    #BtNoYes
    #BtYesNoChancel
    #BtNoYerChancel
EndEnumeration
Global Dim txt.s(#BtNoYerChancel)
txt(#BtOk)=" Msg OK"
txt(#BtYesNo)=" Msg YesNo"
txt(#BtNoYes)=" Msg NoYes"
txt(#BtYesNoChancel)=" Msg YesNoChancel"
txt(#BtNoYerChancel)=" Msg NoYesChancel"
Declare EventButton()
OpenWindow(0,0,0,800,600,"teste",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
BtW=90
BtH=30
btMargin=10
X=400-((BtH*(#BtNoYerChancel+1))+(btMargin*#BtNoYerChancel))
Y=300+BtH
For N=#BtOk To #BtNoYerChancel
    ButtonGadget(N,X,Y,BtW,BtH,txt(N))
    X+BtW+btMargin
Next

Procedure EventButton()
    Select EventGadget()
        Case #BtOk
            Debug MessageRequester("Teste",txt(EventGadget()),#PB_MessageRequester_Ok)
        Case #BtYesNo
            Debug MessageRequester("Teste",txt(EventGadget()),#PB_MessageRequester_YesNo)
        Case #BtNoYes
            Debug MessageRequester("Teste",txt(EventGadget()),#PB_MessageRequester_NoYes)
        Case #BtYesNoChancel
            Debug MessageRequester("Teste",txt(EventGadget()),#PB_MessageRequester_YesNoCancel)
        Case #BtNoYerChancel
            Debug MessageRequester("Teste",txt(EventGadget()),#PB_MessageRequester_NoYesCancel)
    EndSelect
EndProcedure

Repeat
    Event=WaitWindowEvent()
    Select Event
        Case #PB_Event_Gadget
            EventButton()
    EndSelect
Until Event=#PB_Event_CloseWindow

Re: MessageRequester personnalisé

Publié : ven. 27/mai/2016 15:40
par GallyHC
Bonjour,

Cela peut être bien utile dans un programme, je met de coté.

Cordialement,
GallyHC

Re: MessageRequester personnalisé

Publié : lun. 30/mai/2016 15:08
par Mesa
Quelque part se trouve mon code pour faire un code de message requester personnalisé mais pour windows seulement.

Je le remets dessous:

Code : Tout sélectionner

; **************************************************
; **************************************************
; * WinMessageBox                                 *
; *                                                *
; * Code Mesaliko                                  *
; *      LSI                                       *
; * PB 4.5x remplacer FrameGadget par Frame3DGadget*
; *                                                *
; * Décembre 2011                                  *
; * Bug corrigé longueur de texte Janvier 2012     *
; * PB 5.xx Mars 2016                              *
; **************************************************

;{- Enumerations / DataSections
;{ Windows
Enumeration
	#Window_0
	#Window_1
EndEnumeration
;}
;{ Gadgets
Enumeration
	#Frame3D_0
	#Option_1
	#Option_2
	#Option_3
	#Option_4
	#Option_5
	#Option_6
	#Option_7
	#Text_8
	#Frame3D_9
	#Option_10
	#Option_11
	#Option_12
	#Option_13
	#Option_14
	#Frame3D_15
	#Option_16
	#Option_17
	#Option_18
	#Option_19
	#Frame3D_20
	#Option_21
	#Option_22
	#Option_23
	#Frame3D_24
	#Option_25
	#Option_26
	#Option_27
	#Option_28
	#Option_29
	#Option_30
	
	#Button_0
	
	#String_0
	#String_1
	
	#CheckBox_0
	
	#TextGadget_1_0
	
EndEnumeration

Global True=1
Global False=0
Global h_frame

Global code.s

;}
; Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure Callback(hWin,msg,wParam,lParam)
	Select msg
		Case #WM_HELP
			*hlp.HELPINFO = lParam
			Select *hlp\iContextType
				Case #HELPINFO_WINDOW
					;Debug "Help Window - CtrlId:"+Str(*hlp\iCtrlId)+" - ItemHandle:"+Str(*hlp\hItemHandle)+" - ContextId:"+Str(*hlp\dwContextId)+" - Mouse:"+Str(*hlp\MousePos\x)+"/"+Str(*hlp\MousePos\y)
					MessageRequester("Aide","Vous avez demandé de l'aide ?",36);16384
																																			;Case #HELPINFO_MENUITEM
																																			;Debug "Help Menu - CtrlId:"+Str(*hlp\iCtrlId)+" - ItemHandle:"+Str(*hlp\hItemHandle)+" - ContextId:"+Str(*hlp\dwContextId)+" - Mouse:"+Str(*hlp\MousePos\x)+"/"+Str(*hlp\MousePos\y)
			EndSelect
	EndSelect
	ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

Procedure.l GetTextWidthPix(numb, espace=1)
	;espace : null-terminated + pour la checkbox par exemple, il faut ajouter la largeur d'un espace au texte 
	hDC = GetDC_(GadgetID(numb))
	hFont = SendMessage_(GadgetID(numb),#WM_GETFONT,0,0)
	If hFont And hDC
		SelectObject_(hDC,hFont)
	EndIf
	GetTextExtentPoint32_(hDC, GetGadgetText(numb), Len(GetGadgetText(numb)) + espace, lpSize.SIZE)
	result=lpSize\cx
	ReleaseDC_(#Window_0, hDC)
	ProcedureReturn result
EndProcedure

Procedure.l GetTextHeightPix(numb, espace=8)
	; pourquoi 8 ????? 
	hDC = GetDC_(GadgetID(numb))
	hFont = SendMessage_(GadgetID(numb),#WM_GETFONT,0,0)
	If hFont And hDC
		SelectObject_(hDC,hFont)
	EndIf
	GetTextExtentPoint32_(hDC, GetGadgetText(numb), Len(GetGadgetText(numb)), lpSize.SIZE)
	result=lpSize\cy + espace
	ReleaseDC_(#Window_0, hDC)
	ProcedureReturn result
EndProcedure

; Procedure.l LoadWindowFont(Bold = -1, Italic = -1, UnderLine = -1, Size.f = -1)
;    Protected ncm.NONCLIENTMETRICS
;    ncm\cbSize = SizeOf(NONCLIENTMETRICS)
;    SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
;    If Bold = 0
;       ncm\lfMessageFont\lfWeight = 0
;    ElseIf Bold = 1
;       ncm\lfMessageFont\lfWeight = 700
;    EndIf
;    If Italic = 0
;       ncm\lfMessageFont\lfItalic = 0
;    ElseIf Italic = 1
;       ncm\lfMessageFont\lfItalic = 1
;    EndIf
;    If UnderLine = 0
;       ncm\lfMessageFont\lfUnderline = 0
;    ElseIf UnderLine = 1
;       ncm\lfMessageFont\lfUnderline = 1
;    EndIf
;    If Size > 0
;       ncm\lfMessageFont\lfheight * Size
;    EndIf
;    
; ;    Debug PeekS(@ncm\lfMessageFont\lfFaceName, 32)
; ;    CompilerIf #PB_Compiler_Debugger
; ;    DC = GetDC_(0)
; ;    Debug Round(Abs(ncm\lfMessageFont\lfheight) * 72 / GetDeviceCaps_(DC, #LOGPIXELSY), #PB_Round_Nearest)
; ;    ReleaseDC_(0, DC)
; ;    CompilerEndIf
; ;    
;    ProcedureReturn CreateFontIndirect_(@ncm\lfMessageFont)
; EndProcedure

Procedure OpenWindow_Window_0()
	
	x_frame = 8 ; marge gauche du cadre
	x_option = 16 ; marge gauche bouton radio
	
	
	;    FontID = LoadWindowFont()
	;    If FontID
	;       If CreateImage(0, 300, 200)
	;          If StartDrawing(ImageOutput(0))
	;                DrawingFont(FontID)
	;                h_frame = TextHeight("M") ; unité de hauteur
	;                l_frame = TextWidth("ANNULER(2)  RECOMMENCER(10)  CONTINUER(11)  ") + h_frame ; longueur max des cadres
	;             StopDrawing()
	;          EndIf
	;          FreeImage(0)
	;       EndIf
	;       DeleteObject_(FontID)
	;    EndIf
	
	
	;    l_option = l_frame ; longueur bouton radio
	;    h_option = h_frame ; hauteur bouton radio
	;    l_frame + 2 * x_option + 2 * x_frame
	
	If OpenWindow(#Window_0, 0, 0, 0, 0, "Créateur de WinMessageBox ", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
		LoadFont(1, "Arial", 9)
		SetGadgetFont(#PB_Default, FontID(1))
		;FontID = LoadWindowFont()
		;SetGadgetFont(#PB_Default, FontID)
		OptionGadget(1000,0,0,10,10,"ANNULER(2)  RECOMMENCER(10)  CONTINUER(11)")
		l_frame =GetTextWidthPix(1000,2)
		h_frame =GetTextHeightPix(1000)
		ResizeGadget(1000,#PB_Ignore ,#PB_Ignore ,l_frame,h_frame)
		l_frame = GadgetWidth(1000)
		h_frame = GadgetHeight(1000)
		FreeGadget(1000)
		
		l_option = l_frame ; longueur bouton radio
		h_option = h_frame ; hauteur bouton radio
		l_frame + 2 * x_option + 2 * x_frame
		
		delta_y = -4 ; espace entre les boutons radio
		
		y = -delta_y
		FrameGadget(#Frame3D_0, x_frame, y, l_frame, h_frame * 1.5 + delta_y + (h_option + delta_y) * 7, "Type de Bouton (Retour bouton)")
		y + h_frame + delta_y
		OptionGadget(#Option_1, x_frame + x_option, y, l_option, h_option, "OK(1)")
		SetGadgetState(#Option_1, 1)
		y + h_option + delta_y
		OptionGadget(#Option_2, x_frame + x_option, y, l_option, h_option, "OK(1)  ANNULER(2)")
		y + h_option + delta_y
		OptionGadget(#Option_3, x_frame + x_option, y, l_option, h_option, "ABANDONNER(3)  RECOMMENCER(4)  IGNORER(5)")
		y + h_option + delta_y
		OptionGadget(#Option_4, x_frame + x_option, y, l_option, h_option, "OUI(6)  NON(7)  ABANDONNER(3)")
		y + h_option + delta_y
		OptionGadget(#Option_5, x_frame + x_option, y, l_option, h_option, "OUI(6)  NON(7)")
		y + h_option + delta_y
		OptionGadget(#Option_6, x_frame + x_option, y, l_option, h_option, "RECOMMENCER(4)  ANNULER(2)")
		y + h_option + delta_y
		OptionGadget(#Option_7, x_frame + x_option, y, l_option, h_option, "ANNULER(2)  RECOMMENCER(10)  CONTINUER(11)")
		y + h_option + delta_y
		y + h_frame * 0.5
		
		y - delta_y
		
		y0 = y
		FrameGadget(#Frame3D_9, x_frame, y, l_frame / 2, h_frame * 1.5 + delta_y + (h_option + delta_y) * 5, "Icône ")
		y + h_frame + delta_y
		OptionGadget(#Option_10, x_frame + x_option, y, l_option / 2 - x_option, h_option, "Pas d'icône")
		SetGadgetState(#Option_10, 1)
		y + h_option + delta_y
		OptionGadget(#Option_11, x_frame + x_option, y, l_option / 2 - x_option, h_option, "Stop")
		y + h_option + delta_y
		OptionGadget(#Option_12, x_frame + x_option, y, l_option / 2 - x_option, h_option, "?")
		y + h_option + delta_y
		OptionGadget(#Option_13, x_frame + x_option, y, l_option / 2 - x_option, h_option, "!")
		y + h_option + delta_y
		OptionGadget(#Option_14, x_frame + x_option, y, l_option / 2 - x_option, h_option, "i")
		y + h_option + delta_y
		y + h_frame * 0.5
		
		y - delta_y
		
		y = y0
		FrameGadget(#Frame3D_15, x_frame + l_frame / 2, y, l_frame / 2, h_frame * 1.5 + delta_y + (h_option + delta_y) * 5, "Bouton par défaut ")
		y + h_frame + delta_y
		OptionGadget(#Option_16, x_frame + l_frame / 2 + x_option, y, l_option / 2 - delta_x, h_option, "Premier")
		SetGadgetState(#Option_16, 1)
		y + h_option + delta_y
		OptionGadget(#Option_17, x_frame + l_frame / 2 + x_option, y, l_option / 2 - delta_x, h_option, "Second")
		y + h_option + delta_y
		OptionGadget(#Option_18, x_frame + l_frame / 2 + x_option, y, l_option / 2 - delta_x, h_option, "Troisième")
		y + h_option + delta_y
		OptionGadget(#Option_19, x_frame + l_frame / 2 + x_option, y, l_option / 2 - delta_x, h_option, "Quatrième")
		y + h_option + delta_y
		CheckBoxGadget(#CheckBox_0, x_frame + l_frame / 2 + x_option, y, l_option / 2 - delta_x, h_option, "Ajouter Bouton Aide")
		y + h_option + delta_y
		y + h_frame * 0.5
		
		y - delta_y
		
		FrameGadget(#Frame3D_20, x_frame, y, l_frame, h_frame * 1.5 + delta_y + (h_option + delta_y) * 3, "Modalité ")
		y + h_frame + delta_y
		OptionGadget(#Option_21, x_frame + x_option, y, l_option, h_option, "Modal-Par défaut")
		SetGadgetState(#Option_21, 1)
		y + h_option + delta_y
		OptionGadget(#Option_22, x_frame + x_option, y, l_option, h_option, "Système")
		y + h_option + delta_y
		OptionGadget(#Option_23, x_frame + x_option, y, l_option, h_option, "Tâche")
		y + h_option + delta_y
		y + h_frame * 0.5
		
		y - delta_y
		
		FrameGadget(#Frame3D_24, x_frame, y, l_frame, h_frame * 1.5 + delta_y + (h_option + delta_y) * 6, "Divers ")
		y + h_frame + delta_y
		OptionGadget(#Option_25, x_frame + x_option, y, l_option, h_option, "Par défaut")
		SetGadgetState(#Option_25, 1)
		y + h_option + delta_y
		OptionGadget(#Option_26, x_frame + x_option, y, l_option, h_option, "Sur le bureau par défaut uniquement")
		y + h_option + delta_y
		OptionGadget(#Option_27, x_frame + x_option, y, l_option, h_option, "Texte aligné à droite")
		y + h_option + delta_y
		OptionGadget(#Option_28, x_frame + x_option, y, l_option, h_option, "En avant-plan")
		y + h_option + delta_y
		OptionGadget(#Option_29, x_frame + x_option, y, l_option, h_option, "Top-most attribut")
		y + h_option + delta_y
		OptionGadget(#Option_30, x_frame + x_option, y, l_option, h_option, "Notification service")
		y + h_option + delta_y
		y + h_frame * 0.5
		
		y - delta_y
		
		StringGadget(#String_0, x_frame, y, l_frame, h_option + 8, "Entrez le Titre du WinMessageBox")
		y + h_option + 8 - delta_y
		StringGadget(#String_1, x_frame, y, l_frame, h_option + 8, "Entrez le Texte du WinMessageBox")
		y + h_option + 8 - delta_y
		ButtonGadget(#Button_0, x_frame, y, l_frame, h_option * 2, "Code PureBasic dans le Presse-Papier")
		y + h_option * 2
		
		; y - delta_y
		
		ResizeWindow(#Window_0, #PB_Ignore, 8, l_frame + x_frame * 2, y)
		
	EndIf
EndProcedure

Procedure OpenWindow_Window_Code() ; fenêtre fille qui affiche le code final
	
	x0=  WindowX(#Window_0) ; distance jusqu'au bord de la fenêtre principale
	
	If OpenWindow(#Window_1,0, 0,x0-6,100,"Ce Code à copier est déjà dans le Presse-Papier", #PB_Window_Tool, WindowID(#Window_0))
		;TextGadget(#TextGadget_1_0,0,0,290,90,code,#PB_Text_Border)
		EditorGadget(#TextGadget_1_0, 0, 0, x0-10, 30)
		SetGadgetItemText(#TextGadget_1_0, -1, code)
		h_editor = h_frame*(CountGadgetItems(#TextGadget_1_0)  + 2) ; hauteur de l'editor
		ResizeGadget(#TextGadget_1_0, #PB_Ignore, #PB_Ignore, #PB_Ignore, h_editor)
		ResizeWindow(#Window_1, #PB_Ignore, #PB_Ignore, #PB_Ignore, h_editor+30)
	EndIf
	
EndProcedure


OpenWindow_Window_0()
SetWindowCallback(@Callback()) ; gestion de l'aide

;{- Event loop
Repeat
	Event = WaitWindowEvent()
	
	Select Event
			; ///////////////////
		Case #PB_Event_Gadget
			EventGadget = EventGadget()
			EventType = EventType()
			;{-
			; If EventGadget = #Frame3D_0
			; ElseIf EventGadget = #Option_1
			; ElseIf EventGadget = #Option_2
			; ElseIf EventGadget = #Option_3
			; ElseIf EventGadget = #Option_4
			; ElseIf EventGadget = #Option_5
			; ElseIf EventGadget = #Option_6
			; ElseIf EventGadget = #Option_7
			; ElseIf EventGadget = #Text_8
			; ElseIf EventGadget = #Frame3D_9
			; ElseIf EventGadget = #Option_10
			; ElseIf EventGadget = #Option_11
			; ElseIf EventGadget = #Option_12
			; ElseIf EventGadget = #Option_13
			; ElseIf EventGadget = #Option_14
			; ElseIf EventGadget = #Frame3D_15
			; ElseIf EventGadget = #Option_16
			; ElseIf EventGadget = #Option_17
			; ElseIf EventGadget = #Option_18
			; ElseIf EventGadget = #Frame3D_19
			; ElseIf EventGadget = #Option_20
			; ElseIf EventGadget = #Option_21
			; ElseIf EventGadget = #Option_22
			; ElseIf EventGadget = #Option_23
			; ElseIf EventGadget = #Option_24
			; ElseIf EventGadget = #Option_25
			; ElseIf
			;}
			
			
			If EventGadget = #Button_0
				
				; option1 Type de Box
				Compteur = 0
				For i = #Option_1 To #Option_1 + 6
					; Debug GetGadgetState(i)
					If GetGadgetState(i) = 1
						option1 = Compteur
					EndIf
					Compteur = Compteur + 1
				Next i
				
				; option2 Icône
				Compteur = 0
				For i = #Option_10 To #Option_10 + 4
					; Debug GetGadgetState(i)
					If GetGadgetState(i) = 1
						option2 = Compteur * 16
					EndIf
					Compteur = Compteur + 1
				Next i
				
				; option3 Bouton par dédaut
				Compteur = 0
				For i = #Option_16 To #Option_16 + 3
					; Debug GetGadgetState(i)
					If GetGadgetState(i) = 1
						option3 = Compteur * 256
					EndIf
					Compteur = Compteur + 1
				Next i
				
				; option4 Modalité
				Compteur = 0
				For i = #Option_21 To #Option_21 + 2
					; Debug GetGadgetState(i)
					If GetGadgetState(i) = 1
						option4 = Compteur * 4096
					EndIf
					Compteur = Compteur + 1
				Next i
				
				; option5 Divers
				If GetGadgetState(#Option_25) = 1 : option5 = 0 * 65536 : EndIf
				If GetGadgetState(#Option_26) = 1 : option5 = 2 * 65536 : EndIf
				If GetGadgetState(#Option_27) = 1 : option5 = 8 * 65536 : EndIf
				If GetGadgetState(#Option_28) = 1 : option5 = 1 * 65536 : EndIf
				If GetGadgetState(#Option_29) = 1 : option5 = 4 * 65536 : EndIf
				If GetGadgetState(#Option_30) = 1 : option5 = 1 * 1046876 : EndIf
				; Debug option5
				
				options = option1 + option2 + option3 + option4 + option5
				; Debug options
				
				
				; Code sous forme de texte dans le presse-papier
				code = "Retour=MessageRequester(" + Chr(34) + GetGadgetText(#String_0) + Chr(34) + ", " + Chr(34) + GetGadgetText(#String_1) + Chr(34) + ", " + Str(options) + ")"
				
				If GetGadgetState(#CheckBox_0) = 1 ; Si Ajout du bouton Aide
					options = options + 4 * 4096
					
					code = code + Chr(13)+Chr(10)
					code = code + Chr(13)+Chr(10) + "Pour gérer l'aide, Ajouter cette procédure avant le openwindow()"
					code = code + Chr(13)+Chr(10) + "Procedure Callback(hWin,msg,wParam,lParam)"
					code = code + Chr(13)+Chr(10) + "Select msg"
					code = code + Chr(13)+Chr(10) + "Case #WM_HELP"
					code = code + Chr(13)+Chr(10) + "*hlp.HELPINFO = lParam"
					code = code + Chr(13)+Chr(10) + "Select *hlp\iContextType"
					code = code + Chr(13)+Chr(10) + "Case #HELPINFO_WINDOW"
					code = code + Chr(13)+Chr(10) + ";Debug " + Chr(34) + "Help Window - CtrlId: "+ Chr(34) + "+Str(*hlp\iCtrlId)+ "+ Chr(34) +  "- ItemHandle: "+ Chr(34) + "+Str(*hlp\hItemHandle)+ "+ Chr(34) +  "- ContextId: "+ Chr(34) + "+Str(*hlp\dwContextId)+ "+ Chr(34) +  "- Mouse: "+ Chr(34) + "+Str(*hlp\MousePos\x)+"+ Chr(34) + "/"+ Chr(34) + "+Str(*hlp\MousePos\y)"
					code = code + Chr(13)+Chr(10) + ";MessageRequester(" + Chr(34) + "Aide" + Chr(34) + "," + Chr(34) + "Vous avez demandé de l'aide ?" + Chr(34) + ",36)"
					code = code + Chr(13)+Chr(10) + ";Case #HELPINFO_MENUITEM"
					code = code + Chr(13)+Chr(10) + ";Debug " + Chr(34) + "Help Menu - CtrlId:" + Chr(34) + "+Str(*hlp\iCtrlId)+" + Chr(34) + " - ItemHandle:" + Chr(34) + "+Str(*hlp\hItemHandle)+" + Chr(34) + " - ContextId:" + Chr(34) + "+Str(*hlp\dwContextId)+" + Chr(34) + " - Mouse:" + Chr(34) + "+Str(*hlp\MousePos\x)+" + Chr(34) + "/" + Chr(34) + "+Str(*hlp\MousePos\y)"
					code = code + Chr(13)+Chr(10) + "EndSelect"
					code = code + Chr(13)+Chr(10) + "EndSelect"
					code = code + Chr(13)+Chr(10) + "ProcedureReturn #PB_ProcessPureBasicEvents"
					code = code + Chr(13)+Chr(10) + "EndProcedure"
					code = code + Chr(13)+Chr(10)
					code = code + Chr(13)+Chr(10) + "Et ajouter cette ligne après le openwindow()"
					code = code + Chr(13)+Chr(10) + "SetWindowCallback(@Callback())"
					code = code + Chr(13)+Chr(10)
					code = code + Chr(13)+Chr(10) + "La touche F1 devrait fonctionner"
					
				EndIf
				
				
				;Debug code
				
				ClearClipboard()
				SetClipboardText(code)
				
				OpenWindow_Window_Code()
				
				; On voit ce que ça donne
				Retour = MessageRequester(GetGadgetText(#String_0), GetGadgetText(#String_1), options)
				
				Debug Retour
				
			EndIf
			
			; ////////////////////////
		Case #PB_Event_CloseWindow
			EventWindow = EventWindow()
			If EventWindow = #Window_0
				CloseWindow(#Window_0)
				Break
			EndIf
	EndSelect
ForEver
;}

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; Pour avoir une fenêtre avec un "?" dans la barre de titre

;   OpenWindow(0, 100, 100, 200, 200, "ContextHelp Example", #PB_Window_SystemMenu); And CreateGadgetList(WindowID(0))
;   SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_CONTEXTHELP)
;   SetWindowPos_(WindowID(0), 0, -1 , -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE | #SWP_NOZORDER  | #SWP_FRAMECHANGED | #SWP_SHOWWINDOW)

; --------------------------------------------------------------------------------
;
;
; Button Pressed Return Value 
; OK  1
; CANCEL  2
; ABORT  3
; RETRY  4
; IGNORE  5
; YES  6
; NO  7
; TRY AGAIN ** 10
; Continue ** 11
;
; 
;
; Remarks
;
; The flag parameter can be a combination of the following values:
;
; decimal flag Button-related Result hexadecimal flag
; 0 OK button 0x0
; 1 OK And Cancel 0x1
; 2 Abort, Retry, And Ignore 0x2
; 3 Yes, No, And Cancel 0x3
; 4 Yes And No 0x4
; 5 Retry And Cancel 0x5
; 6 ** Cancel, Try Again, Continue 0x6


; decimal flag Icon-related Result hexadecimal flag
; 0 (No icon) 0x0
; 16 Stop-sign icon 0x10
; 32 Question-mark icon 0x20
; 48 Exclamation-point icon 0x30
; 64 Information-sign icon consisting of an 'i' in a circle 0x40

; decimal flag Default-related Result hexadecimal flag
; 0 First button is Default button 0x0
; 256 Second button is Default button 0x100
; 512 Third button is Default button 0x200
;(0x00000300L le 4 ieme bouton)

; decimal flag Modality-related Result hexadecimal flag
; 0 Application  0x0
; 4096 System modal (dialog has an icon) 0x1000
; 8192 Task modal 0x2000

; decimal flag Miscellaneous-related Result hexadecimal flag
; 0 (nothing Else special) 0x0
;(0x20000 MB_DEFAULT_DESKTOP_ONLY
; 262144 MsgBox has top-most attribute set 0x40000
; 524288 title And text are right-justified 0x80000

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

; Displays a modal dialog box that contains a system icon, a set of buttons, And a brief application-specific message, such As status Or error information. The message box returns an integer value that indicates which button the user clicked.
; Syntax
;
; int WINAPI MessageBox(
;   __in_opt  HWND hWnd,
;   __in_opt  LPCTSTR lpText,
;   __in_opt  LPCTSTR lpCaption,
;   __in      UINT uType
; );
;
; Parameters
;
; hWnd [in, optional]
;
;     Type: HWND
;
;     A handle To the owner window of the message box To be created. If this parameter is NULL, the message box has no owner window.
; lpText [in, optional]
;
;     Type: LPCTSTR
;
;     The message To be displayed. If the string consists of more than one line, you can separate the lines using a carriage Return And/Or linefeed character between each line.
; lpCaption [in, optional]
;
;     Type: LPCTSTR
;
;     The dialog box title. If this parameter is NULL, the Default title is Error.
; uType [in]
;
;     Type: UINT
;
;     The contents And behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags.
;
;     To indicate the buttons displayed in the message box, specify one of the following values.
;     Value   Meaning
;
;     MB_ABORTRETRYIGNORE
;     0x00000002L
;
;        
;
;     The message box contains three push buttons: Abort, Retry, And Ignore.
;
;     MB_CANCELTRYCONTINUE
;     0x00000006L
;
;        
;
;     The message box contains three push buttons: Cancel, Try Again, Continue. Use this message box type instead of MB_ABORTRETRYIGNORE.
;
;     MB_HELP
;     0x00004000L
;
;        
;
;     Adds a Help button To the message box. When the user clicks the Help button Or presses F1, the system sends a WM_HELP message To the owner.
;
;     MB_OK
;     0x00000000L
;
;        
;
;     The message box contains one push button: OK. This is the Default.
;
;     MB_OKCANCEL
;     0x00000001L
;
;        
;
;     The message box contains two push buttons: OK And Cancel.
;
;     MB_RETRYCANCEL
;     0x00000005L
;
;        
;
;     The message box contains two push buttons: Retry And Cancel.
;
;     MB_YESNO
;     0x00000004L
;
;        
;
;     The message box contains two push buttons: Yes And No.
;
;     MB_YESNOCANCEL
;     0x00000003L
;
;        
;
;     The message box contains three push buttons: Yes, No, And Cancel.
;
;     
;
;     To display an icon in the message box, specify one of the following values.
;     Value   Meaning
;
;     MB_ICONEXCLAMATION
;     0x00000030L
;
;        
;
;     An exclamation-point icon appears in the message box.
;
;     MB_ICONWARNING
;     0x00000030L
;
;        
;
;     An exclamation-point icon appears in the message box.
;
;     MB_ICONINFORMATION
;     0x00000040L
;
;        
;
;     An icon consisting of a lowercase letter i in a circle appears in the message box.
;
;     MB_ICONASTERISK
;     0x00000040L
;
;        
;
;     An icon consisting of a lowercase letter i in a circle appears in the message box.
;
;     MB_ICONQUESTION
;     0x00000020L
;
;        
;
;     A question-mark icon appears in the message box. The question-mark message icon is no longer recommended because it does Not clearly represent a specific type of message And because the phrasing of a message As a question could apply To any message type. In addition, users can confuse the message symbol question mark With Help information. Therefore, do Not use this question mark message symbol in your message boxes. The system continues To support its inclusion only For backward compatibility.
;
;     MB_ICONSTOP
;     0x00000010L
;
;        
;
;     A stop-sign icon appears in the message box.
;
;     MB_ICONERROR
;     0x00000010L
;
;        
;
;     A stop-sign icon appears in the message box.
;
;     MB_ICONHAND
;     0x00000010L
;
;        
;
;     A stop-sign icon appears in the message box.
;
;     
;
;     To indicate the Default button, specify one of the following values.
;     Value   Meaning
;
;     MB_DEFBUTTON1
;     0x00000000L
;
;        
;
;     The first button is the Default button.
;
;     MB_DEFBUTTON1 is the Default unless MB_DEFBUTTON2, MB_DEFBUTTON3, Or MB_DEFBUTTON4 is specified.
;
;     MB_DEFBUTTON2
;     0x00000100L
;
;        
;
;     The second button is the Default button.
;
;     MB_DEFBUTTON3
;     0x00000200L
;
;        
;
;     The third button is the Default button.
;
;     MB_DEFBUTTON4
;     0x00000300L
;
;        
;
;     The fourth button is the Default button.
;
;     
;
;     To indicate the modality of the dialog box, specify one of the following values.
;     Value   Meaning
;
;     MB_APPLMODAL
;     0x00000000L
;
;        
;
;     The user must respond To the message box before continuing work in the window identified by the hWnd parameter. However, the user can move To the windows of other threads And work in those windows.
;
;     Depending on the hierarchy of windows in the application, the user may be able To move To other windows within the thread. All child windows of the parent of the message box are automatically disabled, but pop-up windows are Not.
;
;     MB_APPLMODAL is the Default If neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified.
;
;     MB_SYSTEMMODAL
;     0x00001000L
;
;        
;
;     Same As MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. Use system-modal message boxes To notify the user of serious, potentially damaging errors that require immediate attention (For example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those associated with hWnd.
;
;     MB_TASKMODAL
;     0x00002000L
;
;        
;
;     Same As MB_APPLMODAL except that all the top-level windows belonging To the current thread are disabled If the hWnd parameter is NULL. Use this flag when the calling application Or library does Not have a window handle available but still needs To prevent input To other windows in the calling thread without suspending other threads.
;
;     
;
;     To specify other options, use one Or more of the following values.
;     Value   Meaning
;
;     MB_DEFAULT_DESKTOP_ONLY
;     0x00020000L
;
;        
;
;     Same As desktop of the interactive window station. For more information, see Window Stations.
;
;     If the current input desktop is Not the Default desktop, MessageBox does Not Return Until the user switches To the Default desktop.
;
;     MB_RIGHT
;     0x00080000L
;
;        
;
;     The text is right-justified.
;
;     MB_RTLREADING
;     0x00100000L
;
;        
;
;     Displays message And caption text using right-To-left reading order on Hebrew And Arabic systems.
;
;     MB_SETFOREGROUND
;     0x00010000L
;
;        
;
;     The message box becomes the foreground window. Internally, the system calls the SetForegroundWindow function For the message box.
;
;     MB_TOPMOST
;     0x00040000L
;
;        
;
;     The message box is created With the WS_EX_TOPMOST window style.
;
;     MB_SERVICE_NOTIFICATION
;     0x00200000L
;
;        
;
;     The caller is a service notifying the user of an event. The function displays a message box on the current active desktop, even If there is no user logged on To the computer.
;
;     Terminal Services: If the calling thread has an impersonation token, the function directs the message box To the session specified in the impersonation token.
;
;     If this flag is set, the hWnd parameter must be NULL. This is so that the message box can appear on a desktop other than the desktop corresponding To the hWnd.
;
;     For information on security considerations in regard To using this flag, see Interactive Services. In particular, be aware that this flag can produce interactive content on a locked desktop And should therefore be used For only a very limited set of scenarios, such As resource exhaustion.
;
;     
;
; Return value
;
; Type: int
;
; If a message box has a Cancel button, the function returns the IDCANCEL value If either the ESC key is pressed Or the Cancel button is selected. If the message box has no Cancel button, pressing ESC has no effect.
;
; If the function fails, the Return value is zero. To get extended error information, call GetLastError.
;
; If the function succeeds, the Return value is one of the following menu-item values.
; Return code/value   Description
;
; IDABORT
; 3
;
;    
;
; The Abort button was selected.
;
; IDCANCEL
; 2
;
;    
;
; The Cancel button was selected.
;
; IDCONTINUE
; 11
;
;    
;
; The Continue button was selected.
;
; IDIGNORE
; 5
;
;    
;
; The Ignore button was selected.
;
; IDNO
; 7
;
;    
;
; The No button was selected.
;
; IDOK
; 1
;
;    
;
; The OK button was selected.
;
; IDRETRY
; 4
;
;    
;
; The Retry button was selected.
;
; IDTRYAGAIN
; 10
;
;    
;
; The Try Again button was selected.
;
; IDYES
; 6
;
;    
;
; The Yes button was selected.
;
; 
; Remarks
;
; The following system icons can be used in a message box by setting the uType parameter To the corresponding flag value.
; Icon   Flag values
; Icon For MB_ICONHAND, MB_ICONSTOP, And MB_ICONERROR   MB_ICONHAND, MB_ICONSTOP, Or MB_ICONERROR
; Icon For MB_ICONQUESTION   MB_ICONQUESTION
; Icon For MB_ICONEXCLAMATION And MB_ICONWARNING   MB_ICONEXCLAMATION Or MB_ICONWARNING
; Icon For MB_ICONASTERISK And MB_ICONINFORMATION   MB_ICONASTERISK Or MB_ICONINFORMATION
;
; 
;
; Adding two right-To-left marks (RLMs), represented by Unicode formatting character U+200F, in the beginning of a MessageBox</span> display string is interpreted by the <span class="posthilit">MessageBox</span> rendering engine so As To cause the reading order of the <span class="posthilit">MessageBox To be rendered As right-To-Left (RTL).
;
; When you use a system-modal message box To indicate that the system is low on memory, the strings pointed To by the lpText And lpCaption parameters should Not be taken from a resource file because an attempt To load the resource may fail.
;
; If you create a message box While a dialog box is present, use a handle To the dialog box As the hWnd parameter. The hWnd parameter should Not identify a child window, such As a control in a dialog box.
;}

M.

Re: MessageRequester personnalisé

Publié : dim. 12/juin/2016 22:22
par digital
Y'a aussi le code de Wolf en alternative:
http://forums.purebasic.com/english/vie ... 71&start=0

Re: MessageRequester personnalisé

Publié : lun. 13/juin/2016 9:05
par case
j'avais fait celui la en 2009 aussi

Code : Tout sélectionner

;----------------------------------------------------------------------
;boite de dialogue comme en gfa sur atari st
;syntaxe : requester(titre$,texte$,reponses$[,image])
;le titre de la fenetre est une chaine de caractere normale
;le texte est multiligne les lignes sont séparées par le caractere |
;le nombre de reponses possible est illimité (sauf par la taille de l'ecran)
;chaque bouton est delimité par le caractere |
;il est posible de specifier une image comme icone elle sera positionée en haut a gauche de la fenetre
;---------------------------------------------------------------------
;auteur Case,forums pure basic.  domaine public
Procedure requester(req_title$,req_txt$,req_reply$,req_icon=0)
  req_lines=CountString(req_txt$,"|")+1
  req_winheight=req_lines*16
  ; verifie la plus grande longueur de chaine dans le résumé
  For req_a=1 To req_lines
    req_l=Len(StringField(req_txt$,req_a,"|"))
    If req_mx<req_l
      req_mx=req_l
    EndIf
  Next
  ;verrifie si le contenu des boutons au total est plus grand que laplus grande des chaines
  If req_mx<Len(req_reply$)+2
    req_mx=Len(req_reply$)+2
  EndIf
  ;verifie la presence d'une image en tant qu'icone et modifie la taille de la fenetre en focntion
  If req_icon<>0
    req_icon_h=ImageHeight(req_icon)+4
    req_icon_w=ImageWidth(req_icon)+4
    If req_winheight<req_icon_h
      req_winheight=req_icon_h
    EndIf
  Else
    req_icon_h=0
    req_icon_w=0
  EndIf
  ;ouvre la fenetre
  req_main=OpenWindow(#PB_Any,0,0,req_mx*6+req_icon_w,req_winheight+20,req_title$,#PB_Window_TitleBar| #PB_Window_ScreenCentered)
  ;ecrit les lignes de texte
  For req_a=0 To req_lines-1
    TextGadget(#PB_Any,req_icon_w,req_a*16,req_mx*6,16,StringField(req_txt$,req_a+1,"|"))
  Next
  ;cree les boutons
  req_nb_b=CountString(req_reply$,"|")+1
  NewList req_buttons()
  req_butsize=(WindowWidth(req_main))/req_nb_b
  For req_a=1 To req_nb_b
    AddElement(req_buttons())
    req_buttons()=ButtonGadget(#PB_Any,(req_a-1)*req_butsize,req_winheight,req_butsize,20,StringField(req_reply$,req_a,"|"))
  Next

  Repeat
    If req_icon<>0
      StartDrawing(WindowOutput(req_main))
      DrawImage(ImageID(req_icon),0,0)
      StopDrawing()
    EndIf
    req_ev=WaitWindowEvent()
  Until req_ev=#PB_Event_Gadget
  ForEach req_buttons()
    If req_buttons()=EventGadget()   
       req_ret=ListIndex(req_buttons())
       ClearList(req_buttons())
       CloseWindow(req_main)
      ProcedureReturn  req_ret+1 ; pour eviter de renvoyer un zero
    EndIf
  Next
      ProcedureReturn 0 ; erreur
EndProcedure
  ; exemple d'utilisation
  UsePNGImageDecoder()
  img=LoadImage(#PB_Any,"Image2.png") ; charger une image pour l'exemple
  ;
  reply=requester("boite d'alerte GFA like","enorme j'en ai révé|c'est a ma portée enfin|et super flexible","ok|mitho|lol")
  Select reply
  Case 1
    requester("fin du programme","jeul savais","ok",img)
  Case 2
    requester("Mitho","comment ca mitho ?","je m'excuse",img)
  Case 3
    requester("lol ?", "rien d'amusant la dedans","pas drole",img)
  EndSelect


Re: MessageRequester personnalisé

Publié : sam. 18/juin/2016 17:54
par JohnJohnsonSHERMAN
Sinon y'a toujours les constantes de l'api windows pour les icones et les différents boutons, ici... 8)
Ca peut toujours servir et c'est plus rapide si on veut juste faire un message d'erreur ou avec des boutons différents, le tout sans se prendre 100 lignes de code dans la tronche (oui je sais je suis trés flemmard... :roll: )