Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MessageBox with checkbox - API?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00814729
Message ID:
00814789
Views:
16
This message has been marked as the solution to the initial question of the thread.
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.nTimeout = 5

? oMb.Show(), oMb.nCheckBoxValue

RETURN
...
* MbxClass.prg
#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
	* Center Message Box in The Parent Window (hWnd property)
	lCentered = .F.
	* Center Message Box text for multi-line message
	lCenteredText = .F.
	* Right aligned buttons
	lRightButtons = .F.
	* Timeout
	nTimeout = 0
	* Check box text
	cCheckboxText = ""
	* Check box value - 0 or 1
	nCheckboxValue = 0
	* Checkbox positio X and Y. Cannot be used with lCentered 
	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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform