VISUAL BASIC MESSAGE POTATO VISUAL BASIC MESSAGE POTATO VISUAL BASIC MESSAGE POTATO Program and documents ©1994 by David Stewart INTRODUCTION--WHAT VBMP DOES The Visual Basic Message Potato is a simple program that makes an irritating task a lot easier: Making Visual Basic message boxes. You now won't have to memorize or look up the syntax and constants, etc., just to create a little message. I've seen two, maybe three other programs that do some of the things this one does; you probably have, too. Mine is--I believe, with all due humility--better. VBMP is meant to be used while you're in the VB coding environment, though it could be used outside it. It is an interactive coding tool. How so? When you have specified your message box in VBMP, you can click the "> Code Window" button, and VBMP will find the topmost code window and enter into it, at the current insertion point location, code for the message box you needed. Voilą. If you're not in the VB design environment, you can use VBMP to specify a message box and then copy the specs to the Clipboard. Then you can paste it into the editor you're using at the moment--useful when you use a code editor like VBAssist's Code Library or Mark Towslee's Visual Basic Project Manager or Paul Bonner's Code Librarian or... A lot of things are easier with VBMP. As you build your message box, VBMP assists with context-sensitive option cues, lets you see your message box code as it is constructed, lets you view the message box itself before you commit it to the code window, inserts into the code window a code template for handling user response, and even declares a variable (within the current sub) to receive the user's response if you wish. INSTALLING THE POTATO There are five files: MSGSPUD.EXE, the executable file. THREED.VBX and SSFORMFX.VBX, custom control files. MSGSPUD.TXT, this documentation file; it substitutes for a real Help, too. SPUDREG.TXT, a registration form. Put MSGSPUD.EXE wherever you want to; but put MSGSPUD.TXT in the same directory. Put the .VBX files in the Windows SYSTEM subdirectory; if you already have versions of either of these files, use these versions only if they have more recent dates than the versions you have. Print SPUDREG.TXT and mail it with your check. If you decide to register, that is. Heh heh. WORKING WITH THE MESSAGE POTATO When you fire up the message spud, you'll see a window about yay big with six framed groups of option buttons or text fields (and some rather unusual features; more about this later). These groups let you create the three parameters of the MsgBox statement and function--message, type and title--on the fly with minimum friction. First, PROCEDURE TYPE. You can make it a statement or a function. If you make it a statement, the spud will, when it enters code, simply insert a single line of code with string literals for the message, a numeric sum representing the buttons, default button, icon and modality, and finally a string literal for the message box title. (You can skip the title if you want, and have a blank title line. You can skip the numerics, because they have default values when you open the oven. You can't skip the message text; the 'tater simply won't do anything much without message text.) Make it a function, it'll handle that, too. Note that you can only make it a statement if you want only one button--the "OK" button--in the message box; all other button sets call for some kind of code action in response to the message box, and as soon as you choose one of the other buttons, the Statement option button is disabled (and reenabled if you choose just "OK"). Next, BUTTONS. You choose these according to the purpose of your message to the user, and the options you want available to the user. As you select your button set, you'll see that the DEFAULT BUTTON group automatically changes to reflect the buttons in that set, so that you can very easily select the single default button you want outlined when the message box pops. All the user has to do is hit the space bar or Enter key to select this button. Of course, you'll want some TEXT STRINGS in the box--a message to the user, perhaps a witty title. Go wild. Who says this stuff has to be boring? (Note the "?" button here. It's the button that pops up this file in a text box. Which, if you're now reading this in a text viewer, will give you a reason NOT to delete this file.) The message string limit is 1024 characters; I don't know about the title, but I suspect it's limited only by the practicality of showing it on your user's monitor. In addition, I haven't figured out how to get the Message field to accept and actually enter carriage returns into the message code. If you know, please pass the secret on to me! You can't go anywhere without seeing an ICON these days. Here are four beauties and a sign that you don't want one. You can only choose one. Choose carefully. (By the way, I ran out of access keys for activating items from the keyboard, so you'll note that the No Icon button has no underlined access key. Go ahead and press Alt 0 (zero), though--that's the key I've assigned it.) If you choose to make your dialog System modal, the Stop icon will be disabled; for some reason Windows doesn't allow a Stop icon in a system modal Message. MODALITY? Just how mad do you want to make your product's users? Shut 'em out of the rest of the app--or the rest of windows? It's up to you. Notice that as you make your decisions and type in your text, you can see the code that will be constructed in the panel at the bottom of the window. That's the stuff: Just make your selections from the groups of exclusive options in the frames, type in some text so your users will have some idea what's going on, and click. Click the "> Code Window" button to send the message box directly to the topmost code window. "> Clipboard" will put it on the Windows clipboard. "View MsgBox" shows you your box before you commit to it. And "Exit"... well, "Exit" speaks for itself. When you specify a statement, as discussed above the tuber will simply add a one-line message box definition to your code. When you specify a function, you get more: The Potato will actually enter the function description code, but also add a template for dealing with the user's response to options offered in the message box. And if you wish to declare a response variable, the Potato stands ready: Just check the Dim Response check box under the MsgBox() Function option button, and the Potato will enter all your function code, including template, and then climb to the top of your procedure and declare the variable like so: Dim Response% Handy, huh? By the way, when you click the "> Code Window" or "> Clipboard" body, not only does it handle the code, it iconizes the Potato's window. I figured that you would probably only want to do one message box at a time. Was I wrong? Let me know if I was! In addition, the Enter key will automatically try to send the message box code to the code window (as long as it's not in one of the text fields), and Esc will Exit the program. "AH HAH! I *KNEW* YOU'D WANT SOMETHING IN RETURN!" All this for FREE? Well . . . no. Though you do get it all; I don't believe in crippling my programs. I'd like you to register the Message Potato if you find that you use it regularly. Or irregularly, but enough to count as having "put it in your toolbox." You know, half the time you do message boxes, whatever. I don't ask much: $7.50, in a check. You're a programmer, you know how important it is to see some reward for your labors of labor and love. There's a coupon file if you feel the need to fill something out. A check alone is fine, with a note on the envelope or check's Memo field that it's for the Message Potato. If you want, I'll send you a laser-printed license sheet--it'll be no big deal, and you won't find any codes to unlock secret features. (I mean, this is simple stuff, right?) So if you want it, let me know. If you don't need it, we'll say your cancelled check and your good feelings about supporting shareware are your license, and we'll save a fraction of a tree. Upgrades: I'll probably be making some changes on this thing sometime; I think it's bug- and error-free, but you may find something that doesn't quite work; just let me know and I'll see if I can fix it. But I'm not going to get into shipping upgrades; I do this stuff at night, see. You can use the latest version with no additional charge, and I'll keep the asking price low, so I don't have to ship out stuff to the probable hundreds of thousands of programmers who'll be registering this. (Yes, that's in my dreams.) HOW DID I GET THOSE FUNKY WINDOW EFFECTS? There are a lot of odd little window effects in this, some of which won't be noticeable at first. The weird title bar look and caption effects and the 3D beveling around the main form are pretty obvious, of course. In addition, note that the border is 3D; that it LOOKS sizeable but in fact is not; and that you can drag the window around not only by the weird title bar, but by clicking on any "client" area inside the borders (that isn't covered by another control, as most of the window is) and dragging. All these effects come compliments of Sheridan Software System's Designer Widgets, specifically the SSFORMFX.VBX custom control. I don't want to turn this file into an ad (except for my own program), but 1) I *am* an advertising copywriter by profession, so it's second-nature to me and 2) this set of tools is, like all of Sheridan's stuff, really cool and really well designed. As long as I'm endorsing things, I'll tell you I can no longer even imagine working in Visual Basic without Sheridan's VBAssist. COOPERATION, SUPPORT, POTATO STORIES Hey, are you making some kind of VB utility that would be improved by the addition of something like this little message spud? If you want to incorporate it, let me know and we'll see if we can work something out. You can reach me on CompuServe at address 72122,03562, or on America Online at Doc Yeah. Hope you enjoy and benefit from this program. Oh, yeah. Why Message Potato? It's a long story with not a great deal of meaning or significance. I came up with Code Potato for a utility I'm still working on, last summer. I liked it, and that's about all there is to it. Everyone uses big, high-fallutin' names. I wanted to use something different. ========================================= David Stewart 738 Hathaway Drive Auburn Hills MI 48326