Wednesday, May 8, 2013

Visual Studio 2012 Issue: No color icons


The UPPERCASE MENUS in Visual Studio 2012 don't really bother me like they seem to bother everyone else. What gets to me is the lack of color. Every time I try to click the Save icon I end up clicking the Open File icon. Without color, they just look too much alike:
 For comparison, here's what they looked like in VS 2010:


Tuesday, March 12, 2013

Better Looking PowerBuilder Applications, Part 1

I've been working with PowerBuilder for close to a decade now. In that time I've seen PB developers create some screens that, while they functioned properly, could have been ….. a little nicer looking. 

In this blog post I briefly go over a few things that, IMHO, can help you create better looking PowerBuilder apps. I plan on writing a series of blog posts that expand on each of these items. I'll update this post with links to the other posts as they become available. 

Standard disclaimer: I'm not a graphics designer nor do I play one on TV. Take what I say with a grain of salt. 

Color

Probably the simplest thing you can do to make a PowerBuilder application look better is to add a bit of color. Just don't overdo it. You want to make the screen visually appealing without it becoming a distraction. 



Icons

The second thing you can do to make your PB apps look better is to add some icons. Although PowerBuilder comes with several built in, I generally prefer to use some of the ones freely available on the Internet. Smashing Magazine is a good place to find these. Just be sure to check that the license allows commercial usage.


Gradients

Much like the use of color, gradients can add a subtle improvement to your PowerBuilder application. But (as with color) you have to be careful not to overdo it and end up with something that distracts from the application's usefulness. Think Goldilocks here: 


Grouping

Grouping may seem out of place in a post with Gradients, Colors and Icons. But it's still a visual way to make it easier to digest the information your application is conveying.


Alternating Row Colors

I almost didn't mention this one because I figured most PB developers already know about it. 




Thursday, April 19, 2012

PowerBuilder and SQL Server: Tips On Working Together

I recently worked on a project that used PowerBuilder for the front end and SQL Server for the database. I've worked with both of these technologies in the past but this was the first time I used them together. Below are some notes about the things that I learned regarding PB and SQL Server working together.

Single Quoted Strings
If you do any work with SQL statements in SQL Server Management Studio (SSMS), you'll find that SQL Server only accepts strings if they are surrounded by single quotes. You can use double quotes in the PowerBuilder painters and they'll get translated properly on their way to SQL Server. But you may want to just go ahead and use single quotes everywhere, especially if you are trying to track down a problem by copying SQL from PowerBuilder and pasting it into SSMS.


Identity Columns
One of my tables had its primary key set in SQL Server to autoincrement. In my datawindow I would insert a row and then do an update. I was expecting the value SQL Server assigned to the primary key column to appear in my datawindow. However, this didn't happen -- at least not reliably -- until I changed my connection string. I had to add Identity='@@IDENTITY':

Database='DATABASENAME',Provider='SQLNCLI10',Identity='@@IDENTITY'


Bit fields

I had one of my fields defined in SQL Server as a bit. If you looked at the data in SSMS you would see this represented as 1s and 0s. However, when accessing this data from PowerBuilder, every 1 was being converted to a -1. Since I was in control of the schema, I changed the field to tinyint to solve the problem. Of course, if you don't have control of the database layout, I'm not sure how you would handle that.

Files Required
On your client machines, in addition to the PB runtimes (including PBSNC120.dll, which is for SQL Server), you also need to install the SQL Server Native Client runtime. These come as an msi installer package from Microsoft. When you install the SQL Server client, you'll need to do so as an administrator. Otherwise you'll get a cryptic error message along the lines of "0: -1".

There's a 32-bit and a 64-bit version of the runtime. The 64-bit version won't run on a 32-bit version of Windows and vice versa.



Footnote: My project used PowerBuilder Classic version 12.1 and SQL Server 2008

Monday, March 19, 2012

A PowerBuilder Color Function


While I was working on my PowerBuilder Color Chart, I started thinking about how we use color values in PB datawindow expressions.

If you wanted to give every other row in a datawindow a gray background, you might put something like this in the detail band's background expression:
if (mod(getrow(), 2) = 0, 16777215, 8421504))
But you'd have to know that 16777215 represents white and 8421504 is the number for gray.

A lot of developers take the next step and use the RGB function:
if (mod(getrow(), 2) = 0, RGB(255, 255, 255), RGB(128, 128, 128))
Here you specify the Red, Green and Blue values for the color you want and the RGB function returns the proper number.

It's still not very easy to tell at a glance what the color is, but it's certainly easier than the first expression.

I wanted an easier way to specify a color. So I created a new function, f_color. You pass it one of the PowerBuilder color names and it will return the proper number. For example, our alternate row highlighting expression now becomes:
if (mod(getrow(), 2) = 0, f_color("White"), f_color("Gray"))
Plus, you can now do things like use Transparent and the Window colors:
if (mod(getrow(), 2) = 0, f_color("Transparent"), f_color("Button Face"))
I've made it available here. Just select File -> Download from the Google Docs page that appears.