views:

72

answers:

1

Hello,

I want to extend an open/save dialog with a "drop-box" which should look like a TPanel (bevel). The code is already there - I use CreateWindowEx() with WNDCLASS name "Edit".

I have searched for a solution to draw a TPanel (resp. a beveled STATIC) with pure WinAPI, but did not found anything.

MS Spy++ tells me that a TPanel has the WNDCLASS name "TPanel" (which doesn't sound like pure WinAPI?)

I have now tried following code, but I get an AV as soon as I try class name "TPanel" instead of "EDIT" or "STATIC".

procedure TForm1.Button1Click(Sender: TObject);
begin
  CreateWindowEx(
  WS_EX_LEFT or WS_EX_LTRREADING or WS_EX_RIGHTSCROLLBAR or WS_EX_CONTROLPARENT,
  'TPanel',
  'Hello World',
  WS_CHILDWINDOW or WS_VISIBLE or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,
  0, 0, 100, 100,
  Handle, 0, hInstance, nil);
end;

Can you please help me?

Regards
Daniel Marschall

PS: Can you please tell me how I write delphi-highlighted code in StackOverflow.com ?

+6  A: 

TPanel is pure VCL control, which is not a wrapper over Win32 window class. Take a look at source code of TPanel (in VCL sources) to see how exactly it's painted. What you need is to fill internals with solid color and paint a border. If you want theme support, things become trickier, though.

Also why would you want to use pure WinAPI? You can embed VCL controls in open/save dialog. Take a look at TOpenPictureDialog in VCL source code -- it does exactly what you need.

Eugene Mayevski 'EldoS Corp
But not much, really. For examples of how to use themes manually, see my example components http://stackoverflow.com/questions/3900833/custom-control-creation-in-delphi/3902049#3902049 and http://stackoverflow.com/questions/3986067/delphi-windows-7-control-panel-component/3991408#3991408 and consult http://stackoverflow.com/questions/4009701/windows-visual-themes-gallery-of-parts-and-states/4009712#4009712 for a way of studing the parts.
Andreas Rejbrand