IPBX_VisualObject interface

Description

The IPBX_VisualObject interface inherits from IPBX_UserObject and is the direct ancestor class of visual PowerBuilder native classes.

Methods

IPBX_VisualObject has three direct methods:

CreateControl

GetEventID

GetWindowClassName

IPBX_NonVisualObject inherits two methods from the IPBX_UserObject interface:

Destroy

Invoke

CreateControl

Description

Creates a window control and returns its handle to the PowerBuilder VM.

Syntax

CreateControl(DWORD dwExStyle, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HINSTANCE hInstance)

Argument

Description

dwExStyle

The extended window style

lpWindowName

The window name

dwStyle

The window style

x

The horizontal position of the window

y

The vertical position of the window

nWidth

The window's width

nHeight

The window's height

hWndParent

The handle of the parent or owner window

hInstance

The handle of the application instance


Return value

HWND.

Examples

This is part of a visual extension example available on the Appeon Web site:

LPCTSTR CVisualExt::GetWindowClassName()
{
return s_className;
}

HWND CVisualExt::CreateControl
(
DWORD dwExStyle, // extended window style
LPCTSTR lpWindowName, // window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HINSTANCE hInstance // handle to application instance
)
{
d_hwnd = CreateWindowEx(dwExStyle, s_className,
lpWindowName, dwStyle, x, y, nWidth, nHeight,
hWndParent, NULL, hInstance, NULL);

::SetWindowLong(d_hwnd, GWL_USERDATA, (LONG)this);

return d_hwnd;
}

Usage

The window must be registered before you call CreateControl.

See also

GetEventID

GetWindowClassName

GetEventID

Description

Returns the identifier of an event when the window's parent is notified that the event occurred.

Syntax

GetEventID(HWND hWnd, uint iMsg, WPARAM wParam, LPARAM lParam)

Argument

Description

hWnd

The handle of the parent window.

iMsg

The message sent to the parent.

wParam

The word parameter of the message.

For WM_COMMAND, the high-order word specifies:

  • The notification code if the message is from a control

  • 1 if the message is from an accelerator

  • 0 if the message is from a menu.

The low-order word specifies the identifier of the control, accelerator, or menu.

For WM_NOTIFY, this parameter contains the identifier of the control sending the message.

lParam

The long parameter of the message.

For WM_COMMAND, this parameter contains the handle of the control sending the message if the message is from a control. Otherwise, this parameter is null.

For WM_NOTIFY, this parameter contains a pointer to a structure.


Return value

Integer.

Examples

In this example, the GetEventID function returns the identifier PB_BNCLICKED if a WM_COMMAND message with the notification code BN_CLICKED was sent. It returns the identifier PB_ENCHANGE if a WM_NOTIFY message was sent; otherwise it returns PB_NULL.

TCHAR CVisualExt::s_className[] = "PBVisualExt";

LPCTSTR CVisualExt::GetWindowClassName()
{
return s_className;
}

HWND CVisualExt::CreateControl
(
DWORD dwExStyle,// extended window style
LPCTSTR lpWindowName,// window name
DWORD dwStyle,// window style
int x,// horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle of parent or owner window
HINSTANCE hInstance// handle of application instance
)
{
d_hwnd = CreateWindowEx(dwExStyle, s_className,
lpWindowName, dwStyle, x, y, nWidth, nHeight,
hWndParent, NULL, hInstance, NULL);

::SetWindowLong(d_hwnd, GWL_USERDATA, (LONG)this);

return d_hwnd;
}

int CVisualExt::GetEventID(
HWND	hWnd, /* Handle of parent window */
UINT	iMsg, /* Message sent to parent window*/
WPARAM	wParam, /* Word parameter of message*/
LPARAM	lParam /* Long parameter of message*/
)
{
if (iMsg == WM_COMMAND)
{
if ((HWND)lParam == d_hwnd)
{
switch(HIWORD(wParam))
{
case BN_CLICKED:
return PB_BNCLICKED;
break;
}
}
}

if (iMsg == WM_NOTIFY)
{
return PB_ENCHANGE;
}
return PB_NULL;
}

Usage

This function is used to process Windows messages, such as WM_COMMAND and WM_NOTIFY, that are sent to the parent of an object and not to the object itself. Such messages cannot be caught in the visual extension's window procedure. The PBVM calls GetEventID to process these messages.

If the message is mapped to a PowerBuilder event, GetEventID returns the event's identifier, for example PB_BNCLICKED, and the event is fired automatically. PowerBuilder event token identifiers are mapped to unsigned integer values in the pbevtid.h header file. The identifiers in pbevtid.h are associated with PowerBuilder event token names. For example, the identifier PB_BNCLICKED is associated with the token name pbm_bnclicked.

If the message is not mapped to an event, GetEventID returns the value PB_NULL and the message is discarded.

See also

CreateControl

GetWindowClassName

GetWindowClassName

Description

Returns the name of the window.

Syntax

GetWindowClassName()

Return value

LPCTSTR.

Examples

The string returned by GetWindowClassName is passed as an argument to the CreateControl method:

LPCTSTR CVisualExt::GetWindowClassName()
{
return s_className;
}

Usage

The window must be registered before you call GetWindowClassName.

See also

CreateControl

GetEventID