Jump to content

Message Dialog ActiveX Control Usage


MilesAhead
 Share

Recommended Posts

I wrote an ActiveX Control several years ago to do standard Windows MessageBox type Dialogs with custom background colors and drawing styles. Unfortunately the optional Help Button doesn't fire the event properly in interpreters but you can still use the control to provide an unusual but consistent look to your dialogs with various programming languages.

It should work with interpreters that support COM such as AutoIt3 and PythonWin. I've been using it quite a bit with compiled languages such as VC++ 6, VB 6, C# and Delphi 5 and I think I've gotten all the bugs out of it over the years.

Anyway you can mess around with it for free if you like. Here's an example script to display a few dialogs from AutoIt3.

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.12.1
    Author:      MilesAhead
    
    Script Function: simple example usage of GradDlgX ActiveX Control
    
    Install Control: download Faves Trial from http://www.favessoft.com/favestrial.zip
                     and run the setup program.

    Uninstall:    Uninstall Faves using Add/Remove Programs
    
    Docs:         You can download a rudimentary .chm file from
                   http://www.favessoft.com/GradDlgHelp.zip
    
    Note 1 : if you don't want to use Faves you can try installing it twice, then
             uninstall it.  This may leave the ActiveX Control on your system
             registered(may or may not work but I seem to remember doing it
             successfully.)  To remove manually run regsvr32 /u GradDlgXControl1.ocx
             from an administrative command prompt in your system directory
             (usually it's C:\Windows\system32)
          
    Note 2 : I removed the design-time license from the ActiveX Control partly
             so that it can be created dynamically by interpreters that support
             COM.  Since the control is now unprotected I figured I might as
             well make it available.  Note that if you have Faves Free installed
             on your system it uses the GradDlg ActiveX Control with the license.
             So you want to uninstall it before installing the Faves Trial. (After
             you uninstall double check it removed the .ocx from the system folder.)
             
    Note 3 : When plugging color1 and color2 into the control for the Execute()
             method, many times you will get mud, but there are probably a dozen
             or more color combinations that look really cool.  It's just an
             algorithm I came up with when messing around with user draw for
             message dialogs. I used the same algorithm for the backgroud of
             this utility: http://www.favessoft.com/FileCRC32Shot.html
             just to give you an idea.
             
#ce ----------------------------------------------------------------------------

$grad = ObjCreate("GradDlgXControl1.GradDlgX")
$grad.GradStyle = 1; use 0 for metalic gradient look
;background colors light pink and white
$grad.Color1 = 0xC186FF
$grad.Color2 = 0xFFFFFF
;red font
$grad.FontColor = 0x0000FF
;draw horizontally
$grad.GradDirect = 1

;using GradDlg Execute function where you can customize
;background and font colors.  Canned dialogs are provided
;with set color schemes but Execute lets you experiment
$grad.Execute("This is Execute!",0,-1)

;always use -1 as help context(last param) with interpreters since
;the event won't fire until after the dialog closes.  With compiled
;languages;such as VC++,Delphi,VC,C# pressing the Help button on the
;dialog will fire an event with help context as param while the dialog
;is still showing.  An easy handler would be to use ShellExecute
;to open a readme file or you can even nest invocations of GradDlg
;dialog boxes.  The dialogs are independent of each other but read
;properties from the base control so it's advised to save and restore
;to and from local vars if you change properties of the ActiveX Control.
;like MsgBox, if you have CRLFs in the message text, the dialog will expand
;to accommodate the message.
If $grad.ConfirmDlg("Sure you want to do this?", True, 1, -1) = 1 Then
    $grad.InfoDlg("You Pressed OK", True, 0, -1)
EndIf
$grad.ErrorDlg("Example Error Message!",True,1,-1)
$grad.WarnDlg("Warning: Example Warning Message!",True,1,-1)
$grad = 0
Link to comment
Share on other sites

  • 2 months later...

I updated the Help File

for this control. The zip file has a small AutoIt example script showing how to set

a few of the dialog styles. The last param of every dialog display method should

be -1 so that no Help Button will be displayed in the dialog. The help button events

work in true compiled languages but are of no use in AutoIt.

Still if you mess around you can create some interesting background color schemes.

Plus you can easily give the same look to message box dialogs if you are coding

in VB, VC++ .. C# Delphi AutoIt or ActivePython for Windows etc..

Hope somebody enjoys using it. I've been messing around with it for 7 years or

so. :)

edit: btw I included the .ocx in the just updated help zip file with instructions to install it directly

Edited by MilesAhead
Link to comment
Share on other sites

sry was mistaken nice one really

That's ok. After I posted I figured it's prolly just ObjCreate() got an error.

The Gradient style will work with just about anything. The stlAverage is

something I found sort of by accident while messing with a Paint handler.

I just added the colors and shifted bits around until I got some that looked

good. There's probably only a couple of dozen really cool ones that come out.

On my site there's FileCRC32 checksum program that you can use as a sort of

quick and dirty trial of the colors. If you change the colors in the .ini file and

restart it paints using those. Unfortunately there are a bunch of combinations

that come up mud and many end up some flavor of purple. But there's a few

nuggets if you mess around with it. :)

Link to comment
Share on other sites

It would be nice if it wouldn't require to install that.

I know what you mean. When I do a Delphi program I just use the control. But to use with other languages you need the ActiveX. Actually the install and uninstall is pretty easy with Inno Setup. I took the design time licensing off since C# express was a pita about installing in the toolbox. It seems to install in C# ok in XP but Visual Studio Express 2008 didn't like Vista last time I tried installing the IDE.

There are some properties that are stored in the control. I did that to reduce the number of params in the dialg calls. Some of them do need to be saved and restored across calls. But the nice thing about the design is that the dialog is created dynamically. So the handler for the Help Button can even be another dialog from the control. I'm working on a small C# demo since that's a free IDE that at least works in XP. It will show using both the TellTail one instance control, and the dialog control.

The gradient paint uses straight Jedi VCL Gradient line drawing code. Maybe in a bit I'll release the Delphi source for the stlAverage paint.

I'll be uploading the help zip again soon and it will have the C# demo if anyone does C#. With that I can show some of the event handling.

Link to comment
Share on other sites

@MilesAhead

No need for installing any ActiveX DLL if you use the MS SxS Manifest approach

Regards

ptrex

That may be valuable if you have code that is >=XP only. My .ocx controls

work on Win98 on up so there'd really be no value in my doing that.

Copying the .ocx and registering it, unregistering and deleting, are taken care

of quite easily using Inno Setup. One line in the Files section for each .ocx does it.

The .exe generated by Inno Setup is a vanilla 32 bit exe program so that spans

Win98 on up too at least for 32 bit stuff.

If you really don't like doing an installer you can always call the DllRegisterServer()

functions with your code.

As it is, my controls are of limited utility in AutoIt and Python anyway. Just thought

some of the programmers here may dabble in other languages with IDEs where they'd

be more useful. They were more fun before MS messed up Visual Studio. In VB 6

and VC++ 6 Dialog editors the GradDlg control had a custom property page with

a color picker dialog to set the colors and built in help. Press F1 when it had the

focus in the dialog editor and .hlp help came up. Somewhere along the way

MS broke all that support. Oh well, at least the code works in VS2008 :)

edit: apparently the property page still works in this control.

If in Visual Studio after you drop on the form if you right click

and select Properties the form will come up. If you click on

one of the color buttons the color picker dialog comes up.

I don't have the help with it since it's old style .hlp. Just

use the .chm help from the zip file.

Edited by MilesAhead
Link to comment
Share on other sites

@MilesAhead

My .ocx controls

work on Win98 on up so there'd really be no value in my doing that.

I am sorry to say that MS SxS has nothing to do with coding ?!

Only a way of distributing DLL / OCX files without registring them.

You don't have to change a comma in your code to do that.

Regards,

ptrex

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...