Hi Mark,
Here's a working prototype of the class wrapper around GSmessagebox. Feel free to adapt it to your requirements
#DEFINE GS_MSGBOX_CENTER 1
#DEFINE GS_MSGBOX_KILLTIMER 2
#DEFINE GS_MSGBOX_CENTER_TEXT 4
#DEFINE GS_MSGBOX_CHECKBOX 8
#DEFINE GS_MSGBOX_RIGHT_BUTTONS 16
#DEFINE GS_MSGBOX_SET_POS 32
lcCrLf = CHR(13) + CHR(10)
PUBLIC oMb AS MessageBoxX OF MbxClass.prg
oMb = NEWOBJECT("MessageBoxX", "MbxClass.fxp")
oMb.nType = 4+16
oMb.cText = "Message Text Message Text Message " + lcCrLf + "Text Message Text "
oMb.cCaption = "Window Title"
oMb.cCheckboxText = "Click me!"
oMb.nCheckBoxValue = 1
? oMb.Show(), oMb.nCheckBoxValue
RETURN
...
#DEFINE GS_MSGBOX_CENTER 1
#DEFINE GS_MSGBOX_KILLTIMER 2
#DEFINE GS_MSGBOX_CENTER_TEXT 4
#DEFINE GS_MSGBOX_CHECKBOX 8
#DEFINE GS_MSGBOX_RIGHT_BUTTONS 16
#DEFINE GS_MSGBOX_SET_POS 32
DEFINE CLASS MessageBoxX AS Custom
oHeap = Null
lCentered = .F.
lCenteredText = .F.
lRightButtons = .F.
nTimeout = 0
cCheckboxText = ""
nCheckboxValue = 0
nXpos = 0
nYpos = 0
hWnd = 0
cText = ""
cCaption = ""
nType = 0
nFlags = 0
PROCEDURE Show
LOCAL lnCheckBoxText, lnChekboxValue, lnResult, lcMsgBoxOpt
DO CASE
CASE This.lCentered
This.nFlags = BITOR(This.nFlags, GS_MSGBOX_CENTER)
CASE This.nXpos > 0 OR This.nYpos > 0
This.nFlags = BITOR(This.nFlags, GS_MSGBOX_SET_POS)
ENDCASE
IF This.lRightButtons
This.nFlags = BITOR(This.nFlags, GS_MSGBOX_RIGHT_BUTTONS)
ENDIF
IF This.lCenteredText
This.nFlags = BITOR(This.nFlags, GS_MSGBOX_CENTER_TEXT)
ENDIF
IF This.nTimeout > 0
This.nFlags = BITOR(This.nFlags, GS_MSGBOX_KILLTIMER)
ENDIF
IF NOT EMPTY(This.cCheckboxText)
This.nFlags = BITOR(This.nFlags, GS_MSGBOX_CHECKBOX)
ENDIF
IF BITAND(This.nFlags, GS_MSGBOX_CHECKBOX) > 0
lnCheckBoxText = This.oHeap.AllocString(This.cCheckboxText)
lnChekboxValue = This.oHeap.AllocBlob(NumToLong(This.nCheckboxValue))
ELSE
lnCheckBoxText = 0
lnChekboxValue = 0
ENDIF
lcMsgBoxOpt = NumToLong(28) + ;
NumToLong(This.nFlags) + ;
NumToLong(This.nTimeout) + ;
NumToLong(lnCheckBoxText) + ;
NumToLong(lnChekboxValue) + ;
NumToLong(This.nXpos) + ;
NumToLong(This.nYpos)
lnResult = GSMessageBox(This.hWnd, ;
This.cText, This.cCaption, This.nType, lcMsgBoxOpt)
IF BITAND(This.nFlags, GS_MSGBOX_CHECKBOX) > 0
This.nCheckboxValue = LongToNum(This.oHeap.CopyFrom(lnChekboxValue ))
This.oHeap.Dealloc(lnChekboxValue)
This.oHeap.Dealloc(lnCheckBoxText)
ENDIF
RETURN lnResult
ENDPROC
PROCEDURE INIT
DECLARE Long GSMessageBox IN GSMessageBox.dll ;
Long hWnd, String lpText, String lpCaption, ;
Long uType, STRING @ lpMsgBoxOpt
SET PROCEDURE TO clsHeap ADDITIVE
This.oHeap = NEWOBJECT("heap", "clsheap.fxp")
ENDPROC
PROCEDURE Destroy
This.oHeap = Null
ENDPROC
ENDDEFINE
>Hi,
>
>I'm looking for a messagebox replacement for VFP7 that will allow me to display a checkbox along with the other standard messagebox capabilities. I found this one:
>
http://www.gipsysoft.com/messagebox/>But it requires passing a pointer to a memory location as part of a structure that is passed to the DLL. I've downloaded the heap class from UT, but would rather not delve into that if there's a better alternative out there.
>
>Note: I initially rolled my own VFP class to handle this, but found that since it's a VFP form also, it's causing undesired events to fire (calling form's deactivate, if called from grid, it's when fires when dialog dismissed, etc.) So, I don't believe a VFP form will give me what I need.
>
>I also rolled my own to invoke a VFP form via COM, but it invokes very slowly and seems to block repainting of the underlying form when moved.
>
>I really appreciate all your help.
>Best,
>Mark Nadig
--sb--