PBX_DrawVisualObject
Description
Draws a visual object in the PowerBuilder development
environment.
Syntax
|
1 |
PBX_DrawVisualObject(HDC hDC, LPCTSTR className, const PBX_DrawItemStruct& property) |
|
Argument |
Description |
|---|---|
|
hDC |
A handle to the device context of the |
|
classname |
The name of the visual extension object to be |
|
property |
A PBX_DrawItemStruct structure specifying the |
Return value
PBXRESULT. The return value of this function is currently
ignored.
Examples
This is an extension of a sample that is available on the
PowerBuilder Code Samples website at https://community.appeon.com/index.php/codeexchange/powerbuilder.
It draws a representation of a light-emitting diode (LED) and uses
Microsoft Foundation Classes (MFC):
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
PBXEXPORT PBXRESULT PBXCALL PBX_DrawVisualObject ( HDC hDC, LPCTSTR xtraName, const PBX_DrawItemStruct& property ) { // If this PBX is dynamically linked against the MFC // DLLs, any functions exported from this PBX that //call into MFC must have the AFX_MANAGE_STATE macro // added at the very beginning of the function. AFX_MANAGE_STATE( AfxGetStaticModuleState() ); // Variables to hold the Led control and a pointer // to Device Context CLed *myLed; CDC* pDC; // The name must not contain uppercase letters if ( strcmp( xtraName, "u_cpp_led" ) == 0 ) { CRect rc( property.x, property.y, property.x + property.width, property.y + property.height ); //Create a new LED myLed = new CLed(); // Get the handle from the hDC pDC = CDC::FromHandle(hDC); CWnd* pWnd = pDC->GetWindow(); // Create the window myLed->Create(NULL, WS_CHILD | WS_VISIBLE | SS_BITMAP, rc, pWnd); // Function that handles the background // rendering of the control myLed->OnEraseBkgndIDE(pDC); // Draw the LED in default mode (red, on, round) myLed->DrawLed(pDC,0,0,0); myLed->SetLed(0,0,0); //done delete myLed; } return PBX_OK; } |
Usage
In a visual extension, export this function if you want the visual
control to be drawn in the development environment. If you do not export
the function, you need to run the application to see the appearance of
the visual control.
See also