Beruflich Dokumente
Kultur Dokumente
The story is: you have your CLIPPER application, get ALASKA XBASE++, install it, read this quid, add
our PRG files, make small change to your PRG modules, make PROJECT file and recompile and link using
PBUILD. Now you have full WINDOWS 32-bit application. Give it to your users and then get back to
ALASKA to learn how to take full power of it. Your users will get new version, you get time to learn new
product and everyone will be satisfied.
Aleksandar Stefanovic
AS Computer Software
Are you Clipper programmer with many DOS applications, someone who wants to
continue to live and someone who think that Windows is not the end? What to do now?
DOS applications can be executed under Windows platform but people want to go on, not
to stay in the past. DOS is the past, and you, as programmer must live with that. So, is
your programmer life finished? Answer is NO. Your applications, source code can have
second chance. Alaska Xbase++ is solution for you. Is this the only one? No, you have
other options but we believe that this is the best one.
These days there is Alaska Xbase++ version 1.9 from Alaska Software. You can find it
on www.alaska-software.com First thing that you will read is that this is 100% Clipper
5.x compatible windows 32bit’s compiler. That is a right and that is not the end. This is
only starting point for you to transfer your old DOS Clipper applications to windows
platform. I want you to remember this. Don’t use this compiler only to make your old
DOS applications, windows applications. As you know DOS and Windows are different
operation systems, so logic you have in DOS time must be changed. Logic about how
users use your application. The best reason for this is that your application doesn’t have
full control over PC. This is just another process on it. Another thing is user interface that
have to be changed. You must use things that Windows offer to you in the way that
windows users expect. You don’t have to reinvent hot water again. I believe that you as
DOS Clipper programmer have full “know how” to use Windows. There is no reason to
teach you how to use Windows, I believe that you already know that. If you don’t, than
this text is not for you.
We believe that Xbase languages have to live on. Easy, effective, clear. And after all
there are so many people who use it for decade (or more). Many other programmers
(C/C++, Delphi…) don’t like Clipper and in one period of time they even don’t think
about Clipper people as programmer at all. But this is not our problem. Clipper was one
of the best that happened in the past. Number of Clipper application is so big, number of
Clipper programmers to. So be patient and forget what other said about this, and continue
to make you living on it.
How to start? First, install it. Please, don’t forget to install Xbase TOOLS because there
are many functions that you will need. You will get all you need in ALASKA directory.
Now use command prompt instead of DOS and find yourself in environment you know.
In the past you have Clipper.exe now you have xpp.exe.
<ALASKA\XPPW32\>
|—BIN Compiler and service programs
|—BOOK Online help
|—LIB Runtime library
|—INCLUDE #include files
|—RESOURCE Resource files
|—RUNTIME Runtime libraries
|—SOURCE Source code
|—SYS Source for System level files
|—COMPAT Compatibility functions for
| Clipper ‘87
|—SAMPLES Example programs
<ALASKA\XBTW32\>
|—BIN Compiler and service programs
|—BOOK Online help
|—LIB Runtime library
|—INCLUDE #include files
|—SOURCE Source code
|—SAMPLES Example programs
@echo off
rem Environment for XbToolsIII
rem created by XbToolsIII installation 5-18-2006
SET PATH=C:\ALASKA\XBTW32\LIB;%PATH%
SET LIB=C:\ALASKA\XBTW32\LIB;%LIB%
SET INCLUDE=C:\ALASKA\XBTW32\INCLUDE;%INCLUDE%
You can have Clipper and ALASKA on the same system but you need to take care for
environment variables, remember that.
Please, remember what happened after starting CLIPPER.EXE. You sow compiler
options. Just to remind you.
Options:
/a automatic memvar declaration
/b debug info
/credits credits screen
/d(<id>)[=<val>] #define <id>
/es[<level>] set exit severity
/I<path> #include file search path
/l supress line number information
/m compile module only
/n no implicit starting procedure
/o<path> object file drive and/or path
/p generate pre-processed output (.ppo) file
/q quiet
/r[<lib>] request linker to search <lib> (or none)
/s syntax check only
/u[<file>] use command def set in <file> (or none)
/v variables are assumed m->
/w enable warnings
@file compile list of modules in <file>
Do you remember?
/q quiet mode
As Clipper programmer we believe that you don’t need “Hello World” sample. You have
your own applications and if you compile and link that with ALASKA you will get your
WINDOWS application. Because Clipper language is only a part of ALSAKA you have
to read all of help files for description of new functions, commands and objects. This
story is not about that only how to start in very short time to transfer your old DOS
Clipper application into NES WINDOWS ALASKA application. You can find in users
gude that you have only to recomple your project but then you will keep old DOS look
and here is short solution how to get new 32-bit application and how to get new look.
After that you will get time to chenge your application using other ALASKA functions,
command and objects but your users can use your NEW application .
Here we will not talk about linker, you can find that using alink is the same process but at
the start please forget this and use PBUIL.EXE utility to compile and link your
application. To use it you only have to make PROJETC.XPJ text file. It is easy but new
to you. The Xbase++ ProjectBuilder is a tool for managing entire software projects. You
can make one or more EXE or DLL (yes) files. This is ASCII file with XPJ extension. In
Xbase help documentation you can find one example
01: [PROJECT]
05: GUI = no
07: LINK_FLAGS =
09: RC_FLAGS =
10: CUSTOMER.XPJ
11:
12: [CUSTOMER.XPJ]
13: CUSTOMER.EXE
14:
17: COLLAT.CH
18: GET.CH
19: MEMVAR.CH
20: PROMPT.CH
21: SET.CH
22: STD.CH
23: CUSTOMER.OBJ
24: GETCUST.OBJ
25: PRINT.OBJ
26: VIEWCUST.OBJ
27: // $STOP-AUTODEPEND
28: CUSTOMER.PRG
29: GETCUST.PRG
30: PRINT.PRG
31: VIEWCUST.PRG
Don’t be afraid of this. It is easy to manage. You have only to remember that there is
sections that describe you compiler and linker options and list of all include, source code
prg and obj files. Read users guide about this options.
Options for compiler and linker you will write only once and after that you have only to
add your files names.
01: [PROJECT]
03: GUI = no
04: CUSTOMER.XPJ // The root of the project
05:
08:
11: GETCUST.PRG
12: PRINT.PRG
11: VIEWCUST.PRG
You can create this using editor. Numbers are not part of file body and here are they just
to make things clear and easy for reference. So if you have to make PROJECT file for
your project, start editor, write [PROJECT], go to the next line, write DEBUG=yes (use
this for testing, and when you get no errors, change it to DEBUG=no), go to next line
Write name for your project (in this case it is CUSTOMER) CUSTOMER.XPJ and you
have finished first section. Now go to next line and write [CUSTOMER.XPJ] starting
point for your application description. Go to next line and write CUSTOMER.EXE, this
is the name of EXE file that will be generated. Now we have to list from what ours
programs modules we want EXE file. Write [CUSTOMER.EXE] and after that make a
list of PRG files. That’s it. Save this file as PROJECT.XPJ and under command prompt
type PBUILD. This utility will open our PROJETCT.XPJ file and invoke compiler and
linker for us. After that you will have your EXE. Full win32 application. It will not be so
difficult to make PROJECT.XPJ that describe your old DOS application for start. You
have more options that PBUILD can use. If you start transition to windows environment
and if you use your old DOS source Clipper code without changes, this is good start
point. Please use
Your application will look as your DOS application. But only look is the same. If you try
to use it on DOS you will not be able to start it because this is full windows application.
Now you are Windows programmer. It is not so difficult for Clipper programmer to write
PROJECT.XPJ and became Windows programmer. You are back.
In Xbase help file you can find full description of options you can (and will) use in your
project file. Please read it.
All information that may be listed in the [PROJECT] section is described below. Each project file
must begin with the [PROJECT] section which contains definitions valid for the entire project
(project-wide definitions):
COFF_LINKER= This optional definition can be used to define the linker to be invoked by the
ProjectBuilder when OBJ_FORMAT= is set to COFF (Common Object
File Format). If COFF_LINKER= is not defined in this case, the
ProjectBuilder uses the linker defined with LINKER=.
COMPILE= This indicates the name of the Xbase++ compiler. It is always XPP.
COMPILE_FLAGS= All compiler switches to be set for compilation are defined here. Note that
separate definitions OBJ_DIR= and DEBUG= exist for the switches /o and
/b.
DEBUG= This definition can be set to YES (debug version) or NO (non debug
version). Executable files are created accordingly with or without debug
information. An executable file must be created with DEBUG=YES so that
it can be monitored with the debugger.
LINKER= This definition indicates the name of the linker that is used to create EXE
or DLL files from OBJ files. It is the linker that is shipped with the
operating system-specific Xbase++ version.
LINK_FLAGS= All linker flags which are not covered by GUI= and DEBUG= are listed in
this definition. However, if the flags /PM and /DE are used here as well,
they override the corresponding definitions GUI= and DEBUG=.
OBJ_DIR= Optionally, the directory for OBJ files can be defined. The compiler creates
OBJ files in this directory, and the linker searches it for these files. Only
one directory can be set for each target.
Note: The OBJ_DIR setting affects only the OBJ files listed in the section of a project file that is
delimited with // $START-AUTODEPEND and // $STOP-AUTODEPEND. PBuild completes these
OBJ file names with the OBJ_DIR directory so that no path information may be specified for the
files listed in the auto-dependency section. Additional OBJ files can be specified with a full qualified
path outside the auto-dependency section.
OBJ_FORMAT= Two values can be used for this definition to select the object file format:
COFF (Common Object File Format) or OMF (Object Module Format).
The ProjectBuilder then starts the Compiler and invokes AIMPLIB.EXE, if
necessary, using the corresponding switches /coff or /omf. In addition, the
linker specified with COFF_LINKER= or OMF_LINKER= is used in the
build process.
OMF_LINKER= This optional definition can be used to define the linker to be invoked by the
ProjectBuilder when OBJ_FORMAT= is set to OMF (Object Module
Format). If OMF_LINKER= is not defined in this case, the ProjectBuilder
uses the linker defined with LINKER=.
POST_BUILD= This definition can be used to execute a command after the target is built.
The statement that follows the equal sign ("=") is then executed in a
command shell. More than one POST_BUILD definition can be present in a
section. In this case, the commands are executed sequentially, in the order
they were defined. If a command returns an error, execution of
PBUILD.EXE is aborted. This behaviour can be overridden by specifying a
hyphen character ("-") as first character behind the equal sign ("=").
POST_CLEAN= This definition can be used to execute a command after the target is
cleaned. The statement that follows the equal sign ("=") is then executed in
a command shell. More than one POST_CLEAN definition can be present
in a section. In this case, the commands are executed sequentially, in the
order in which they were defined. If a command returns an error, execution
of PBUILD.EXE is aborted. This behaviour can be overridden by
specifying a hyphen character ("-") as first character behind the equal sign
("=").
PRE_BUILD= This definition can be used to execute a command before the target is built.
The statement that follows the equal sign ("=") is then executed in a
command shell. More than one PRE_BUILD definition can be present in a
section. In this case, the commands are executed sequentially, in the order
in which they were defined. If a command returns an error, execution of
PBUILD.EXE is aborted. This behaviour can be overridden by specifying a
hyphen character ("-") as first character behind the equal sign ("=").
PRE_CLEAN= This definition can be used to execute a command before the target is
cleaned. The statement that follows the equal sign ("=") is then executed in
a command shell. More than one PRE_CLEAN definition can be present in
a section. In this case, the commands are executed sequentially, in the order
in which they were defined. If a command returns an error, execution of
PBUILD.EXE is aborted. This behaviour can be overridden by specifying a
hyphen character ("-") as first character behind the equal sign ("=").
RC_COMPILE= This definition contains the name of the resource compiler as it is shipped
with Xbase++. Normally, additional resources are used for GUI
applications only.
OS/2 - There are additional notes at the end of this section for the OS/2 platform.
RC_FLAGS= The flags for the resource compiler are set with this definition.
<SECTION> All entries in the [PROJECT] section defined without equal signs are used as a
reference to subsequent user-defined sections which are to be analyzed by the ProjectBuilder.
Normally, only one additional section (the root section) is referenced. There must be at least one
user-defined section.
Note: Definitions listed in the [PROJECT] section are valid for the entire project. However, they may
appear in user-defined sections as well. In this case, they are valid for one section only. If definitions
are passed to PBUILD.EXE on the command line using the /d switch, all definitions in a project file
with the same name are ignored.
Depending on whether resources are declared in ARC or RC files, the option RC_COMPILE= must
be set to arc or rc . If ARC files are used, the Project Builder invokes first ARC.EXE (Alaska
resource compiler) and then RC.EXE (OS/2 resource compiler). ARC.EXE translates ARC files to
RC files which can be compiled by RC.EXE.
If you get large EXE file consider breaking it into one or more DLL files. Please don’t
ask me what is it. I believe you know. How you will do that. Using PBUILD. If you have
prg files like this
** File SAYHI.PRG **
PROCEDURE SayHi
? "Hi folks"
RETURN
// File: PROJECT.XPJ
[PROJECT]
ROOT
[ROOT]
MAIN.EXE
MYFUNCS.DLL
[MAIN.EXE]
MAIN.PRG
MYFUNCS.LIB
[MYFUNCS.DLL]
SAYHELLO.PRG
SAYHI.PRG
When you start PBUILD you will make MAIN.EXE and MYFUNCS.DLL. In your
directory you will find MYFUNCS.LIB this file will be used by linker only. So when you
want to use functions from some DLL you need LIB file for it. Just add it to your
PROJECT.
Remember XB TOOLS? If you use functions from it you will need to add LIB files
XBTBASE1.LIB and XBTBASE2.LIB. You will find it in ALASKA XBTW32\LIB
directory. Just add it and you will get more then 800 functions. If you as Clipper
programmer use some libraries that are not part of standard Clipper library you will have
to change it with functions from XBTOOLS library. Believe us, you will find them there.
Some functions you will not find, but this is the price to start your WINDOWS life. On
the other hand clipper functions and commands are only one part of ALASKA XBASE.
When you want to make full 32-bit Windows application without any text based support
you will find much more commands and functions new to Clipper programmers. But
about that later.
For now this is all you need to make your new (old DOS) Windows application. Once
againg You are now Windows programmer.
Let’s make our applications to look more Windows then DOS application.
This function is normally executed prior to the call of the MAIN procedure and if we
want to use some GUI device output we must use it. This file you can write ONLY once
and forget about it. Just add it in your project file. What you will get. Window that you
can control in old DOS way. But you will have 80 rows and 30 col. Why 30 instead of
25. This looks better and you will get some extra space where you can add some
graphics. Your source code that control display will not have to be changed. We add one
more thing. Functions that will check are we have any other instance of our application
and how we can avoid it. Under windows you can start many applications and one more
then once, but this is sometimes that not is what we want. For this we use function
just_one(). This function use some windows API functions, this is the reason why we
need DLL.CH and some other DLL declaration. We don’t have LIB files for Windows
libraries and we must use functions that can load libraries and find functions in it. What
you are see here is the way you can use to access any function from any DLL library if
you know function name, where to find it and how to use it. Remember, you are in
Windows now and there is no reason not to use functions from it. In old day’s we use
DOS internal functions, interrupts and now we can use WINDOWS API functions.
For this we must find documentations for it. This is another story, but we believe that
sometimes you will ask for it.
////////////////////////////////////////////////////////////////////
// APPSYS.PRG
//////////////////////////////////////////////////////////////////////
#include "DLL.CH"
#include "appevent.ch"
#include "xbp.ch"
#include "aboutbox.ch"
***********************************************************************
*****
* Function AppSys() to create default output devices
***********************************************************************
*****
PROCEDURE AppSys()
#define DEF_ROWS 30
#define DEF_COLS 80
//#define DEF_FONTHEIGHT 16
//#define DEF_FONTWIDTH 8
//#define DEF_FONTHEIGHT 23
//#define DEF_FONTWIDTH 10
// uncomment this 3 lines if you need to disable more then one instance
of application
// If just_one( "XbpPmtClass" )
// QUIT
// EndIF
aSizeDesktop := AppDesktop():currentSize()
aPos := { (aSizeDesktop[1]-(DEF_COLS * DEF_FONTWIDTH))
/2, ;
(aSizeDesktop[2]-(DEF_ROWS * DEF_FONTHEIGHT)) /2 }
Do Case
Case aSizeDeskTop[1] = 800
Def_FontHeight := 18
Def_FontWidth := 10
Case aSizeDeskTop[1] = 1024
Def_FontHeight := 22
Def_FontWidth := 12
Otherwise
Def_FontHeight := 16
Def_FontWidth := 8
Endcase
oCrt:PresSpace()
SetAppWindow ( oCrt )
oCrt := RootCrt():New()
oCrt:CreateBuffer := .T.
oCrt:Create()
SetAppWindow ( oCrt )
ENDCASE
RETURN
/*
* ShowWindow() Comande, iz WINUSER.H
*/
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_MAX 10
If nHwndFind # 0
nHwndForeground := GetForegroundWindow()
nForeGroundId := GetWindowThreadProcessId( nHwndForeground, 0 )
nFindId := GetWindowThreadProcessId( nHwndFind, 0 )
EndIF
BringWindowToTop( nHwndLast )
SetForegroundWindow( nHwndLast )
EndIF
lRet := .T.
EndIF
RETURN lRet
FUNCTION FindWindow2(cClass)
LOCAL nDll:=DllLoad("USER32.DLL")
LOCAL xRet:=DllCall(nDll, DLL_STDCALL, "FindWindowA", @cClass, 0)
DllUnLoad(nDll)
RETURN xRet
This file (appsys.prg) you have only to add in project.xpj and forget about it.Once again,
this procedure is execudet when application start, so if you want other things at that
moment you can add it here.
Information about application have every Windows application and this is ABOUTBOX
function. Lets add realy windows ABOUTBOX to your application.
//////////////////////////////////////////////////////////////////////
//
// ABOUTBOX.CH
//
// Copyright:
// Alaska Software Inc., (c) 1997-2001. All rights reserved.
//
// Contents:
// Bitmap Id for function AboutBox()
//
//////////////////////////////////////////////////////////////////////
#define ID_AS_ICON 101
#define ID_AS_CURSOR 102
#define ID_ABOUT_BITMAP 4242
#define ID_ABOUT_OKSLIKA 4243
Here is ABOUTBOX.PRG
//////////////////////////////////////////////////////////////////////
//
// ABOUTBOX.PRG
//
//////////////////////////////////////////////////////////////////////
#include "Aboutbox.ch"
#include "Appevent.ch"
#include "Common.ch"
#include "Font.ch"
#include "Gra.ch"
#include "Xbp.ch"
RETURN (0)
// this function we will use to inform user about something
function AboutOK(swhat)
RETURN (0)
/*
* Display program information and an optional bitmap logo
*/
drawingArea := oDlg:drawingArea
drawingArea:setFontCompoundName( FONT_HELV_SMALL )
/*
* The pushbutton reacts to the Return and Esc keys due to
* the :keyboard code block
*/
oBtn := XbpPushButton():new( drawingArea, , {86,12}, {67,24} )
oBtn:caption := "Ok"
oBtn:setpointer(,ID_AS_CURSOR,XBPWINDOW_POINTERTYPE_ICON)
oBtn:create()
oBtn:activate := {|| lExit := .T. }
oBtn:keyboard := {|nKey| IIF( nKey == xbeK_RETURN .OR. nKey ==
xbeK_ESC, ;
lExit := .T., NIL ) }
/*
* Size of the bitmap is limited
*/
aSize := oLogo:currentSize()
aSize[1] := Min( BITMAP_MAX_WIDTH , aSize[1] )
aSize[2] := Min( BITMAP_MAX_HEIGHT, aSize[2] )
nDX := aSize[1] + 12
mp1 := oDlg:currentSize()
oDlg:setSize( { mp1[1] + nDX + 4, mp1[2] } )
ChangePos( oDlg, { -nDX / 2, 0 } )
mp1 := { nDX, 0 }
AEval( drawingArea:childList(), {|o| ChangePos( o, mp1 ) } )
aSize[1] += 4
aSize[2] += 4
oXbp:setSize( aSize )
oXbp:setPos( { 12, aPos[2] -aSize[2] } )
ENDIF
oDlg:show()
oDlg:setModalState( XBP_DISP_APPMODAL )
oXbp:setpointer(,ID_AS_CURSOR,XBPWINDOW_POINTERTYPE_ICON)
oFocus := SetAppFocus( oBtn )
DO WHILE ! lExit
nEvent := AppEvent( @mp1, @mp2, @oXbp )
oXbp:handleEvent( nEvent, mp1, mp2 )
ENDDO
oDlg:setModalState( XBP_DISP_MODELESS )
oDlg:destroy()
SetAppFocus( oFocus )
RETURN
/*
* Change the position of an XBP by distance
*/
STATIC PROCEDURE ChangePos( oXbp, aDistance )
LOCAL aPos := oXbp:currentPos()
aPos[1] += aDistance[1]
aPos[2] += aDistance[2]
oXbp:setPos( aPos )
RETURN
/*
* Calculate the center position from size and reference size
*/
With this function we will create some dialogs with picture in it. For this we need this
ARC file
//////////////////////////////////////////////////////////////////////
//
// ABOUTBOX.ARC
//
//////////////////////////////////////////////////////////////////////
#include "Aboutbox.ch"
ICON ID_AS_ICON = "as.ico"
BITMAP ID_ABOUT_BITMAP = "as.bmp"
BITMAP ID_ABOUT_OKSLIKA = "ok.bmp"
ICON ID_AS_CURSOR = "AS_CUR.ICO"
Of course, we need some ico and bmp files. Use it with your files.
Please use this files as is. You can change bitmap names or some text and you will get
ABOUTBOX and one notifies functions with windows.
Just another file we need at start is splashscreen file.
// splash.PRG
#include "XBP.CH"
#include "FONT.CH"
#include "GRA.CH"
STATIC oStartUp
PROCEDURE ShowSplashScreen(BITMAPID)
oXbp:AutoSize := .T.
oXbp:ClipChildren := .F.
oXbp:Create()
oXbp:Show()
aSize := oXbp:CurrentSize()
aRect := oStartUp:CalcFrameRect( { 0, 0, aSize[1], aSize[2] } )
oStartUp:SetSize ( { aRect[3] - aRect[1], aRect[4] - aRect[2] } )
CenterXbp ( oStartUp )
oStartUp:Show()
oStartUp:ToFront()
RETURN
PROCEDURE RemoveSplashScreen()
oStartUp:Destroy()
RETURN
STATIC FUNCTION CenterXbp ( oXbp )
aSizeParent := oXbp:SetParent():CurrentSize()
aSize := oXbp:CurrentSize()
aPos := Array(2)
aPos[1] := ( aSizeParent[1] - aSize[1] ) / 2
aPos[2] := ( aSizeParent[2] - aSize[2] ) / 2
oXbp:SetPos ( aPos )
RETURN aPos
Our application has modules in different PRG files. We can use Windows menu to access
them and we will do it in this way. Our Main procedure will look like this.
//////////////////////////////////////////////////////////////////////
//
// MENUDEMO.PRG
//
//////////////////////////////////////////////////////////////////////
#include "Appevent.ch"
#include "Xbp.ch"
#include "Aboutbox.ch"
#include "gra.ch"
#include "dll.ch"
PROCEDURE Main
LOCAL nEvent, mp1, mp2, oXbp,w_w,oPS,oBMP,obmpp
public u_programu:=.f.
private oStatusL,oStatusT,nDLL,oSTatusL1,OstatusT1
SetColor( "N/W" )
SetCancel( .F. )
SetMouse(.T.)
set scoreboard off
set cursor off
set century on
set date german
set wrap on
firmatxt1:=space(40)
firmatxt2:=space(40)
firmatxt3:=space(40)
RemoveSplashScreen()
oPS := SetAppWindow():presSpace()
oStatust:=XbpStatic():new(,oStatusL,{04,4},{633,20})
oStatust:type:=XBPSTATIC_TYPE_TEXT
oStatust:create()
setcolor("W/N")
oStatust1:=XbpStatic():new(,oPS,{200,120},{300,240})
oStatust1:type:=XBPSTATIC_TYPE_TEXT
oStatust1:create()
SetAppWindow():useShortCuts := .T.
AS_MENU( SetAppWindow():menuBar() )
setcolor("W/N")
//ok when we start let’s play one AVI file
pustiavi()
DO WHILE nEvent <> xbeP_Close
nEvent := AppEvent( @mp1, @mp2, @oXbp )
oXbp:handleEvent( nEvent, mp1, mp2 )
oBMP:draw(oPS)
porukas(" ")
set cursor off
set confirm off
ENDDO
RETURN
/*
• We will create manu
• */
PROCEDURE AS_MENU( oMenubar )
LOCAL oMenu
RETURN
DO CASE
CASE nSelection == 101
if !u_programu
QUIT
else
aboutok("You have to leve modul first"+chr(13)+"thn quit
application")
endif
ENDCASE
RETURN
function pustiavi()
local nDLL:=DLLLoad("WINMM.DLL")
local poruka1:= "OPEN TEST.AVI TYPE AVIVIDEO ALIAS AVI WAIT"
local poruka2
local poruka3:="PUT AVI DESTINATION AT 200 200 320 240 wait"
local poruka4:="play avi WAIT"
local poruka5:="window avi handle default wait"
local poruka6:="close avi wait"
local baffer:=space(200)
local nazad:=0
local n
//n:=alltrim(str(SetAPPWindow():gethwnd(),10))
n:=alltrim(str(oStatust1:gethwnd(),10))
nazad:=dllCall(nDLL,DLL_STDCALL,"mciSendStringA",@poruka2,@baffer,0,0)
//nazad:=dllCall(nDLL,DLL_STDCALL,"mciSendStringA",@poruka3,@baffer,0,0
)
//? "3 "+str(nazad,10)
nazad:=dllCall(nDLL,DLL_STDCALL,"mciSendStringA",@poruka4,@baffer,0,0)
nazad:=dllCall(nDLL,DLL_STDCALL,"mciSendStringA",@poruka5,@baffer,0,0)
nazad:=dllCall(nDLL,DLL_STDCALL,"mciSendStringA",@poruka6,@baffer,0,0)
DLLUnload(nDLL)
oStatust1:destroy()
return (NIL)
We here use NEW MAIN function, we make window display, play AVI in it, draw
picture and make menu to acces other parts of our application.
If u_programu
Return (NIL)
Endif
U_programu:=.t.
U_programu:=.f.
This is our flag. We need it because we don’t want to control menu options. We can
enable and disable them but this is much better from our point of view.
We have our own status bar to. You can use status bar part of xbase but sometimes it is
better to have our own.
And in lower left corner we put our bitmap. Now our application doesn’t look like DOS
one.
You can easy add other your modules. I thing that you get the picture how to very easy
transfer your DOS application to Windows world. You can use this files as your start
point. Other moules don’t have to be changed. Just add CLR command when you eneter
your procedure and CLR at the end. For now it will be all you need.
This is our CRT Window and we control it. On this windows you can use SAY,GET
QOUT, TBROWSE ,SAVSCREEN,RESTSCREEN…
Just one more thing, you can have more then one, let’s say DOS window. How?
Use this function
#include "inkey.ch"
#include "xbp.ch"
#include "box.ch"
#include "gra.ch"
FUNCTION CrtBox( nT, nL, nB, nR, cTitle, bAction )
LOCAL oAppWindow, cColor, nCursor, oError
LOCAL oCrt, nRowCount, nColCount, nX, nY, xReturn
oAppWindow := SetAppWindow()
// DEFAULT nT TO 0 , ;
// nL TO 0 , ;
// nB TO MaxRow() , ;
// nR TO MaxCol() , ;
// cTitle TO " "
/*
*/
nRowCount := nB - nT + 1
nColCount := nR - nL + 1
nX := nL * oAppWindow:fontWidth
nY := ( MaxRow() - nB ) * oAppWindow:fontHeight
nX += oAppWindow:currentPos()[1]
nY += oAppWindow:currentPos()[2]
cColor := SetColor()
nCursor := SetCursor()
SetAppWindow( oCrt )
SetColor( "N/W" )
CLS
SetColor ( cColor )
SetCursor( nCursor )
SetMouse ( .T. )
oCrt:setModalState( XBP_DISP_APPMODAL )
SetAppFocus( oCrt )
oCrt:setModalState( XBP_DISP_MODELESS )
oCrt:destroy()
SetAppWindow( oAppWindow )
SetAppFocus ( oAppWindow )
RETURN xReturn
If you remember functions from main prg file in many options (p0101(),p0102()…)
example function names from modules (in p0101.prg…), edit these files.
At start we have
Func p0101()
…
…
return (NIL)
Func p0101()
Local xbp0101:={||bp0101()}
Crtbox(0,0,20,50,”Title”,xbp0101)
Return (NIL)
Func bp0101()
…
return (NIL)
In this way you have next window when user choose one menu option. Nice. As you can
sow you have CRT window but dimensions are under your control, so it will not be
80x25, 80x30, it can be smaller, just as you need.
Believe us, this is all you need to know and to use and your DOS application will be
NEW Windows application in very, very short period of time.
There is one another important thing that you have to remember. When you start XBASE
application it’s act as it is in NETWORK environment, SET EXCLUSIVE OFF is
default. Change it to SET EXLUSIVE ON (CLIPPER default) and there will be no
problem.