msgbox that you can position where you want relative to the cursor

CJ_London

Super Moderator
Staff member
Local time
Today, 02:10
Joined
Feb 19, 2013
Messages
16,968
There have been a few recent posts about msgboxes, so I thought I would share what I use.

Unlike inputboxes the msgbox does not have parameters to specify the top/left position - typically a msgbox appears mid screen and often well away from where the user is actually working. The problem is a msgbox has to be dialog to ensure it sits on top and stop further code running. So any changes to position have to done once the message form is open and consequently cannot be done by the calling code.

The attached is something I developed a while ago and have now extracted from the app it was used in to provide a demo. It has a limited range of options (although has been sufficient for my needs) but can easily be extended if required - see notes in the modules.
1724522387315.png


1724522443403.png


The function is called with one line of code as per msgbox and returns a result as per msgbox. The parameters are pretty much the same as msgbox.

pStr = txtHeader & ";" & txtMessage & ";" & Choose(fOptions, "vbOKOnly", "vbOKCancel", "vbYesNo", "vbYesNoCancel", "vbRetryCancel") & Choose(fImages, "", "+vbCritical", "+vbExclamation")
MsgBox "returns the vbNumber " & MsgBoxResult(pStr)


Hope some of you find it useful
 

Attachments

Users who are viewing this thread

Back
Top Bottom