2

Is it possible to create a "Command Link" button in Visual C++ (CLR/Windows Forms Application)?

I'm really happy it is described so well in the "Design Guidelines", but there isn't any code sample, nor a reference anywhere.

If you're not sure what I'm talking about: http://msdn.microsoft.com/en-us/library/windows/desktop/aa511455.aspx

Sorry if it's explained somewhere (how to use it/if it's deprecated), but my searching keeps yielding results about ASP.NET or "Command Line"...

ChrisF
  • 134,786
  • 31
  • 255
  • 325
Vultour
  • 373
  • 4
  • 15

1 Answers1

3

You might find this article helpful:

http://blogs.msdn.com/b/knom/archive/2007/03/12/command_5f00_link.aspx

The summary is that a command link is not a separate control. It's just a normal button control with two specific styles applied. You can make your own with code similar to this (original example is C# rather than C++/CLR):

public class CommandLink:Button
{
    const int BS_COMMANDLINK = 0x0000000E;

    public CommandLink()
    {
        this.FlatStyle = FlatStyle.System;
    }


    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cParams = base.CreateParams;
            cParams.Style |= BS_COMMANDLINK;
            return cParams;
        }
    }
}
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • Yeah I think i saw that somewhere... the problem is I've got the app in CLR and can't find a way to style the button... even if there is the "button->setStyle()" method, there isn't a constant for Command Link style... – Vultour Jan 30 '12 at 22:28
  • 1
    @Set - updated my answer a bit -- the code now includes the required constant. – Joel Coehoorn Jan 30 '12 at 22:29