OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 20-01-2011, 19:08
PAnderson PAnderson is offline
Member
 
Join Date: Nov 2003
Posts: 47
Default VBA Form Color Picker?

Sigh. I am trying to figure out how to do something which you macro gurus probably can do in your sleep. I want to add buttons on my form for the user to choose a color from the Fill dialog and also the Outline dialog. Most of the ones I've seen on macro forms have a small square that is a live preview of the color and then the button to bring up the dialog just has an asterisk on it.

Is there a sample form somewhere I can pick apart and study? Would it also be possible to add and eye dropper to the form as well? Seems like it should be a simple thing to figure out, but I need pointed in the right direction.

Thank you in advance...
Patti

Last edited by PAnderson; 20-01-2011 at 19:11.
Reply With Quote
  #2  
Old 20-01-2011, 19:51
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
Here's a start.
Put the top 2 subs in form's code. Create a command button called cmdGetCol
Use the bottom function in any module to retrieve the color.

-John



Code:
Option Explicit

Private Sub cmdGetCol_Click()

    Dim fillColor As New Color ' fill color
    fillColor.RGBAssign 153, 153, 153
    
    If fillColor.UserAssignEx Then
        If VersionMajor > 12 Then
            SaveSetting "Patti Macro", "Preferences", "fillColorSet", 13
            SaveSetting "Patti Macro", "Preferences", "fillColor", fillColor.ToString
        End If
    
        fillColor.ConvertToRGB
        cmdGetCol.BackColor = RGB(fillColor.RGBRed, fillColor.RGBGreen, fillColor.RGBBlue)
    
        isDark fillColor, cmdGetCol
        
    End If
    
End Sub

Private Function isDark(col As Color, cmdBut As CommandButton) As Boolean
    On Error Resume Next
    isDark = False
    col.ConvertToLab

    If col.LabLuminance < 75 Then
        isDark = True
    End If
    
    If isDark Then
        cmdBut.ForeColor = RGB(255, 255, 255)
    End If
    
End Function

Public Function getCol() As Color
    Set getCol = New Color
    Dim colSet As String, regCol As String
    
    On Error GoTo errorAssignDefaultCol
    
    getCol.RGBAssign 153, 153, 153
    colSet = GetSetting("Patti Macro", "Preferences", "fillColorSet", 0)
    regCol = GetSetting("Patti Macro", "Preferences", "fillColor")

        
    If colSet = 13 Then
        getCol.StringAssign regCol
    End If
    
Exit Function
errorAssignDefaultCol:
    getCol.RGBAssign 153, 153, 153
    
End Function
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
calling another form with a button in a form gorgo CorelDRAW/Corel DESIGNER VBA 1 27-05-2010 08:23
Font picker dialog isvaljek CorelDRAW/Corel DESIGNER VBA 2 29-03-2009 10:14
Colour Picker control Gadget CorelDRAW/Corel DESIGNER VBA 3 25-01-2008 12:01
Date Picker Tweak ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 29-10-2004 10:02
Color Replecer - not replece white color Zuk Macros/Add-ons 2 30-04-2003 01:44


All times are GMT -5. The time now is 15:09.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com