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

Choose Colour Common Dialog 64-bit

dannycat
New Contributor I
746 Views
What changes need to be made the call up the ChooseColor dialogon a64-bit platform. When I try to call up this type of dialog box I get the error message.

"Invalid structure size passed to CD"

The following code contains the subroutine where the problem occurs.

integer function ChooseNewColor( hWnd )

! ***************************************************************************
!* PURPOSE: Invokes common dialog function to chose a new color.
!*
!* COMMENTS:
!* This function initializes the CHOOSECOLOR structure for any
!* mode the user chooses: standard, using a hook or using a
!* customized template. It then calls the ChooseColor()
!* common dialog function.
!*
!* RETURN VALUES:
!* TRUE - A new color was chosen.
!* FALSE - No new color was chosen.
!*
!***************************************************************************

use dfwin
use femglobals

implicit none

! Arguments
integer(HANDLE),intent(in) :: hWnd

! Local Variables
integer :: dwColor
integer :: dwCustClrs(16)
integer :: fSetColor
integer :: i,irbg,Red,Green,Blue

! Function
integer :: grp_getcol

! Initialise
fSetColor = FALSE

do i = 1, 15
dwCustClrs(i) = grp_getcol(i,int1(Red),int1(Green),int1(Blue))
enddo
irbg = grp_getcol(1,Red,Green,Blue)
dwColor = RGB(int1(Red),int1(Green),int1(Blue) )

! Populate Colour Dialog Data Structure
chsclr%lStructSize = sizeof(chsclr)
chsclr%hwndOwner = hWnd
chsclr%hInstance = ghInstance
chsclr%rgbResult = dwColor
chsclr%lpCustColors = LOC(dwCustClrs)
chsclr%lCustData = 0
chsclr%Flags = CC_PREVENTFULLOPEN
chsclr%lpfnHook = NULL
chsclr%lpTemplateName = NULL

! Display Colour Dialog
fSetColor = ChooseColor( chsclr )
if(fSetColor.ne. 0) then
crColor = chsclr%rgbResult
ChooseNewColor = TRUE
else
call ProcessCDError(CommDlgExtendedError(),hWnd)
ChooseNewColor = FALSE
endif

end

The femglobals module contains the ghInstance variable.

Note: That in some other common dialogs, like ChoosFont, I had to change the explicit value for the %lStructSize component to the sizeof()function. I did the same here (used to be a constant 36) but it does not seem to work in this case.

0 Kudos
2 Replies
Steven_L_Intel1
Employee
746 Views
What value are you getting for lStructSize? It should be 72. You don't show it, but I assume you are using TYPE(T_CHOOSECOLOR).
0 Kudos
dannycat
New Contributor I
746 Views
What value are you getting for lStructSize? It should be 72. You don't show it, but I assume you are using TYPE(T_CHOOSECOLOR).

Yes I did use type T_CHOOSECOLOR, but I have have to apologise for being stupid in this case. The subroutine I posted does not get called!! I only realised this when I tried to set a breakpoint. The problem was that there are other similar calls elsewhere and these still had the hard coded value of 36 from the 32-bit original code.

One thing that is really frustrating though is that Visual Studio crashes every time I try the search of a string. This only occurs on one ofmy client's64-bit machines (not on the other which is always occupied!). Has anyone else experienced this problem?
0 Kudos
Reply