Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Picture Control

jaeger0
Beginner
551 Views

I'm trying to make a color selector dialog.

The Dialog consists of three sliders (reg,green,blue), and an "Picture Control" with type set to Bitmap.
So I create the bitmap with

hBitmap_Image=CreateBitmap(64,64,3,8,

Loc(hBitmap_pixels))

, in the update subroutine of the slider I call

retlog = SetBitmapBits(hBitmap_Image, col,

LOC( hBitmap_pixels)) ! update color col
! update the bitmap in the dialog
retlog = DLGSENDCTRLMESSAGE(dlg,IDC_COLDLG_IMG, STM_SETIMAGE,IMAGE_BITMAP,hBitmap_Image)

I get TRUE for the two functions, but nothing hapened in the Dialog. Any fundamental error ?

0 Kudos
1 Reply
Paul_Curtis
Valued Contributor I
551 Views

1. Drawing a bitmap is somewhat more complicated. You need to create a PaintStruct by calling BeginPaint (and then signal the end of the activity with EndPaint), and then draw the bitmap using the design context which is returned as a component of the PaintStruct. I can provide a code sample for this, but it's long and complex.

2. If your goal is simply to have a color-picker, for which the bitmap is just a small region showing the currently selected color value, it's much easier to do this with a rectangle which can be filled with a selected color.

3. Or, simpler still, you could use the Windows ColorPicker common dialog:

LOGICAL FUNCTION CmnDlgChooseColor(hwndParent, color)

IMPLICIT NONE

INTEGER, INTENT(IN) :: hwndParent
INTEGER, INTENT(INOUT) :: color

TYPE(T_CHOOSECOLOR) :: cc

cc%lStructSize = SIZEOF(cc)
cc%hwndOwner = hwndParent
cc%lpCustColors = LOC(customColors)
cc%rgbResult = color
cc%Flags = CC_RGBINIT

IF(ChooseColor(cc)) THEN
CmnDlgChooseColor = .TRUE.
color = cc%rgbResult
ELSE
CmnDlgChooseColor = .FALSE.
END IF

END FUNCTION CmnDlgChooseColor

0 Kudos
Reply