The ability to convert character-based applications to Windows applications while retaining your existing procedural source code is a unique and exciting feature of the current versions of PFXplus.
You can convert your character-based programs to a Windows program running in Graphical mode plus, which means that movement between controls remains procedural but while a control has focus, the program is Windows event-driven, meaning that the usual Windows cut and paste functions etc are available.
Alternatively, if you prefer an object-oriented programming approach this is also possible with PFXplus, but will of course involve a rewrite of procedural code.
Once your programs have been converted to Windows you can use the Common Controls Architecture (CCA) tools to easily integrate many of the 32-bit Windows features into your programs to add that professional Windows look and feel, without having to hard-code everything. You can download a copy of PFXplus Sampler, which demonstrates the CCA tools and includes source code.
If you are concerned about converting your existing character-based code to Windows, send us a program that is typical of the type of programs to be converted. We will give you an idea as to the amount of work and time involved in converting it to Windows.
A number of POWERlines articles have been written on this subject. You can access them on this web site. Refer to POWERlines articles on Migrating to Windows and Using CCA to add Menus, Toolbars and Status Bars for an example of converting a character-based program to a fully functional Windows program. You will be astonished at how easy it is!
The Common Controls Architecture (CCA) tools were specifically developed to assist PFXplus Windows Developers to integrate many of the 32-bit Windows features into their programs with a minimum of effort and without needing to hardcode everything. These tools assist developers in creating professional-looking Windows screens with all the features of Windows (such as Tab Controls, Animation, Buttons, Bitmaps, Menus, Toolbars, Multi-select Look Up Tables and more) in next to no time. The CCA tools come standard with PFXplus version from 4.22 onwards at no extra cost.
PFXplus Sampler is a suite of programs, which demonstrates the use and implementation of these tools, and includes source code. You can download a free copy of PFXplus Sampler to check this out for yourself.
Refer to POWERlines article Sizing Your Screens. If you are having problems with PFLT not running full screen automatically (and the Full screen option is not available), try creating a DOS icon pointing to a DOS application (such as PFL3.exe for example), and then change the icon to point to PFLT. This will fool Windows into thinking you are running an MSDOS application, which will make the Full screen option available.
To change the caption of a button at runtime, use:
indicator onoff sts
keyproc key.user
onoff = not onoff
sts = winEnableWindow(s1_btn\Handle,onoff)
return
Where os1_btn is the name of the button and btntxt is the caption variable.
Put your buttons in their own entermode like this:
entergroup
entry member.surname s1_surname {required}
endmode
entermode
entry 0 s1_cancel {text="cancel", value=Key.Escape}
endgroup
Yes you can change the font on an object by using an API call in Win32 PFXplus. See POWERlines article Fonts with WM_SETFONT.
Multi-line Edit Boxes are both a character-mode and Windows feature. The sample program SWCHREQ.PFX which comes with PFXplus, demonstrates this. The key part of code to set an edit box to Multi-line is {HEIGHT= }.
Example:
/Screen
PFXplus Sample Program - Multi-line edit
[________________________________________________]
/*
page screen at 2 4
Accept screen.1 {HEIGHT=5, SIZE=400, WRAP}
This example creates a multi-line edit window 5 lines high, which can hold up to 400 characters.
Any control can be enabled and disabled using the API call WinEnableWindow. For a demonstration, add the following code to the keyproc section of our sample program CCBMPBTN.PFX.
The permissible length of the path (directory tree structure) depends on the runtime you are working with. There was a limit of 64 characters for the earlier DOS versions. However, the current Win 32 versions (PFLN, PFLT) support the 256 characters long path.
You cannot because static is not an addressable control. However, the workaround is to define the static in the image definition as a static control __S__, and move data to it.
The GroupBox is actually a button with style BS_GroupBox. You need to define a class and attach it to a custom control. For an example of the code required download the GB.PFX sample program.
A new feature introduced in PFXplus 5 SP1 allows you to do just that. The new configuration item iMultiLineHScroll controls the behavior of a multiline edit control, which has wrap set and has a height of 1. The effect of this on a multiline edit control of height 1 is to allow horizontal scrolling of the edit control.
WINLST:~nn selects the orientation. The values are 1 for portrait and 2 for landscape. If tilde (~) is specified without nn then landscape is selected, which is compatible with previous behaviour. The order does not matter, spaces are ignored, and a previously defined Windows printer can be selected as well.
Examples: //default printer, A5 size, Landscape DIRECT_OUTPUT "WINLST:&11~" //non default printer, Landscape DIRECT_OUTPUT "WINLST:~TI microLaser9 Turbo v2010.119; TI microLaser9 Turbo v2010.119,LPT1"
LOAD_DLL loads a Dynamic Link Library for Windows.
Calling an entry point in a DLL requires several steps:
Our example shows accessing a C++ custom dll called MyDLL.dll containing a function AddTwoIntegers for adding two integers:
//*** PFXplus part ***
integer sum
Load_DLL MyDLL
//or LOAD_DLL MyDLL FROM "C:\WINNT\SYSTEM32\MyDLL.dll"
FUNCTION AddTwoIntegers EXTERNAL MyDLL "_AddTwoIntegers@8";
Integer Integer RETURNS Integer
sum = AddTwoIntegers(22,44)
showln sum
inkey
abort
//*** MyDLL in C++ ***
extern "C" __declspec(dllexport)
int __stdcall AddTwoIntegers (int a, int b)
{
return (a+b);
}
Why "_AddTwoIntegers@8"? The __stdcall calling convention is used to call Win32 API functions. An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, int b ) is decorated as follows: func@8.
With PFLT, the title for the character mode screen and the minimised icon on the taskbar is set via the sTitle configuration item as in previous versions of PFXplus.
When running character mode applications with PFXplus 5 PFLN runtime, sTitle sets the title on the application screen, but on the taskbar displays the default "PFXplus for Windows" title. Use the "WinSetWindowText" wincalls function to set the title of the application to the minimised icon on the taskbar:
// test title #use wincalls //string for sTitle string s //handles integer hconsole integer h hconsole = Desktop\Handle() WinGetWindowText hconsole s 80 h = WinGetWindow(hconsole,GW_OWNER) WinSetWindowText h s
Currently, the owner of the main window rather than the main window itself is needed to set the title on the taskbar icon.
The WinMoveWindow function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.
The following code positions the window to the left top corner of the screen, while setting the size of it to 150x100 px.
#use wcomctl /screen1 ___ /* integer j h page screen1 h = desktop\handle j = WinMoveWindow (h,0,0,150,100,true) inkey