Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link Windows API: Saving and restoring custom colors for ColorDialog 2003-09-10 -- Larry Sand Newsgroups: softvelocity.products.c55ee
| > The ChooseColor common dialog is really easy to call. Shout
| > if you need an example.
|
| Sure, fire away.
!============================================
! Using the ChooseColor common dialog in Clarion
! Written by Larry Sand
!============================================
PROGRAM
CC_RGBINIT EQUATE(00000001h)
CC_FULLOPEN EQUATE(00000002h)
CC_PREVENTFULLOPEN EQUATE(00000004h)
CC_SHOWHELP EQUATE(00000008h)
CC_ENABLEHOOK EQUATE(00000010h)
CC_ENABLETEMPLATE EQUATE(00000020h)
CC_ENABLETEMPLATEHANDLE EQUATE(00000040h)
CC_SOLIDCOLOR EQUATE(00000080h)
CC_ANYCOLOR EQUATE(00000100h)
_CHOOSECOLOR GROUP,TYPE
lStructSize UNSIGNED
hwndOwnder UNSIGNED
hInstance UNSIGNED
rgbResult LONG
lpCustColors LONG
Flags UNSIGNED
lCustData LONG
lpfnHook LONG
lpszTemplateName LONG
END
NCUSTOMCOLORS EQUATE(16)
MAP
MODULE('Win32Api')
ChooseColor(*_CHOOSECOLOR lpcc|
), BOOL, PASCAL, RAW, NAME('ChooseColorA'), PROC
END
END
W WINDOW('Using the ChooseColor dialog Win32'),AT(,,277,179),|
FONT('MS Sans Serif',8,,),SYSTEM
BUTTON('Choose Color'),AT(9,12,55,14),USE(?ChooseColorButton)
END
cc LIKE(_CHOOSECOLOR)
aCustomColors LONG,DIM(NCUSTOMCOLORS),AUTO
i LONG,AUTO
hwndW UNSIGNED,AUTO
Code
Open(W)
hwndW = W{PROP:Handle}
!-------------------------------------------
!First inintialize the custom color array to
!all white. Or use your serialized values.
!-------------------------------------------
LOOP i = 1 TO NCUSTOMCOLORS
aCustomColors[i] = COLOR:White
END
ACCEPT
IF FIELD() = ?ChooseColorButton
IF EVENT() = EVENT:Accepted
!-------------------------------------------
! Initialize the CHOOSECOLOR structure. See
! MSDN for all of the options. Here, I'm telling
! the color dialog to select and display the color
! specified in cc.rgbResult and show the expanded
! dialog for the custom color picker.
!-------------------------------------------
cc.lStructSize = SIZE(cc)
cc.hwndOwnder = hwndW
cc.Flags = BOR(CC_RGBINIT, CC_FULLOPEN )
cc.lpCustColors = ADDRESS(aCustomColors)
!-------------------------------------------
! Before calling the common dialog you must
! call unlockthread in Clarion versions < C6
!-------------------------------------------
UNLOCKTHREAD()
ChooseColor(cc) !ChooseColor returns 0 when you click the Cancel button
LOCKTHREAD()
! Show the result by changing the client area to the selected color
W{PROP:Color} = cc.rgbResult
END
END
END
RETURN
Today is November 21, 2024, 6:32 am This article has been viewed 35377 times. Google search has resulted in 70 hits on this article since January 25, 2004.
|
|