Announcement

Collapse
No announcement yet.

ChooseColor blues

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ChooseColor blues

    I wrote a small function to encapsulate the ChooseColor dialog box,

    Code:
    Function SelectColor(ByVal hParent As Long, ByVal iStartColor As Long, ByVal iUseExt As Long) As Long
     Local cca As ChooseColorApi
     cca.hinstance = 0
     cca.lStructSize = SizeOf(cca)
     cca.Flags    = %CC_RGBINIT
     If iUseExt = 0 Then cca.Flags = cca.Flags Or %CC_PREVENTFULLOPEN
     cca.hwndowner = hParent
     cca.rgbResult = iStartColor
     If ChooseColor(cca) Then Function = cca.rgbResult
    End Function
    But when I run the code under Win 98 it drains 20% of system resources, no dialog box shows, but pressing Ctrl+Alt+Del reveals the program is still running. The program will only terminate after about 3 ctrl+alt+del key presses.

    In the PB\DLL debugger a GPF is reported and the machine totally locks up and only the reset button is the cure.

    I have transferred the program to my website, at:
    www.kgpsoftware.freeserve.co.uk/color.exe

    Can anyone help ?


    -------------
    Kev G Peel
    KGP Software
    Bridgwater, UK.
    mailto:[email protected][email protected]</A>

  • #2
    I think you need to add an array for the custom color boxes, even
    if you don't use them. The following should work:

    Code:
    Function SelectColor(ByVal hParent As Long, ByVal iStartColor As Long, ByVal iUseExt As Long) As Long
      Local cca As ChooseColorApi
      DIM ccTemp(16) AS STATIC DWORD
     
      cca.hinstance    = 0
      cca.lStructSize  = SizeOf(cca)
      cca.lpCustColors = VARPTR(ccTemp(0))  '<-- !!
      cca.Flags        = %CC_RGBINIT
      If iUseExt = 0 Then cca.Flags = cca.Flags Or %CC_PREVENTFULLOPEN
      cca.hwndowner    = hParent
      cca.rgbResult    = iStartColor
     
      If ChooseColor(cca) Then Function = cca.rgbResult
    
    End Function
    ------------------


    [This message has been edited by Borje Hagsten (edited April 26, 2000).]

    Comment


    • #3
      Cheers Borje!

      That did the trick

      Regards,

      ------------------
      Kev G Peel
      KGP Software
      Bridgwater, UK.
      mailto:[email protected][email protected]</A>

      Comment

      Working...
      X