Results 1 to 10 of 10

Thread: HTML Code that Refers to CommonDialog ActiveX Control

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    HTML Code that Refers to CommonDialog ActiveX Control

    Some of you may have seen this thread which is about a tool for formatting forum posts. It's been reported by one user who has VB.Net installed that they get a "You Need to Have CommonDialog ActiveX Control Installed" error when they try to use the application's Gradient function. Here is the html code that refers to the common dialog.

    VB Code:
    1. Function GetColor(msg)
    2. Dim Dlg
    3. On Error Resume Next
    4. Set Dlg = CreateObject("MSComDlg.CommonDialog")
    5.   If Err.Number = 0 Then
    6.     Err.Clear
    7.     oWindow.alert(msg)
    8.     Dlg.CancelError = True
    9.     Dlg.ShowColor()
    10.     If Err.Number = 0 Then
    11.       Err.Clear
    12.       GetColor = Clng(Dlg.Color)
    13.       Set Dlg = Nothing
    14.     End If
    15.   Else
    16.       GetColor = -1
    17.   End If
    18. End Function
    I have two questions.
    • Have any of you that have VB.Net installed ever used the Gradient function in the forum tool app?
    • How can I modify the above code so that a VB.Net person can use it?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I never use the gradient bit but I also can't see a good .NET replacement for that. If you know they have the .NET framework and are in a .NEt assembly then you can reference the ColorDialog object but I don't see how that can work via the web.

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Or build another version for .NET platforms and users, so this would be fair to both .......

  4. #4

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    By writing it in any .NET language . ........

  6. #6

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Originally posted by Pirate
    By writing it in any .NET language .:eek: ........:D
    I was trying to be serious and if anyone can modify the code I posted above I'd appreciate it. Here's the complete code:

    VB Code:
    1. <!--
    2. +---------------------------------------------------------------------------+
    3.         VB-WORLD Forums - Tagging Scripts 1.0
    4.         Programmed By G.Kumaraguru {Active}
    5.             [email][email protected][/email]
    6. +---------------------------------------------------------------------------+
    7. -->
    8.  
    9. <SCRIPT LANGUAGE = "VBScript">
    10. Dim oWindow,oDocument,oSelect,oSelectRange,Clr
    11. Set oWindow = window.external.menuArguments
    12. Set oSource = oWindow.event.srcElement
    13. Set oDocument = oWindow.document
    14. Set oSelect = oDocument.selection
    15. Set oSelectRange = oSelect.createRange()
    16. If oSource.tagName = "TEXTAREA" Then
    17.  StrtClr = GetColor("Choose The Starting color")
    18.   If StrtClr = -1 Then
    19.    oWindow.alert("You Need to Have CommonDialog Activex Control Installed!")
    20.   Else
    21.     EndClr = GetColor("Choose the Ending Color")
    22.     oSelectRange.text = CodeGrad(oSelectRange.text,StrtClr,EndClr)
    23.   End If
    24. End If
    25.  
    26. Function CodeGrad(Src,StrtClr,EndClr)
    27.  If Src = "" Then Exit Function
    28.  Dim ResString,CChar,HexClr,CC,j,Pcent
    29.  
    30.   For j = 1 To Len(Src)
    31.     CChar = Mid(Src, j, 1)
    32.     Pcent = (j / Len(Src)) * 100
    33.  
    34.     If Asc(CChar) <> 13 And Asc(CChar) <> 10 Then
    35.         CC = GradientColor(StrtClr, EndClr, Pcent)
    36.         ResString = ResString & "[Color=" & Chr(34) & HexColor(CC) & Chr(34) & "]" & CChar & "[/Color]"
    37.     Else
    38.         ResString = ResString & CChar
    39.     End If
    40.   Next
    41.   CodeGrad = ResString
    42. End Function
    43.  
    44. Function HexColor(Color)
    45. Dim Red,Green,Blue
    46.   Red = Color And &HFF&          
    47.   Green = (Color And &HFF00&) \ 256
    48.   Blue = (Color And &HFF0000) \ 65536
    49. HexColor = "#" & Hexify(Red) & Hexify(Green) & Hexify(Blue)
    50. End Function
    51.  
    52. Function Hexify(Color)
    53.  Dim HexNum
    54.  HexNum = Hex(Color)
    55.  If Len(HexNum) = 1 Then
    56.         HexNum = "0" & HexNum
    57.  End If
    58.  Hexify = HexNum
    59. End Function
    60.  
    61. Function GetColor(msg)
    62. Dim Dlg
    63. On Error Resume Next
    64. Set Dlg = CreateObject("MSComDlg.CommonDialog")
    65.   If Err.Number = 0 Then
    66.     Err.Clear
    67.     oWindow.alert(msg)
    68.     Dlg.CancelError = True
    69.     Dlg.ShowColor()
    70.     If Err.Number = 0 Then
    71.       Err.Clear
    72.       GetColor = Clng(Dlg.Color)
    73.       Set Dlg = Nothing
    74.     End If
    75.   Else
    76.       GetColor = -1
    77.   End If
    78. End Function
    79.  
    80.  
    81. Function GradientColor(ByVal A,ByVal B,ByVal p)
    82.  If p > 100 Or p < 0 Then Exit Function
    83.  If A > 16777215 Or A < 0 Then Exit Function
    84.  If B > 16777215 Or B < 0 Then Exit Function
    85.    Dim rStart,gStart,bStart,rEnd,gEnd,bEnd
    86.         bStart = Int(A / 65536)
    87.     gStart = Int((A - bStart * 65536) / 256)
    88.     rStart = Int(A - gStart * 256 - bStart * 65536)
    89.     bEnd = Int(B / 65536)
    90.     gEnd = Int((B - bEnd * 65536) / 256)
    91.     rEnd = Int(B - gEnd * 256 - bEnd * 65536)
    92.     GradientColor = RGB(rStart - ((rStart - rEnd) * (p / 100)), gStart - ((gStart - gEnd) * (p / 100)), bStart - ((bStart - bEnd) * (p / 100)))
    93. End Function
    94.  
    95.  
    96. </SCRIPT>

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I think it'd be easiest to just have the user download/install the CommonDialog control.
    Last edited by Edneeis; Dec 29th, 2003 at 03:27 PM.

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Yes , I was serious too . I thought that vb application which can be very easily written in VB.NET , not vb script . Anyways , as Edneeis said it's easier to let the user d/l the file .

  9. #9
    Addicted Member rdove's Avatar
    Join Date
    Dec 2002
    Location
    Indianapolis
    Posts
    251
    Originally posted by Edneeis
    I think it'd be easiest to just have the user download/install the CommonDialog control.
    Or you could just include it in the installation file
    ~Ryan





    Have I helped you? Please Rate my posts.

  10. #10
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Re: HTML Code that Refers to CommonDialog ActiveX Control

    Hi,

    I realise that this a very old thread. I recently upgraded to windows 7 64bit and no longer have vb6 installed, I've just been on the forum and tried to use the highlight option on the vbforum tool and got the error "You need to have CommonDialog Activex Control installed!"

    1. Download "comdlg32.ocx" off the net http://www.martin2k.co.uk/vb6/vb6download4.php
    2. Save it to "C:\windows\system32"
    3. Register it - Open the cmd prompt, with run as administrator
    4. Type in "REGSVR32 comdlg32.ocx" without the quotes press return, should get a confirmation message that the control was successfully registered.
    5. Restart your browser IE (32bit version only)
    6. Try using the tool again.


    Please note that this still doesn't work with the 64bit version of IE.

    Cheers Al

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width