In a conference like Direcionts EMEA, I noticed again how interested people can be in sometimes such a simple solution. In our company, we implement every installation with a default set of tools (enhancements). One of these tools is a very simple and little something called "Database Info"-form.
The goal is to differentiate what kind of database you logged in: Test Database, a Test Company, a Development Database, ... . Actually, you just want a visual difference between two environments. In the old days (version 3.X and less), we had a menu, which we could give a certain color, caption or whatever. Now, we don't have a form that pops up, so no form we can modify. I present to you a little solution that might be able to help you with this, and the end result looks like this:
The red area, just right from the menu suite, is the "solution" I'm talking about - in case it was not clear . To accomplish the main idea, there are only three things you have to do:
IF GUIALLOWED THEN FORM.RUN(FORM::"Database Info");
That's basically all. Easy, isn't it?
But let's make it somewhat more useful and generic. Let's put some info on the form, work with colors and make that configurable ... So that the result is somewhat more like above:
CLEAR(recDatabaseInfoSetup); IF recDatabaseInfoSetup.GET THEN IF recDatabaseInfoSetup."Show Database Info Form" THEN IF GUIALLOWED THEN FORM.RUN(FORM::"Database Info");
The main idea is to "generate" the form when we are opening it. We'll set the colors, fill in the fields, make the form the right size and put it in it's place. Actually, the design on the form might even look like this (it doesn't matter):
//FIXED WIDTH AND HEIGHT. I CHOSE THESE VALUES: lintFormWidth := 10960; lintFormHeight := 4647;
//RESET SHAPE VALUES CurrForm.Blue.VISIBLE:=FALSE; CurrForm.Red.VISIBLE:=FALSE; //... //YOU CAN ADD THE REST OF THE COLORS IN THE SAME WAY
//MOVE SHAPES CASE recDatabaseInfoSetup.Color OF recDatabaseInfoSetup.Color::Red: BEGIN CurrForm.Red.VISIBLE:=TRUE; CurrForm.Red.XPOS := 0; CurrForm.Red.YPOS := 0; CurrForm.Red.WIDTH := lintFormWidth; CurrForm.Red.HEIGHT := lintFormHeight; END; recDatabaseInfoSetup.Color::Blue: BEGIN CurrForm.Blue.VISIBLE:=TRUE; CurrForm.Blue.XPOS := 0; CurrForm.Blue.YPOS := 0; CurrForm.Blue.WIDTH := lintFormWidth; CurrForm.Blue.HEIGHT := lintFormHeight; END; //... //YOU CAN ADD THE REST OF THE COLORS IN THE SAME WAY END;
//RESIZE FORM CurrForm.WIDTH := lintFormWidth; CurrForm.HEIGHT := lintFormHeight;
It all comes down on resizing the form and resizing shapes.
//recLicense (Record of the table "License Information") recLicense.SETRANGE("Line No.",5,6); IF recLicense.FIND('-') THEN REPEAT IF recLicense.Text <> '' THEN txtlicense[recLicense."Line No."] := COPYSTR(recLicense.Text, 27, STRLEN(recLicense.Text)-26); UNTIL recLicense.NEXT = 0;
With txtlicense and txtLicense you can find your license information.
CLEAR(lrecSession); IF lrecSession.RECORDLEVELLOCKING THEN lrecSession.SETFILTER("Application Name",'@*NAV*'); intSessionCount := lrecSession.COUNT;
lrecSession.SETRANGE("My Session", TRUE); IF lrecSession.FINDFIRST THEN BEGIN txtUserID := lrecSession."User ID"; txtDatabaseName := lrecSession."Database Name"; END ELSE BEGIN txtUserID := ''; txtDatabaseName := ''; END;
This way, you also get the full login (with domain) when logged in with Windows Authentication ... Which I prefer.
Voilà, that's all. Not really "hocus pocus". Just simple and effective.
Hope you like it.
Do you have a text file of the object that you could share?
Yes Eric, this is a nice simple and neat solution to a very commonly requested issue.
Thanks for sharing it.
I've already sent a link to this blog to customers :)
o-ow, I hope they like it .
I have no .txt available. If you just follow the description, it won't take long, I guess... (I hope).
Great tip. So simple and yet so useful. It's funny how often the best solutions are the simplest.
I'll start using it with all my customers from now on!
The best solutions are simplest - this is really neat and really useful - thanks a lot
I love this tip and have been playing about with it. I've added a couple of extra features and I'll post something about it when it's done, but I have a question. Is there any way of stopping someone from clicking on the form and pressing ESC which then closes it? Other than setting Close Forms on Esc to No. I tried putting EXIT(FALSE) in the or putting something in the OnQueryCloseForm() but that is BAAAAD and you can't exit the company or NAV. Any ideas?
@Gaspode: I have been strugling with that myself and I don't see a solution (yet). The only way (for now) is to change the option "Close Forms On Esc" to "No".
But honestly, we don't do that.
Hi it's me again. OK so I had a go at doing some things with this idea. If you're interested, take a look at my post on gaspodethewonderdog.blogspot.com/.../where-am-i.html
I did come across a few issues so maybe some of the clever readers of your blog could answer the bits that don't work. Thanks for the inspiration and thanks heaps for posting the idea. Cheers, Dave.
When I do this, my shapes seem to be on top of the textboxes (so I cannot see the text) - I know I am missing something simple...
You need to add the shapes first - then the labels afterwards, and then the labels will appear on top of the shapes instead of being hidden :)
Thanks for posting the answer. I was going to try this out ... but you were too quickly.