Creation of the message dialog in the PB

zhaozj2021-02-17  81

Creation of the message dialog in the PB

Shanghai University Sun Yuanlei

SharedObject series functions

And shared objects involved in: SharedObjectRegister, SharedObjectget, SharedObjectUnregister, and SharedObjectDirectory functions.

First, use the SharedObjectRegister function to initialize the shared object and create a separate thread. Such as:

SharedObjectRegister ("ccuo_thread", "three")

Where CCUO_THREAD is a class name of a shared custom class user object, thread1 is a shared name of the shared object instance. If the SharedObjectRegister function returns SUCCESS, the new thread creates a success.

Then, execute the specified code. There are two ways to make the new thread execute the specified code: One is to write a script in the CONSTRUctor event of the custom class user object, and the new thread will automatically execute the event script; another method is to use the sharedObjectget function. This function implements a reference to the shared object instance, such as:

SharedObjectget ("Thread1", Inv_thread)

Where INV_THREAD is an object variable used to store the shared object instance, requiring the same class name with CCUO_THREAD.

Finally, by using the POST statement, that is, asynchronously calls the function of_function of the shared object asynchronously.

After completing the task, you can use the SharedObjectUnRegister function to stop thread, or you can list all valid shared objects with the SharedObjectDirectory function.

Function call part

The Win32 API function in this article is:

Function Ulong Findwindowa (String Lpwindown) library "user32.dll"

Function ulong gettickcount () library "kernel32.dll"

Function Ulong getDesktopWindow () library "user32.dll"

Function Boolean getWindowRect (Ulong Hwnd, Ref Stc_Rect LPRECT) Library "User32.dll"

Function Boolean MoveWindow (Ulong Hwnd, Int X, Int Y, INT NWIDTH, INT NHEIGHT, BOOLEAN BREPAINT) LIBRARY "User32.dll"

The following specifically discusses how to implement the current display of the message dialog:

// Declaration of object variables

CCUO_THREAD LCCUO_THREAD

// Create a new thread

SharedObjectRegister ('ccuo_thread', 'thread_center')

/ / Reference example

SharedObjectget ('Thread_Center', LCCUO_THREAD) // Call Window Center Central Function

LCCUO_THREAD.POST OF_CENTER ('# 32770', 'Demostration ", 2000)

// Create a message dialog

MessageBox ('Demostration', 'Copyright (c) 2001 by Y.l.sun')

// Abort thread

SharedObjectunRegister ('thread_center')

Function implementation

The function displayed in the window is a custom class user object CCUO_THREAD object function of_center. In fact, the current code is as follows: ccuo_thread.of_center (String LpClassName, String

LPWindowname, ulong dwtimeout) Return Boolean

// LPClassName: Class name of the message dialog (# 32770)

// lpwindowname: Title of Message Dialog

// DWTIMEOUT: timeout count

Ulong LUL_HWND / / Handle of the Message Dialog

Ulong LUL_START / / Trimming Time Value

LUL_START = GetTickCount () // Start

DO

/ / Find the top window

LUL_HWND = FindWindowa (lpclassname, lpwindowname)

/ / After finding the top window, jump out of the loop

IF lul_hwnd <> 0 THEN EXIT

/ / Judgment is timeout

LOOP while gettickcount () -lul_start

// No message dialog found

IF lul_hwnd = 0 THEN

Return False

Else

// Dialogue

Return of_center (0, LUL_HWND)

END IF

The OFTER's overload function code is as follows:

CCUO_THREAD.OF_CENTER (Ulong Hwndp, Ulong Hwndc) Return Boolean

// hwndp: The handle of the parent window, the value is 0, it is considered a desktop

// hwndc: Handle of the child window

INT Li_x // window of X coordinate

INT Li_Y // window Y coordinate

STC_Rect LSTC_PARENT / / Father 4 coordinates

STC_Rect LSTC_Child // 4 side coordinates of the child window

/ / The value is considered to be a desktop

IF hwndp = 0 Then HWndParent =

GetDesktopWindow ()

// get the 4 side coordinates of the window

IF not getWindowRect (hwndcurrent, lstc_child) THEN RETURN FALSE

If not getWindowRect (hwndparent, lstc_parent) THEN RETURN FALSE

Li_x = ((LSTC_Parent.right - LSTC_Parent.Left) -

(LSTC_Child.right -Lstc_Child.Left) / 2

LI_Y = ((LSTC_Parent.bottom - LSTC_Parent.top) -

(LSTC_CHILD.BOTTOM -LSTC_CHILD.TOP)) / 2

// Calculate the x, y coordinate of the subsequent window

IF li_x <0 or li_y <0 THEN RETURN FALSE

// Mobile sub-window

IF not movewindow (hwndcurrent, li_x, li_y, lstc_child.right, lstc_child.left, lstc_child.bottom - lstc_child.top, false) THEN RETURN FALSE

Return True

This document is passed under PB 7.0.

转载请注明原文地址:https://www.9cbs.com/read-31083.html

New Post(0)