Navigation:  Examples >

Single instance

Previous pageReturn to chapter overviewNext page

http://news.xbwin.com/ot4xb.examples/7/

 

 

Minimum ot4xb build 1.5.3.126 -> function description (Misc.)

-------------------------------------

#include "ot4xb.ch"

// ---------------------------------------------------------------------------

#define MYAPP_UUID "CB803A76-0A3C-4560-814B-CD3D14BCBC68"

// ---------------------------------------------------------------------------

proc appsys() ; return

// ---------------------------------------------------------------------------

proc main()

local np := PCount()

local ap := Array(np)

local n

for n := 1 to np ; ap[n] := PValue(n) ; next

if ot4xb_single_instance(MYAPP_UUID,MyInstanceHandler(),ap)

   QUIT

end

CreateTheCrt()  

? "Main:" , ap

while inkey(0) != 27 ; end

return

// ---------------------------------------------------------------------------

CLASS MyInstanceHandler

EXPORTED:

INLINE CLASS METHOD OnNewInstance( aParams )

@user32:SetForegroundWindow( SetAppWindow():GetHWnd()  )

@user32:ShowWindowAsync( SetAppWindow():GetHWnd() , 1 )

? "NEW INSTANCE:" , aParams

return NIL

ENDCLASS

// ---------------------------------------------------------------------------

proc CreateTheCrt()

local nAppType :=  AppType()

local aSizeDesktop    := AppDesktop():currentSize()

local aPos            := {(aSizeDesktop[1]-640)/2,(aSizeDesktop[2]-400)/2}

local oCrt            := XbpCrt():New ( NIL, NIL, aPos, 25, 80 )

oCrt:FontWidth  := 8

oCrt:FontHeight := 16

oCrt:title      := AppName()

oCrt:FontName   := "Alaska Crt"

oCrt:Create()

oCrt:PresSpace()

SetAppWindow ( oCrt )

return