* References: * MessageBoxIndirect Function * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/DialogBoxes/DialogBoxReference/DialogBoxFunctions/MessageBoxIndirect.asp * MSGBOXPARAMS Structure * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxstructures/msgboxparams.asp * MessageBoxEx Function * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/messageboxex.asp * LoadIcon Function * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/icons/iconreference/iconfunctions/loadicon.asp * LoadImage Function * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/loadimage.asp * Needs rAPIdStructure class of file rpstruct.prg in * same directory as this prg, or in path, download from UT #Define GWL_HINSTANCE -6 #Define MB_ABORTRETRYIGNORE 0x2 #Define MB_CANCELTRYCONTINUE 0x6 #Define MB_HELP 0x4000 #Define MB_OK 0x0 #Define MB_OKCANCEL 0x1 #Define MB_RETRYCANCEL 0x5 #Define MB_YESNO 0x4 #Define MB_YESNOCANCEL 0x3 #Define MB_USERICON 0x80 #Define MB_ICONEXCLAMATION 0x30 #Define MB_ICONWARNING MB_ICONEXCLAMATION #Define MB_ICONASTERISK 0x40 #Define MB_ICONINFORMATION MB_ICONASTERISK #Define MB_ICONQUESTION 0x20 #Define MB_ICONHAND 0x10 #Define MB_ICONSTOP MB_ICONHAND #Define MB_ICONERROR MB_ICONHAND #Define IDI_APPLICATION 32512 #Define IDI_HAND 32513 #Define IDI_QUESTION 32514 #Define IDI_EXCLAMATION 32515 #Define IDI_ASTERISK 32516 #Define IDI_WINLOGO 32517 #Define IDI_ERROR IDI_HAND #Define IDI_INFORMATION IDI_ASTERISK #Define IDI_WARNING IDI_EXCLAMATION #Define MB_DEFBUTTON1 0x0 #Define MB_DEFBUTTON2 0x100 #Define MB_DEFBUTTON3 0x200 #Define MB_DEFBUTTON4 0x300 #Define MB_APPLMODAL 0x0 #Define MB_SYSTEMMODAL 0x1000 #Define MB_TASKMODAL 0x2000 #Define MB_RIGHT 0x80000 #Define MB_SETFOREGROUND 0x10000 #Define MB_TOPMOST 0x40000 #Define LANG_NEUTRAL 0x0 #Define IMAGE_ICON 1 #Define LR_LOADFROMFILE 0x10 #Define LR_DEFAULTSIZE 0x40 Clear Declare Integer GetWindowLong In user32; INTEGER HWnd,; INTEGER nIndex Declare Integer MessageBoxIndirect In user32; STRING @ lpMsgBoxParams Declare Integer LoadImage In user32; INTEGER hinst,; STRING lpszName,; INTEGER uType,; INTEGER cxDesired,; INTEGER cyDesired,; INTEGER fuLoad Local cOldDefault m.cOldDefault = Set("Default") Set Default To Justpath(Sys(16)) Local cIconFile, lpszIcon, hInstance m.hInstance = GetWindowLong(Application.HWnd,GWL_HINSTANCE) *m.cIconFile = Getpict("ICO") *m.lpszIcon = 105 *LoadImage(hInstance, cIconFile, IMAGE_ICON, 0, 0,Bitor(LR_LOADFROMFILE,LR_DEFAULTSIZE)) Local oMsgBoxParams, cMsgBoxParamsDef, clpMsgBoxParams * Create Structure: oMsgBoxParams = Newobject("rAPIdStructure","rpstruct.prg") * Pass Structure definition to Structure Object: TEXT to cMsgBoxParamsDef NOSHOW Type MSGBOXPARAMS cbSize As Long hwndOwner As Long hInstance As Long lpszText As String lpszCaption As String dwStyle As Long lpszIcon As Long dwContextHelpId As Long lpfnMsgBoxCallback As Long dwLanguageId As Long End Type ENDTEXT * Load Struc in Struc Object: oMsgBoxParams.LoadVBDef(m.cMsgBoxParamsDef) * Assign Values to Struct: With oMsgBoxParams .hwndOwner = Application.HWnd && Application.HWnd or 0 for Desktop .hInstance = m.hInstance && or 0 for normal icons .lpszText = "Text of the messagebox" + Chr(0) .lpszCaption = "Title of the messagebox" + Chr(0) .dwStyle = Bitor(MB_OKCANCEL, MB_USERICON, MB_TOPMOST,MB_SETFOREGROUND,MB_APPLMODAL) *.lpszIcon = m.lpszIcon .dwContextHelpId = 0 .lpfnMsgBoxCallback = 0 .dwLanguageId = LANG_NEUTRAL Endwith Local N * Display Messagebox with VFP resource Icons: For N = 101 To 110 With oMsgBoxParams .lpszIcon = m.n .lpszText = "VFP Runtime Icon Resource # : " + Str(m.n) .cbSize = .CalculateBytes() Endwith * Assign Struc to String: clpMsgBoxParams = oMsgBoxParams.MakeStruct() ?MessageBoxIndirect(@clpMsgBoxParams) Endfor * Display Messagebox with Windows resource Icons: oMsgBoxParams.hInstance = 0 For N = 32512 To 32517 With oMsgBoxParams .lpszIcon = m.n .lpszText = "Windows Icon Resource # : " + Str(m.n) .cbSize = .CalculateBytes() Endwith * Assign Struc to String: clpMsgBoxParams = oMsgBoxParams.MakeStruct() ?MessageBoxIndirect(@clpMsgBoxParams) Endfor Set Default To (m.cOldDefault)