The BAPBUG Journal
Issue #5, December 1999
Welcome to the Baltimore Area PBUG newsletter.
This is the first newsletter of 1999! We are looking forward to having BAPBUG bring many exciting and challenging topics and tools associated with PowerBuilder and the Internet to each and every meeting.
At the December meeting, we held an election for the 1999 officers. The 1999 officers are: President Debbie Arczynski
Vice President Bill Bitman
Secretary Gordon Giffen
Treasurer Fred Grau
Technical Advisors Mark Pfeifer
Greg Dzingeleski * Newsletter Editor
Anne Sola* Web Administrator
Congratulations! Their phone numbers and email addresses can be found at the end of the newsletter.
We have some exciting news! Corporate Technology Partners, a company which offers a full line of client/server and web application development and training services, has sponsored our user group by subscribing, in behalf of all our members, to PowerTimes, an international journal for Client/Server and Intranet/Internet development, focusing on PowerBuilder, Power ++, and PowerJ. However, you must become registered in order to start receiving PowerTimes. You can register on our web site at: www.geocities.com/siliconvalley/bay/8680 and select Meeting Information.
This newsletter is YOUR newsletter! We hope that it is stimulating and helps you in your quest for the answer to the ultimate PowerBuilder question that you have on your mind! By the way, what is your question? You can forward all questions to any of the technical advisors. They are there for you. Their phone numbers and email addresses are listed in the newsletter, along with all of the BAPBUG officers.
We also want to encourage you to submit small, medium, or large articles of interest to the PowerBuilder community along with any "PowerBuilder tips" that have helped you along your way and may help others.
We want to thank Greg Dzingeleski for volunteering to take on the enormous task of organizing and putting together this newsletter. Thanks Greg!
We hope to see you at our next meeting in February and hope to hear from you soon!
Debbie Arczynski
Please take a look at our new web page designed by Anne Sola. It has lots of information about the group itself, the officers, the agenda, events, jobs, and links to other PB web pages. It is located at: www.geocities.com/siliconvalley/bay/8680. If you have any suggestions and/or comments, please contact Anne Sola.
It is here that you can register for PowerTimes, an international journal for Client/Server and Intranet/Internet development, focusing on PowerBuilder, Power ++, and PowerJ. You simply select Meeting Information and you can register for PowerTimes, courtesy of Corporate Technology Partners, a company which offers a full line of client/server and web application development and training services.
Many thanks to Ed Kennedy from Sybase for filling in at the last minute for David Wolf and presenting at our December meeting. Instead of presenting "Building Good Components", which was geared more toward Jaguar, he gave a presentation on the Sybase Enterprise Application Studio, which incorporated PowerBuilder 7.0. We were able to get a glimpse of what is to come with the new version of PowerBuilder.
Next Meeting
Mark Pfeifer with Corporate Technology Partners, will be at the February meeting to present "Building Enterprise Solutions with the Sybase Tools." This presentation will focus on the Sybase tools and their use in developing true enterprise solutions. Mark will discuss the options for moving existing PowerBuilder applications to the Web. Mark will also demonstrate the new Enterprise Application Studio 3.0s products to build an enterprise application.
You will learn how to create reusable PowerBuilder components which can be called from any front-end. Finally, Mark will demonstrate the PowerBuilder Web Deployment Kit which was announced at the 1998 Powersoft User Conference in Los Angeles. The kit is a promising technology that allows any PowerBuilder application to be deployed unmodified to a browser from any standard Windows NT 4.0 server.
Come see why Sybases PowerBuilder is still the leading 4GL development tool for client/server and the enterprise!
Future Meetings
At the April meeting, Bill Bitman will give a presentation on Unified Modeling Language (UML). He plans to discuss what UML is and is not, and the seven different diagrams used in UML. He will be explaining the elements of each diagram, as well as giving an example of each.
Interested in speaking at a future user group meeting?
If you are interested in speaking on a particular subject, or would like to demo your PowerBuilder application that you have been working on, please contact Debbie Arczynski at (410) 796-9461 (or softquip@home.com). There are openings for presentations or demos of any length from 10 minutes to 2 hours. Thanks!
Sybase TechWave Conference 99
August 22 - 26, 1999
Walt Disney World Swan and Dolphin
Orlando, Florida
Sybase is combining the annual Powersoft Conference, the annual International Sybase User Group (ISUG) North American Conference, and the Middleware Technical Summit into one unified event.
You can take advantage of the in-depth training and time-critical information youll find only at this one-of-a-kind event. Each registration fee includes:
Register Early and Save!
Register on or before Friday, May 21, 1999 $ 995
Register between May 22 and June 25, 1999 $1,095
Register after Friday, June 25, 1999 $1,195
Watch your mail this Spring for detailed information about session offerings in the Preliminary Agenda!
Call 1-(508) 652-1008 today for registration information, or visit the TechWave Conference 99 Web site at www.sybase.com/techwave99.
How to put a working icon on the task bar
by Greg Dzingeleski
In this article Id like to describe how to put an icon in the windows task
bar. The task bar is the bar, usually at the bottom of the screen with the Start button,
"buttons" for open applications and what I believe is called the system tray.
The system tray has the clock and maybe some icons. Usually a speaker icon (speaker from a
stereo, not like Newt Gingrich) appears there if you have a sound card. Many of these
icons will put up a popup menu if you right click on them. This is the kind of thing
Id like to make for an application Im writing.
Im writing a utility to help in testing another application Im working on. I want the utility to find social security numbers in our database and put them in a popup menu that I can access from the task bar icon. When I select the menu item that SSN will be put in the clipboard. Basically Im too lazy and clumsy to type in all the SSNs I use and I decided the task bar icons would be a good place to "store" these numbers.
A task bar icon is created using a windows API call which requires a structure. Another windows API call is needed to get the handle of the icon to use for the task bar icon. Ive done this in NT 4. I think it works in windows 95/98, but Ive never tried it. The basic steps are:
Get the handle of the icon you want to use
Fill up the structure
Create or modify the icon
The icon handle can be retrieved using two different API calls. The call LOADICONA (defined as FUNCTION long LoadIconA( ulong hInst, long resourceID ) LIBRARY "user32.dll") loads in the application icon. The variable hInst is the handle of the application which is obtained by using the handle() function on the application returned by the GetApplication() function (handle(getapplication()) works). Use Long(1000,0) for the variable resourceID. This function loads the icon into memory (not displayed!) and the return value is the handle of the icon. The handle is loaded into the structure (see below).
The other function LoadImageA (declared as FUNCTION long LoadImageA( ulong hInst, string lpszName, uint uType, int a, int b, uint l ) LIBRARY "user32.dll") allows you to identify the icon to be used by name. To be brief (and because Ive never done it any other way) the following code is what I use for this function ll_return=LoadImageA( 0, as_bitmap, 1, 0, 0, 80 ). The variable as_bitmap is the name of the bitmap. Include the path name if it is located outside the application path. The value ll_return is the handle for the icon, just as with LoadIconA.
The next step is to load in the structure. The export file for the structure (suitable for import w/PB 6.5) is:
$PBExportHeader$str_ipdata.srs
$PBExportComments$structure for task bar icon manipulation
global type str_ipdata from structure
long cbsize
long hwnd
long uid
long uflags
long ucallbackmsg
long hicon
character sztip[64]
end type
The structure contains 6 long type members and one character string with a length of 64. The first variable cbsize is the size of the structure. I use 88, but Im just going from what Ive read. The variable hwnd is the handle of a window, Ill explain which window later. The handle is taken as the return value of the handle(window) function. The variable uID is an identifier of the icon that is defined by the application and I just use the handle of the window in the previous step. The variable uflags tells the system which variables in the structure are valid. This seems like a really odd thing to have to do, but windows seems to want it. I use a value of 7 which tells the system all the variables are valid. The next item ucallbackmessage is very important because it determines what event is fired in the window specified in the hwnd variable. Any code in this event will be executed when the user interacts with the icon (more about that later). The codes for the various window events are:
512 MOUSEMOVE
513 LEFTBUTTONDOWN
514 LEFTBUTTONUP
515 LEFTBUTTONDBLCLK
516 RIGHTBUTTONDOWN
517 RIGHTBUTTONUP
518 RIGHTBUTTONDBLCLK.
The last long variable is the handle of the icon to use in the task bar. The last variable sztip is a string which is text of the popup text that appears when you put the mouse over the icon.
Now that the structure is filled you can call the API Shell_NotifyIcon (declared as FUNCTION long Shell_NotifyIcon( ulong dwMessage, REF str_IpData lpData ) LIBRARY "shell32.dll"). The first argument specifies whether you want to add an icon (use 0), modify an icon (use 1) or delete the icon (use 2). The second argument is the structure you just created. The function returns 0 if it fails, something else if it succeeds. That's all there is to it. Here's some code putting it all together:
Long ll_rc
w_invisible lw
str_ipdata istr_ipdata //this is the structure for the icon info
open(lw)
istr_ipdata.cbSize = 88
istr_ipdata.hWnd = handle(lw)
istr_ipdata.uID= istr_ipdata.hWnd //just use the handle of the window in the last step
istr_ipdata.uFlags = 2+4+1
istr_ipdata.szTip= gnv_app.of_getappname() + Char(0)
istr_ipdata.uCallbackMsg = 512
istr_ipdata.hIcon = LoadIconA( handle(getapplication()),Long( 1000, 0 ) )
//istr_ipdata.hIcon= LoadImageA( 0, as_bitmap, 1, 0, 0, 80 ) ****use this to use an icon with name
// as_bitmap
//Do this for development
if istr_ipdata.hIcon=0 then
istr_ipdata.hIcon=1
end if
ll_rc = Shell_NotifyIcon( 0, istr_ipdata )//0=add, 1=modify, 2=delete
return ll_rc
Now that weve done all of this, so what. What happens now? What happens is when the user interacts with the task bar icon is that the event specified in the callback message is fired. In addition one of the arguments of the event, usually (if not always) the xpos argument is a number (a long) that corresponds to the action that the user just executed upon the task bar icon. What this all means is that in the example above if the user moves the mouse over the icon the mousemove event is fired in the window I used in the structure hwnd variable. The xpos argument of that event will be 2341 (remember this is NT 4, windows 95/98 might be different). If the user double clicks the left mouse button the mousemove event will be fired again, but this time the xpos argument will be 2354. The list of events and xpos value is as follows (for NT 4):
2341 the mouse moved over the task bar item
2363 RightMouseButton Up
2359 RMB Down
2350 LMB Up
2345 LMB Down
2354 LMB Double Click
2368 RMB Double Click
Now were in the realm of PowerBuilder. I have the script in a window executing and I can tell what type of interaction the user just executed with the task bar icon. Now to display the popup menu I just use normal powerscript. I can chose to have it appear when the user right clicks or during any interaction with the task bar icon. I can make the app close or anything I want, because Im in the realm of PowerBuilder. The rest I leave up to you.
There are a number of subtle points to go over. I want the popup menu to appear on the task bar icon even if the application is minimized. If all the windows in an app were minimized the popup menu wouldn't appear. I don't know if it was me or if windows won't display a menu for a minimized app. What I could do is use an app with an MDI frame as the interface, but create an invisible window to keep up for the task bar icon. When the frame window is minimized the invisible window is not and the popup menu is displayed. The handle of the invisible window is what is put in the structure for the function call. This also allows me to put code in whatever event I want to and I don't have to worry about that event being triggered by other means, such as a double-click or mousemove. It doesn't seem very object oriented however. Why should a window have to know what to do if the task bar icon is hit? But that's the only thing I could come up with to solve my problem. Make sure you close the invisible window when you want your app to close. If you don't your app won't close.
I added a few lines to help me in development. When I try to get the handle of the app in development I get 0 because the app is really Powerbuilder not the app I created. In this case the handle of the app icon will also be 0 and I'll get no task bar icon. It will still be there but it won't have a picture, just blank space. So what I do is if the icon handle is zero I make it equal to one. This puts up a generic window icon that looks better.
I can get rid of the icon by calling the Shell_NotifyIcon function but use 2 instead of zero as the first argument (something like ll_rc = Shell_NotifyIcon( 2, istr_ipdata )). I keep a reference to the structure so I dont have to recreate it. It is possible for an app to create many icons, so the structure has to specify which icon to destroy. If you dont destroy the icon when you close the app there doesnt seem to be much of a problem. All Ive seen is that the icon remains until the user moves the mouse cursor over it, then it disappears. There is no crash, and maybe only a small memory leak, but it seems sloppy so you probably want to destroy it.
That's all there is to it. If you have any questions please do not hesitate to email me at greg.dzingeleski@ssa.gov. I hope you find this useful.
BAPBUG Officers | |||
President | Debbie Arczynski | softquip@home.com | (410) 796-9461 |
Vice President | Bill Bitman | bitman@jhuapl.edu | (443) 778-3904 |
Secretary | Gordon Giffen | gordon-g@vips.com | (410) 832-8300 |
Treasurer | Fred Grau | fgrau@chesint.net | (410) 893-9638 |
Tech Advisor | Mark Pfeifer | mpfeifer@sprynet.com | (410) 499-8765 |
Web Administrator / Tech Advisor |
Anne Sola | anne-s@vips.com | (410) 832-8300 |
Newsletter Editor / Tech Advisor |
Greg Dzingeleski | greg.dzingeleski@ssa.gov | (410) 966-3328 |