Author Topic: Color Dialog Wiki Example 64 Bit  (Read 1049 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Color Dialog Wiki Example 64 Bit
« on: June 23, 2020, 08:59:50 am »
Hello, all. I successfully took the Color Dialog Wiki example and made it work in 64 bit as well. Here is the code. Enjoy!
I know it isn't too much of a conversion but I'm posting it in case someone was needing it.
"BI"
Code: QB64: [Select]
  1.     ' Color Dialog flag constants (use + or OR to use more than 1 flag)
  2.     CONST CC_RGBINIT = &H1& '           Sets the initial color
  3.     CONST CC_FULLOPEN = &H2& '          Opens all dialog sections such as the custom color selector
  4.     CONST CC_PREVENTFULLOPEN = &H4& '   Prevents the user from opening the custom color selector
  5.     CONST CC_SHOWHELP = &H8& '          Shows the help button (USELESS!)
  6.     '----------------------------------------------------------------------------------------
  7.     $IF 32BIT THEN
  8.         TYPE COLORDIALOGTYPE
  9.             lStructSize AS LONG
  10.             hwndOwner AS LONG
  11.             hInstance AS LONG
  12.             rgbResult AS LONG
  13.             lpCustColors AS _OFFSET
  14.             flags AS LONG
  15.             lCustData AS LONG
  16.             lpfnHook AS LONG
  17.             lpTemplateName AS _OFFSET
  18.         END TYPE
  19.     $ELSE
  20.         TYPE COLORDIALOGTYPE
  21.         lStructSize AS _INTEGER64
  22.         hwndOwner AS _INTEGER64
  23.         hInstance AS _INTEGER64
  24.         rgbResult AS _INTEGER64
  25.         lpCustColors AS _OFFSET
  26.         flags AS _INTEGER64
  27.         lCustData AS _INTEGER64
  28.         lpfnHook AS _INTEGER64
  29.         lpTemplateName AS _OFFSET
  30.         END TYPE
  31.     $END IF
  32.  
  33.  
  34.     DECLARE DYNAMIC LIBRARY "comdlg32"
  35.         FUNCTION ChooseColorA& (DIALOGPARAMS AS COLORDIALOGTYPE) '    Yet the also famous color dialog box
  36.     END DECLARE
  37.     'EXAMPLE USAGE: clr~& = ChooseColor&(_RGB32(0, 0, 0), Cancel, CC_FULLOPEN, _WINDOWHANDLE)
"BM"
Code: QB64: [Select]
  1.     FUNCTION ChooseColor& (InitialColor&, Cancel, Flags&, hWnd&)
  2.         DIM ColorString AS STRING * 64
  3.         ColorString = SPACE$(10)
  4.  
  5.     DIM ColorCall AS COLORDIALOGTYPE
  6.  
  7.     ColorCall.rgbResult = _RGB32(_BLUE32(InitialColor&), _GREEN32(InitialColor&), _RED32(InitialColor&))
  8.     ColorCall.lStructSize = LEN(ColorCall)
  9.     ColorCall.hwndOwner = hWnd&
  10.     ColorCall.flags = Flags&
  11.     ColorCall.lpCustColors = _OFFSET(CustomColors$)
  12.  
  13.     ' Do dialog call
  14.     Result = ChooseColorA(ColorCall)
  15.     IF Result THEN
  16.         rgbResult& = ColorCall.rgbResult
  17.         ' Swap RED and BLUE color intensity values using _RGB
  18.         ChooseColor& = _RGB(_BLUE32(rgbResult&), _GREEN32(rgbResult&), _RED32(rgbResult&))
  19.     ELSE
  20.         Cancel = -1
  21.     END IF
Shuwatch!

FellippeHeitor

  • Guest
Re: Color Dialog Wiki Example 64 Bit
« Reply #1 on: June 23, 2020, 09:01:48 am »
Much appreciated, @SpriggsySpriggs. Would you be interested in wiki access so these contributions/fixes can also be applied there?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Color Dialog Wiki Example 64 Bit
« Reply #2 on: June 23, 2020, 09:02:54 am »
Much appreciated, @SpriggsySpriggs. Would you be interested in wiki access so these contributions/fixes can also be applied there?
That would be absolutely amazing, Fellippe.
Shuwatch!

FellippeHeitor

  • Guest
Re: Color Dialog Wiki Example 64 Bit
« Reply #3 on: June 23, 2020, 09:05:47 am »
Check your email.