FINDFIRSTINSTANCE function
Purpose: FINDFIRSTINSTANCE will search for a running instance of a GUI program by looking for the Class Name. If found, the caption bar of the sought program will flash until the sought program is re-activated. If the sought program does not have a caption bar, the sought program is given, automatically, the keyboard focus.
Syntax: RetVal = FINDFIRSTINSTANCE(ClassName$) Parameters:
Return Value:
|
Remarks: FINDFIRSTINTANCE usually is used in the SUB
FORMLOAD procedure. If a BCX program is searching for an instance
of itself, the Class Name is stored in a preset variable named
BCX_CLASSNAME$. In the example below,
"mandelbrot" is the Class Name stored in BCX_CLASSNAME$
Example:
GUI"mandelbrot"CONSTRed=RGB(10,0,0)CONSTGreen=RGB(0,10,0)CONSTBlue=RGB(0,0,10)GLOBALFormASCONTROLGLOBALKolorASINTEGERSUBFORMLOADIFFINDFIRSTINSTANCE(BCX_CLASSNAME$)THENPostQuitMessage(0)Kolor=Blue Form=BCX_FORM("Mandelbrot ~ Made with BCX ~")BCX_SET_FORM_COLOR(Form,0)CENTER(Form)SHOW(Form)ENDSUBBEGINEVENTSSELECTCASECBMSG'*******************CASEWM_CREATE'*******************IFNOTSetTimer(hWnd,1,3000,0)THENMessageBox(hWnd,"Timer Error","Error", MB_OK)PostQuitMessage(0)ENDIF'*******************CASEWM_PAINT'*******************DIMRAWpsASPAINTSTRUCTDIMRAWhdcASHDC hdc=BeginPaint(hWnd,&ps)DrawMandelbrot(hdc)DeleteDC(hdc)EndPaint(hWnd,&ps)'*******************CASEWM_TIMER'*******************SELECTCASEKolorCASERed Kolor=GreenCASEGreen Kolor=BlueCASEBlue Kolor=RedCASEELSEKolor=BlueENDSELECTInvalidateRect(Form,0,1)'*******************ENDSELECTENDEVENTSSUBDrawMandelbrot(hdcASHDC)DIMRAWCountASINTEGERDIMRAWAASSINGLE, BASSINGLE, CASSINGLEDIMRAWIASSINGLE, RASSINGLEFORI=-1.3TO1.3STEP.01DOEVENTSFORR=-2.2TO1STEP.01 A=B=C=Count=0WHILEABS(A)<=2ANDABS(B)<=2ANDCount <128C=A*A-B*B+R B=2*A*B+I A=CINCRCountWENDSetPixel(hdc,50+(230+R*100),140+I*100, Count*Kolor)NEXTNEXTUpdateWindow(Form)ENDSUB