home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
FUNHOUSE
/
FUNHOUSE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-01-14
|
4KB
|
173 lines
program FunHouse;
{ define right_way} { Define this term to make the dlg box display }
{ properly at various resolutions and sysfont sizes }
uses
Win31,
WinTypes,
WinProcs,
Strings,
Objects,
OMemory,
OWindows,
ODialogs;
{$R funhouse.res}
const
AppName = 'FunHouse';
id_bitmap = 100;
id_mode = 100;
id_icon = 101;
{ DLU's! }
map_rect: TRect = ( left: 75; top: 33; right: 50; bottom: 50);
{ Pixels! }
bad_map_rect: TRect = ( left: 150; top: 66; right: 100; bottom: 100);
type
PFunHouseApp = ^TFunHouseApp;
TFunHouseApp = object(TApplication)
procedure InitMainWindow; virtual;
end;
PFunHouse = ^TFunHouse;
TFunHouse = object(TDlgWindow)
constructor Init;
procedure SetupWindow; virtual;
procedure WMPaint(var Msg: TMessage); virtual wm_First + wm_Paint;
end;
{ -------------------------------------------- }
procedure TFunHouseApp.InitMainWindow;
begin
MainWindow := New(PFunHouse,Init);
end;
{ -------------------------------------------- }
constructor TFunHouse.Init;
begin
TDlgWindow.Init(nil,PChar(100));
end;
{ -------------------------------------------- }
procedure TFunHouse.SetupWindow;
var
s: array[0..100] of char;
temp: array[0..20] of char;
the_rect: TRect;
scale_x, scale_y: real;
inc_x, inc_y: integer;
begin
TDlgWindow.SetupWindow;
StrCopy(s,'Display mode: ');
Str(GetSystemMetrics(sm_CXScreen),temp);
StrCat(s,temp);
StrCat(s,'x');
Str(GetSystemMetrics(sm_CYScreen),temp);
StrCat(s,temp);
StrCat(s,', ');
Str(LoWord(GetDialogBaseUnits),temp);
StrCat(s,temp);
StrCat(s,'x');
Str(HiWord(GetDialogBaseUnits),temp);
StrCat(s,temp);
StrCat(s,' system font');
SetWindowText(GetDlgItem(HWindow,id_mode),s);
{$ifdef right_way}
SetWindowText(HWindow,'Corrected Version');
{ Correct the icon's position }
GetClientRect(GetDlgItem(HWindow,id_icon),the_rect);
{ Translate the client coords from icon relative to dlg relative }
MapWindowPoints(GetDlgItem(HWindow,id_icon),HWindow,the_rect,2);
{ The following 2 lines assume that the dialog uses the standard
system font! }
scale_x := LoWord(GetDialogBaseUnits) / 8 - 1;
scale_y := HiWord(GetDialogBaseUnits) / 16 - 1;
with the_rect do
begin
inc_x := Round(Int((right - left) div 2 * scale_x));
Inc(left,inc_x);
Inc(right,inc_x);
inc_y := Round(Int((bottom - top) div 2 * scale_y));
Inc(top,inc_y);
Inc(bottom,inc_y);
MoveWindow(GetDlgItem(HWindow,id_icon),left,top,right - left,
bottom - top,false);
end;
{$else}
SetWindowText(HWindow,'Uncorrected Version');
{$endif}
end;
{ -------------------------------------------- }
procedure TFunHouse.WMPaint(var Msg: TMessage);
var
PaintStruct: TPaintStruct;
my_dc, MemDC: HDC;
OldBitmap: HBitmap;
BmpInfo: TBitmap;
the_map: HBitmap;
the_rect: TRect;
begin
the_map := LoadBitmap(HInstance,PChar(id_bitmap));
my_dc := BeginPaint(HWindow,PaintStruct);
MemDC := CreateCompatibleDC(my_dc);
OldBitmap := SelectObject(MemDC,the_map);
GetObject(the_map,SizeOf(TBitmap),@BmpInfo);
{$ifdef right_way}
{ Convert DLU's to pixels before use }
the_rect := map_rect;
MapDialogRect(HWindow,the_rect);
with the_rect do
StretchBlt(my_dc,left,top,right,bottom,MemDC,
0,0,BmpInfo.bmWidth,BmpInfo.bmHeight,srcCopy);
{$else}
{ Do a naive BitBlt }
with bad_map_rect do
BitBlt(my_dc,left,top,right,bottom,MemDC,0,0,srcCopy);
{$endif}
DeleteObject(SelectObject(MemDC,OldBitmap));
DeleteDC(MemDC);
EndPaint(HWindow,PaintStruct);
end;
{ -------------------------------------------- }
var
my_app: TFunHouseApp;
begin
my_app.Init(AppName);
my_app.Run;
my_app.Done;
end.