Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

FontDialog1.Handle problem

Dear Experts,

I fount this procedure to hide the Size combobox
of the fontdialog-component:

procedure TMainForm.FontDialog1Show(Sender: TObject);
  function EnumChildren(hwndChild: HWND; lParam: Integer): BOOL; stdcall;
  begin
     ShowWindow(hwndChild, SW_HIDE);
     result:=True;
  end;

begin
  // 1090 is the Dialog ID for the size label
  ShowWindow(GetDlgItem(FontDialog1.Handle, 1090), SW_HIDE);
  // 1138 is the dialog for the size combo box
  ShowWindow(GetDlgItem(FontDialog1.Handle, 1138), SW_HIDE);
  // Handle the size combo child list as well
  EnumChildWindows(GetDlgItem(FontDialog1.Handle, 1138), @EnumChildren, 0);

end;

I want to hide the groupbox Effect too. How can I find
out the handle of it. I have create a litte programm with
code that i have from www.torry.net to get the handle
of a component, but I get diffirent handle-numbers!
How do I find out the handle-number of the groupbox Effects?

Greetings,

Peter Kiers
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Kiers

ASKER

When I point the groupbox Effects
Windowse give Control id: 0430
But that doesn't work and 1072 does!

PK
Avatar of TName
TName

>Effects group box id is 1072 I think.

Sorry, I hadn't noticed that mokule had already told you this...



You can also find out the control id's yourself if you want to experiment :)
Add a button, a memo and a font dialog to a form and assign Button1Click to the button:
When clicking the button, the font dialog will appear and the control ids will be displayed in the memo


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    FontDialog1: TFontDialog;
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure FontDialog1Show(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 FontDialog1.Execute;
end;

function EnumProc(wnd: HWND; Lines: TStrings): BOOL; stdcall;
var
  buf, Caption: array [0..255] of char;
begin
  Result := True;
  GetClassname(wnd, buf, 256);
  GetWindowText(wnd, Caption, 256);
  Lines.Add(Format('ID: %d, class: %s, caption: %s',
    [GetDlgCtrlID(wnd), buf, Caption]));
end;

procedure TForm1.FontDialog1Show(Sender: TObject);

begin
 Memo1.Clear;
 EnumChildWindows(FontDialog1.Handle, @EnumProc, Integer(Memo1.Lines));
end;

end.
Peter 430 is in hex which is equal 1072 decimal
Thank for the info

Greetings,

Peter Kiers
Here's more about it (replacing text on dialogs):
http://www.swissdelphicenter.ch/torry/showcode.php?id=419