#define WIN_INCLUDEALL
#include "windows.bi"
DIM AS CHOOSECOLOR PTR cc 'common dialog box structure
DIM AS UINTEGER PTR acrCustClr 'custom colors (16x4 bytes) -> Speicher dynamisch anfordern
DIM AS HWND hwnd 'owner window
DIM AS HBRUSH hbrush 'brush handle
DIM AS UINTEGER rgbCurrent 'initial color selection
rgbCurrent = &HFF00FF 'Rosa als Voreinstellung - initial selection: pink
cc = CAllocate(sizeof(CHOOSECOLOR))
acrCustClr = CAllocate(64)
cc->lStructSize = Cast(UInteger,sizeof(CHOOSECOLOR))
cc->hwndOwner = hwnd
cc->lpCustColors = CAST(LPDWORD, acrCustClr)
cc->rgbResult = rgbCurrent
cc->Flags = CC_FULLOPEN Or CC_RGBINIT
if (ChooseColor(cc) = TRUE) Then
hbrush = CreateSolidBrush(cc->rgbResult)
rgbCurrent = cc->rgbResult
'Print "OK, alles klar! Gewaehlter Farbwert (hexadezimal): "; HEX(rgbCurrent, 8)
Print "Ok, no error! Selected color: "; HEX(rgbCurrent, 8)
Else
'Print "Fehler: Aktion durch Benutzer abgebrochen oder Aufruf fehlgeschlagen."
Print "Error: action aborted by the user or selection failed."
End If
Sleep
End
Worked well with previous versions of FreeBasic, but not with version 1.04 (32 bit and 64 bit), result is always 0.
if (ChooseColor(cc) = Not TRUE) Then
'Print "Fehler: Aktion durch Benutzer abgebrochen oder Aufruf fehlgeschlagen."
Print "Error: action aborted by the user or selection failed."
Else
hbrush = CreateSolidBrush(cc->rgbResult)
rgbCurrent = cc->rgbResult
'Print "OK, alles klar! Gewaehlter Farbwert (hexadezimal): "; HEX(rgbCurrent, 8)
Print "Ok, no error! Selected color: "; HEX(rgbCurrent, 8)
the Example will only work with 32bit Compiler! This should be corrected!
For it to work correctly with all Compiler Versions, you'd have to replace the
UInteger Stuff with ULong (also the Pointer = ULong Ptr), since Color is a fixed
UINT32, consisting of four UBytes(a, r, g, b).
Proof: your HEX output ... HEX(nnnn, 8) = 4 x UByte = 1 x ULong (2 per UByte).