Page 1 of 1

Message Requester with context Help button on Windows.

Posted: Sun Dec 21, 2008 2:24 am
by Rescator
This quick example shows how to use MessageBoxIndirect_()
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
which lets you add a 4th button, a context sensitive (through a id you optionally can pass) Help button.

Would be really cool to see a PureBasic's own MessageRequestere extended to provide a similar feature, however I hope you enjoy this code anyway.

Code: Select all

EnableExplicit

#MB_HELP=$00004000
#MB_DEFBUTTON4=$00000300

Procedure.l MessageRequesterIndirect_Callback(*lpHelpInfo.HELPINFO)
 MessageRequester("Help","Help Text")
 ;the HELPINFO struct lets you do more advanced stuff here,
 ;like serving help for multiple requesters, use mbox\dwContextHelpId to pass along a help id.
 ;See http://msdn.microsoft.com/en-us/library/ms645511%29VS.85%29.aspx for more
EndProcedure

Procedure.l MessageRequesterIndirect(title$,message$,flags.l=#Null,parent.i=#Null)
 Protected result.l,mbox.MSGBOXPARAMS
 mbox\cbsize=SizeOf(MSGBOXPARAMS)
 mbox\hwndOwner=WindowID(parent)
 mbox\hInstance=#Null
 mbox\lpszText=@message$
 mbox\lpszCaption=@title$
 mbox\dwStyle=#MB_SETFOREGROUND|#MB_TOPMOST|#MB_APPLMODAL|flags
 mbox\lpszIcon=#Null
 mbox\dwContextHelpId=#Null
 mbox\lpfnMsgBoxCallback=@MessageRequesterIndirect_Callback()
 mbox\dwLanguageId=#Null
 result=MessageBoxIndirect_(mbox)
 ProcedureReturn result
EndProcedure

#Window_Main=1
Define event.l,quit.l
If OpenWindow(#Window_Main,100,200,195,260,"PureBasic Window",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
 Debug MessageRequesterIndirect("Title","Message",#MB_ABORTRETRYIGNORE|#MB_HELP|#MB_DEFBUTTON4|#MB_ICONQUESTION,#Window_Main)
 Repeat
  event=WaitWindowEvent()
  Select event
   Case #PB_Event_CloseWindow
   quit=#True
  EndSelect
 Until quit
EndIf

End

Posted: Sun Dec 21, 2008 2:52 am
by SFSxOI
Very nice, thank you . :)

(BTW - the MS link is no good - should it be: http://msdn.microsoft.com/en-us/library ... S.85).aspx)

Posted: Sun Dec 21, 2008 3:25 am
by Rescator
Fixed the link. since the forum mess up the () in urls I've started to use %28 and %29 heh.

Posted: Sun Dec 21, 2008 5:09 am
by rsts
Nice and useful.

Thanks for sharing. :)

cheers