|
{
Hi,
I'm trying to create a very simple Visual
Component that does just this: it displays a small bitmap and
some text under the bitmap (code follows).
Concerning the
bitmap, I know 2 methods to load it:
1. - From a .bmp file on
the disk, using the LoadFromFile method 2. - From the component's
resource file (.dcr), using the LoadFromResourceName
method
Each one of these 2 methods just work fine
...
With this component, I can create an ActiveX control
(.ocx) that works just as fine, I can load it with my web browser
and all, alright ...
BUT THE PROBLEM IS that I don't want to
load the bitmap from a file on the disk ! I want it to be STORED
IN the OCX file !!
Because the ActiveX control does not read
the .bmp file on the SERVER's disk, but on the CLIENT's disk ! So
this method compells the client to have the .bmp file on its own
disk, which is not very funny ...
So my question is very
simple: Does anybody out there knows a mean to encapsulate
these damned bitmaps in an OCX file, or at least to read them on
the server's side ????
Thanks in advance !
-> The
component's code follows, if you want to have a look at it
...
}
{###########################################################################################} {MyControl.pas}
unit
MyControl;
interface
uses Windows, Messages,
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
const DEFAULT_HEIGHT =
40; DEFAULT_WIDTH = 70;
type TMyControl =
class (TCustomControl) private pMyIcon:
TBitmap; fOnClick:
TNotifyEvent; protected procedure Paint;
override; public constructor Create
(AOwner: TComponent); override; published
property OnClick: TNotifyEvent read fOnClick write
fOnClick; end;
procedure
Register;
implementation
procedure
Register; begin RegisterComponents ('Standard',
[TMyControl]); end;
constructor TMyControl.Create (AOwner
: TComponent); { Constructor
} begin inherited; pMyIcon :=
TBitmap.Create; pMyIcon.Transparent :=
True; pMyIcon.LoadFromFile ('C:Program
FilesBorlandDelphi5ProgsMy ControlMy Icon.bmp'); //
pMyIcon.LoadFromResourceName (HInstance,
'MYICON'); Height := DEFAULT_HEIGHT; Width :=
DEFAULT_WIDTH; end;
procedure TMyControl.Paint; { Paint
procedure } begin inherited; // draws in the
canvas with Canvas do begin
// sets the canvas size Height
:= DEFAULT_HEIGHT; Width :=
DEFAULT_WIDTH; // draws the icon
Draw (30, 5, pMyIcon); // writes
text under the icon Brush.Color :=
clBtnFace; Font.Name := 'Tahoma';
Font.Style := []; TextOut (15,
20, 'My Icon');
end; end;
end.
{###########################################################################################}
|