Message Requester with context Help button on Windows.

Share your advanced PureBasic knowledge/code with the community.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Message Requester with context Help button on Windows.

Post 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
Last edited by Rescator on Sun Dec 21, 2008 3:24 am, edited 1 time in total.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post 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)
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Fixed the link. since the forum mess up the () in urls I've started to use %28 and %29 heh.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Nice and useful.

Thanks for sharing. :)

cheers
Post Reply