뭐라고 해야 하나? 제목을 붙이기가 힘드네요
델마당에 Q&A에 올라온 질문을 보고 한번 만들어 본것인데요
http://www.delmadang.com/community/bbs_view.asp?bbsNo=17&bbsCat=0&st=&keyword=&indx=400395&keyword1=&keyword2=&page=1
폼을 Modal로 띄울때 폼을 띄운 폼의 Caption은 Disable되는데..
나머지는 Client영역은 그대로 남아있는데...
Disable된 폼의 Client영역도 Disable된것처럼 보이게 gray톤으로 바꾸는것입니다.
첨부파일의 이미지 처럼..
원리는...
1. GetFormImage로 현재 폼의 이미지를 가져온다.
2. Bitmap의 이미지를 gray톤으로 바꾼다.
3. 현재 폼에 TPanel을 하나 추가하고 Panel위에 TImage를 올린다. align=alClient로 ..
4. 생성한 TImage에 Gray톤으로 바꾼 bmp를 Assign시킨다.
5. 원하는 폼을 ShowModal한다.
6. Panel을 delete시킨다. //원래대로 돌아옴
// Builder예제
void __fastcall TForm1::GrayBitmap(Graphics::TBitmap *bmp)
{
unsigned char *pt;
bmp->PixelFormat=pf32bit;
int gra=180;
for(int h=0;hHeight;h++)
{
pt=(unsigned char *)bmp->ScanLine[h];
for(int w=0;wWidth;w++)
{
pt[0]=(pt[0]+gra)/2;
pt[1]=(pt[1]+gra)/2;
pt[2]=(pt[2]+gra)/2;
pt[3]=(pt[3]+gra)/2;
pt+=4;
}
}
}
void __fastcall TForm1::Button6Click(TObject *Sender)
{
TPanel *Pan=new TPanel(this);
Pan->SetBounds(0,0,ClientWidth,ClientHeight);
TImage *Img=new TImage(Pan);
Img->Align=alClient;
Pan->BorderStyle=bsNone;
Pan->BevelOuter=bvNone;
Img->Picture->Bitmap->Width=ClientWidth;
Img->Picture->Bitmap->Height=ClientHeight;
Graphics::TBitmap *bmp=this->GetFormImage();
bmp->PixelFormat=pf32bit;
GrayBitmap(bmp);
Img->Picture->Bitmap->Assign(bmp);
delete bmp;
Pan->Parent=this;
Img->Parent=Pan;
Form2->ShowModal();
delete Pan;
}
//===========================================================================
//Delphi 예제
procedure TForm1.GrayBitmap(bmp: TBitmap);
var
pt : PByte;//Pointer;
gra : Byte;
h,w : Integer;
begin
bmp.PixelFormat:=pf32bit;
gra:=180;
for h:=0 to bmp.Height-1 do
begin
pt:=PByte(bmp.ScanLine[h]);
for w:=0 to bmp.Width-1 do
begin
pt^ := (pt^+gra) div 2;Inc(pt);
pt^ := (pt^+gra) div 2;Inc(pt);
pt^ := (pt^+gra) div 2;Inc(pt);
pt^ := (pt^+gra) div 2;Inc(pt);
end;
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
var
Pan: TPanel;
Img: TImage;
bmp: TBitmap;
begin
Pan:=TPanel.Create(Self);
Pan.SetBounds(0,0,ClientWidth,ClientHeight);
Img:=TImage.Create(Pan);
Img.Align:=alClient;
Pan.BorderStyle:=bsNone;
Pan.BevelOuter:=bvNone;
Img.Picture.Bitmap.Width:=ClientWidth;
Img.Picture.Bitmap.Height:=ClientHeight;
bmp:=Self.GetFormImage();
bmp.PixelFormat:=pf32bit;
GrayBitmap(bmp);
Img.Picture.Bitmap.Assign(bmp);
bmp.free;
Pan.Parent:=Self;
Img.Parent:=Pan;
Form2.ShowModal();
Pan.free;
end;
어디 쓸데 있으려나?
그럼..
|