Make your own free website on Tripod.com

Did you know...

Back Up Next

Subject Description
How to select text beyond the 32K limit.

Roland Smith (rsmith@cvps.com)

The SelectText function which I use on multiline edit controls has a problem because it accepts integer arguments instead of longs.  This prevents you from selecting text at the end of really long text.

I have figured out how to get around this problem and thought I would let everyone know about it.

// select the text
Send(Handle(mle_1), 177, start, end)

// scroll to where the cursor is
Send(Handle(mle_1), 183, 0, 0)
RGB values for system colors

(SchulF@mail01.dnr.state.wi.us)

67108864 ButtonFace
1073741824 WindowBackground
33554432 WindowText
268435456 ApplicationWorkspace
553648127 Transparent

I think these are the same as:

2^25 - Window Text
2^26 - buttonface
2^27 - scrollbar background
2^28 - app. workspace
2^29 - transparent
2^30 - Window Background
How to get the count of selected rows in a datawindow

(Thomas Kellerer, Thomas.Kellerer@tps-labs.de)

ll_SelectedCount =
Long(dw_1.Describe("Evaluate('sum(if (IsSelected(),1, 0) for all)',1)"))
How Can I sent a Email with attachment files?

(Thomas Kellerer, Thomas.Kellerer@tps-labs.de)

string ls_Filter
mailsession lms_Session
mailmessage lm_Message
mailrecipient lm_Recipient
mailFileDescription lmf_File
mailreturncode lmc_Return

string ls_FileName, ls_PathName, ls_UserName
ulong ll_Length

lmf_File.FileType = mailAttach!
lmf_File.FileName = ls_FileName
lmf_file.PathName = ls_PathName + ls_FileName

lm_Message.NoteText = "Your text goes here"
lm_Message.Subject = "Subject"
lm_Message.Attachmentfile[1] = lmf_File

lm_Recipient.Address = "someone@somewhere"
lm_Recipient.Name = "Real name of someone"
lm_Recipient.RecipientType = mailTo!
lm_Message.Recipient[1] = lm_Recipient

lms_Session = create mailsession
lmc_Return = lms_Session.mailLogon()
lmc_Return = lms_Session.mailSend(lm_Message)
if lmc_Return <> mailReturnSuccess! then
MessageBox("Error", "Error on Send")
end if

lmc_Return = lms_Session.mailLogoff()
destroy lms_Session
Surpressing vertical column selection in a grid datawindow without losing the ability to move/resize the columns. Well, try this in the clicked event:

if row <= 0 then
     if string(dwo.name) <> 'datawindow' then
        return 1
    end if
end if

This will allow you to move the columns in the datawindow (dwo.name = 'datawindow') but turns off the column selection (dwo.name <> 'datawindow').
Here is how to drag a window by clicking anywhere in the client area, not just the title bar:

(Roy Kiesler kieslerr@logica.com)

In the mousedown event of the window code the following:

CONSTANT uint WM_NCLBUTTONDOWN = 161
CONSTANT uint HTCAPTION = 2

// Fake Windows into thinking that we are clicking on the title bar,
// so we can drag the window from anywhere, not only the title bar
Post( il_handle, WM_NCLBUTTONDOWN, HTCAPTION, Long( xpos, ypos ) )

SQL to check if a table or column doesn’t exist

(Avron Polakow avron@shira.co.il)

ls_table = "tablename"
ls_sql = "SELECT * FROM " + ls_table + " WHERE 1=2"

EXECUTE IMMEDIATE :ls_sql ;

// NOW Check the SQLCA.SQLCode
IF SQLCA.SQLCode <> 0 THEN
// Table or column doesn't exist
MessageBox("Error " + string(SQLCA.SQLCode), SQLCA.SQLErrText)
END IF
Drop down a DDLB of DDDW using the keyboard F4 is the standard Windows key to drop down a ddlb or dddw.
Making any control moveable.

(Avron Polakow avron@shira.co.il)

In the mousedown event:
Send(handle(this), 274, 61458, 0)

If the control doesn't have a mousedown event then define the event as:
ue_mousedown pbm_lbuttondown
Retrieving SIMULTANEOUSLY in different dws

(Avron Polakow avron@shira.co.il)

Enter any script in the dw control retrieverow event of each of the datawindows.
Getting the column names and definitions for ANY TABLE IN ANY DBMS
without system tables or awareness of which database is being used

(Avron Polakow avron@shira.co.il)

int li, lj
string ls, ls_sql, ls_table, ls_syntax,
string ls_cols[ ] // Will contain the column names
string ls_datatype[ ] // Will contain the column data types
datastore lds

ls_table = "tablename" // eg for table with name "tablename"
ls_sql = "SELECT * FROM " + ls_table
lds = CREATE datastore
ls_syntax = SQLCA.SyntaxFromSQL(ls_sql, "", ls_errors)

li = lds.CREATE(ls_syntax, ls_errors)
ls = lds.Object.DataWindow.Column.Count
lj = integer(ls)
FOR li = 1 TO lj
ls_describe = "#" + string(li) + ".dbName"
ls_col[li] = lds.Describe(ls_describe)

// You can now also get the datatype
///////////////////////////////////////////////////////
// Remember that the datatype name is the
// internal PowerBuilder Name
// eg: Oracle Number(10,4) will be listed as FLOAT
// You might here want to translate PB's internal datatype
// names into the standard datatype names in your own DBMS
//////////////////////////////////////////////////////////

ls_describe = "#" + string(li) + ".ColType"
ls_datatype[li] = lds.Describe(ls_describe)

NEXT

DESTROY lds
Quickly counting the number of occurrences of any token(s)
in a string (without FOR ... NEXT)

(Avron Polakow avron@shira.co.il)

FUNCTION f_count_tokens(string as_string, string as_token)
// Returns: Number of tokens
/////////////////////////////////////////////////////////////
int li, lj

li = Pos(as_string, as_token, 1)
DO WHILE li > 0
lj++
li++
li = Pos(as_string, as_token, li)
LOOP

return lj
Searching a string back-to-front
(Avron Polakow
avron@shira.co.il)
FUNCTION f_search_backwards (as_string, as_token)
//////////////////////////////////////////////////
long ll_Pos

ll_pos = Pos(Reverse(as_string), Reverse(as_token))
IF ll_Pos = 0 THEN
return 0
ELSE
return Len(as_string) - ll_Pos + 1
END IF
Capturing the Close Event from the Control Menu

(Avron Polakow avron@shira.co.il)

// IN pbm_syscommand event
////////////////////////////////////////////////////
IF Message.WordParm = 61536 THEN
/* do whatever */
END IF
Animated cursors

(anild007@terra.worldonline.nl)

Any .ani (animated) file can be used as a pointer for object.
I.e. cb_1.Pointer = "c:\windows\cursor\drum.ani"
Starting applications based on extension

 

On Win95 or WinNT, you can start or open many files like INI files or URLs with an associated application: run("start http://www.sybase.com") or run("start win.ini")
Position objects ontop of others You can use the SetPosition() function to place objects in front of others. For instance, a commandbutton on your datawindow will disappear if the datawindow gets the focus. With the SetPosition() function you can solve this like: cb_1.SetPosition(ToTop!, dw_1)
Change default printer You can change the default printer with the SetProfileString(‘win.ini’,’system’,’device’, printerstring). This works for Win3.x, Win95 and even for WinNT (although its win.ini does not have these INI entries, changes are automatically sent to the registry).
Get current directory

 

You can use the DirList() function to get the current directory?
PowerBuilder INI file locations

 

You can specify in your win.ini where the PB.INI file can be located:

[PowerBuilder]

InitPath040 = c:\pb4

InitPath050 = c:\pb5

For PowerBuilder 6+, you can specify the PB.INI file location in the system options within PowerBuilder.

Response windows with menu

 

You can have a menu in a response window? Although this is not standard windows GUI, it could be handy sometimes. Use the changemenu() function in the open event to associate a menu with the window.
MDI frame without menu & toolbar

 

You can have a MDI frame without a menu and without a toolbar? Create a menu with only one item, which is invisible and disabled and use that menu for the MDI frame.
Aligning menu items on the right If you use char(8) + ‘YourMenuText’ as text for a main menuitem, the item will be displayed on the rightmost location of your window!

Works for PB4. Dunno for PB5. Not for PB6.

Determining if we are in development mode

 

You can determine that you are in development mode by using the Handle(GetApplication()) function. If it returns 0, you’re in dev mode. Otherwise, you’ve started the app as an EXE.

You've got a simple tip? Mail mailto.gif (96 bytes) it to me and I'll add it to the list.

Back Up Next