//////////// // FUNCTION ApiCreateRoundedRegion_(oXbp, nXLeft,nYLeft, nXRight,nYRight, nW, nH, lElipse) // Cria uma área com os cantos arredondados ou uma área em forma de círculo (ou elipse). // Esta área delimita a saída das Gra... funções à sua área, onde: // -> Xbp where the rregin will be create // [nXLeft>] -> Left Bottom axe X. Defaults to 0 // [] -> Left bottom axe Y. Defaults to 0 // [] -> Upper right axe X. (Defaults :currentSize()[01] -1) // [] -> Upper right axe Y. (Defaults :currentSize()[02] -1) // [] -> Axe X radius. (See Grabox()) // Defaults to 10 // Ignored if being .t. // [] -> Axe Y radius (See Grabox()) // Defaults to 10 // Ignored if being .t. // [] -> area to be created must to ve circular (or eliptic)? // The extension hrizontal and the height defined by the coordenates // defines this format // Defaults to .f. // The coordinates , e , will to be converted // to top down nXTop,nYTop e nXBottom,nYBottom that are used by the APIs // // The size of the area to be crested must hold the edges to be drawn. // Returns: .t. if the region could to be crated // .f. it the region could not to be created. // // Example: // ::XbpPushButton:create(oParent, oOwner, aPos, aSize, NIL, .f.) // if !ApiCreateRoundedRegion_(Self, 0,0, (aSize[01] - 1),(aSize[02] - 1), cabPUSH_RADIUS, cabPUSH_RADIUS, .f.) // ... // else // ... // endif // ///// STATIC cCallRounded, cCallElipse, cSetRegion, cCallDelete LOCAL nHandle, nXTop,nYTop, nXBottom,nYBottom, lOk if cCallRounded == NIL nHandle := ApiLoadDll_('GDI32.dll') cCallRounded := DllPrepareCall(nHandle, DLL_STDCALL, 'CreateRoundRectRgn') cCallElipse := DllPrepareCall(nHandle, DLL_STDCALL, 'CreateEllipticRgn') cCallDelete := DllPrepareCall(nHandle, DLL_STDCALL, 'DeleteObject') nHandle := ApiLoadDll_('User32.dll') cSetRegion := DllPrepareCall(nHandle, DLL_STDCALL, 'SetWindowRgn') endif // // Converting the coordinates if nXLeft == NIL nXLeft := 0 endif nXTop := nXLeft if nYLeft == NIL nYLeft := 0 endif nYBottom := nYLeft if nYRight == NIL nYRight := (oXbp:currentSize()[02] - 1) endif nYTop := nYRight if nXRight == NIL nXRight := (oXbp:currentSize()[01] - 1) endif nXBottom := nXRight // // Creating the edges if lElipse <> NIL .and.; lElipse nHandle := DllExecuteCall(cCallElipse, nXTop,nYTop, nXBottom,nYBottom) else if Empty(nW) nW := 10 endif if Empty(nH) nH := 10 endif nHandle := DllExecuteCall(cCallRounded, nXTop,nYTop, nXBottom,nYBottom, nW, nH) endif if nHandle <> 0 lOk := DllExecuteCall(cSetRegion, oXbp:getHWND(), nHandle) > 0 DllExecuteCall(cCallDelete, nHandle) else lOk := .f. endif RETURN lOk //////////// // FUNCTION ApiLoadDll_(cDll, cError) // Loads a Dll, where: // -> Name of the DLL for to be loaded. // Its extension is not needed // [@] -> Error message if could not to be loaded // Returns the Dll handle or 0 if it could not to be loaded. // ///// STATIC aDllLoaded := {} // Dlls carregadas: {{cDllName, nDllHandle}, ...} LOCAL nDllHandle cDll := Lower(AllTrim(cDll)) if Right(cDll, 4) <> '.dll' cDll += '.dll' endif nDllHandle := AScan(aDllLoaded, {|x| x[01] == cDll}) if nDllHandle > 0 nDllHandle := aDllLoaded[nDllHandle, 02] else nDllHandle := DllLoad(cDll) if nDllHandle > 0 AAdd(aDllLoaded, {cDll, nDllHandle}) else cError := DosErrorMessage(DosError()) endif endif RETURN nDllHandle