My Memory
2017년 3월 9일 목요일
[Delphi] MDI Child Form staying on Top
Add TApplicationEvents to form that should stay on top, in design mode set FormStyle to fsNormal (not fsStayOnTop !!)
then
Form's OnActivate evet handler:
procedure TWinInfo.FormActivate(Sender: TObject);
begin
SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
end;
ApplicationEvents' OnActivate event handler:
procedure TWinInfo.ApplicationEventsActivate(Sender: TObject);
begin
if Visible then
SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
end;
ApplicationEvents' OnDeActivate event handler:
procedure TWinInfo.ApplicationEventsDeactivate(Sender: TObject);
begin
if Visible then
SetWindowPos(Handle,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
end;
2017년 3월 2일 목요일
[MySQL] 데이터베이스 테이블별 용량확인
SELECT
table_name,
table_rows,
round(data_length/(1024*1024),2) as 'DATA_SIZE(MB)',
round(index_length/(1024*1024),2) as 'INDEX_SIZE(MB)'
FROM information_schema.TABLES
where table_schema = 'DB Name'
GROUP BY table_name
ORDER BY data_length DESC
LIMIT 10;
2017년 2월 14일 화요일
[Delphi] How to Declare and Initialize Constant Arrays in Delphi
In Delphi, arrays allow a developer to refer to a series of variables by the same name and to use a number (an index) to tell them apart.
In most scenarios, you declare an array as a variable -- thus allowing for array elements to be changed at run-time.
Sometimes, however, you need to declare a constant array -- a read-only array.
You cannot change the value of a constant or a read-only variable.
Therefore, while declaring a constant array you must also initialize it.
Example
type
TShopItem = record
Name : string;
Price : currency;
end;
const
Days : array[0..6] of string = (
'Sun', 'Mon', 'Tue', 'Wed',
'Thu', 'Fri', 'Sat' ) ;
CursorMode : array[boolean] of TCursor = (
crHourGlass, crSQLWait ) ;
Items : array[1..3] of TShopItem = (
(Name : 'Clock'; Price : 20.99),
(Name : 'Pencil'; Price : 15.75),
(Name : 'Board'; Price : 42.96) ) ;
This code declares and initializes three constant arrays, named: "Days," "CursorMode" and "Items."
2017년 2월 10일 금요일
[MSSQL] 응급 복구 모드로 DB복구 하기
자료출처: http://cafe.naver.com/iwillgosu/762
Step 1:
ALTER DATABASE DB명 SET EMERGENCY
GO
Step 2:
DBCC CHECKDB('DB명')
GO
- 위의 결과에서 어떤것들이 검색되었다고 나오면 복구 가능성이 높고
- 그렇지 않고 메모리 공간 부족등 이상한 오류가 나오면 힘들다.
검색 결과가 나오면
Step 3: 단일 사용자 모드로 변경
ALTER DATABASE DB명 SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
- DBCC CHECKDB 옵선
- REPAIR_FAST : 시간이 많이 소요 되지 않고, 데이터의 손실이 없는 사소한 오류
- REPAIR_REBUILD : REPAIR_FAST가 하는 모든 작업, 인덱스 재생성과 같이 시간이 소요되는 작업이 복구 과정에서 진행됨,역시 데이터 손실 위험을 없다.
- REPAIR_ALLOW_DATA_LOSS : REPAIR_REBUILD가 하는 모든 작업, 할당 오류, 구조적 행 오류나 페이지 오류, 손상된 텍스트 개체 삭제를 수정하기 윈한 행과 페이지의 할당 및 할당 취소 등의 작업이 진행된다.
Step 3: DB복구
Step 4:
DBCC CHECKDB('DB명', REPAIR_ALLOW_DATA_LOSS)
- 복구 불가능한 데이터는 버리고 테이블 복구
Step 5: 다중 사용자 모드로 변경
ALTER DATABASE DB명 SET MULTI_USER
GO
- DB에 걸려 있던 응급 모드도 자동 해제됨.
2017년 2월 7일 화요일
[Delphi] Make Hash string : MD5, SHA1
uses IdGlobal, IdHash, IdHashMessageDigest, IdHashSha1;
function gGetMd5HashString(value: string): string;
var
hashMessageDigest5 : TIdHashMessageDigest5;
begin
hashMessageDigest5 := nil;
try
hashMessageDigest5 := TIdHashMessageDigest5.Create;
Result := IdGlobal.IndyLowerCase ( hashMessageDigest5.HashStringAsHex ( value ) );
finally
hashMessageDigest5.Free;
end;
end;
function gGetSha1HashString(value: string): string;
var
SHA1: TIdHashSHA1;
begin
SHA1 := TIdHashSHA1.Create;
try
Result := SHA1.HashStringAsHex(value);
finally
SHA1.Free;
end;
end;
[Delphi] How to pan an image with the mouse in Scrollbox
자료출처 : http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_25028583.html
Here is the correct coding. The FLastX/Y value needs to be adjusted by the amount that the image was moved.
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
Dx, Dy: Integer;
begin
if FMouseIsDown then
begin
Dx := X - FLastX;
Dy := y - FLasty;
Read More »
Here is the correct coding. The FLastX/Y value needs to be adjusted by the amount that the image was moved.
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
Dx, Dy: Integer;
begin
if FMouseIsDown then
begin
Dx := X - FLastX;
Dy := y - FLasty;
VertScrollBar.Position := VertScrollBar.Position - (Dy * Image1.height div vertscrollbar.Range);
HorzScrollBar.Position := HorzScrollBar.Position - (Dx * Image1.width div horzscrollbar.Range);
FLastX := X - Dx;
FLastY := Y - Dy;
end
end;
HorzScrollBar.Position := HorzScrollBar.Position - (Dx * Image1.width div horzscrollbar.Range);
FLastX := X - Dx;
FLastY := Y - Dy;
end
end;
[Delphi] Speed Button 으로 Toggle Switch Button 만들기
자료출처: http://www.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=986
한번 누르면 버튼이 들어간 상태로 있고, 한번 더 누르면 다시 정상 상태로 올라오는
토글 스위치 버턴을 만들려면, 스피드 버튼을 이용하면 됩니다.
가끔씩 이런 기능의 버턴이 필요한데,
델파이가 제공하는 기본 컴포넌트에서 이걸 하려면 스피드버튼을 사용하면 됩니다.
스피드 버튼을 폼에 올리고
AllowAllUp = true; 로 바꾸고
GroupIndex = 0 이외의 값을 주면 됩니다.
스피드 버턴을 그룹화 시켜 쓰는 것이 없다면 그냥 1 주면 되겠죠.
이렇게 하면 간단히 토글 스위치 버턴이 만들어 집니다.
모양을 좋게 하려면
Flat = true;
기본 버턴을 좀 이쁘게 하고 싶으면
스피드 버턴 밑에 TShape을 하나 깔거나, TImage로 백그라운드를 그려주는게 좋겠죠.
하지만 이 경우 버튼이 Down 모드일 경우는 나타나지 않으니, 이를 감안해서 백그라운드 이미지를
선정해야 합니다.
AllowAllUp 프로퍼티는 그룹화 시켜 놓은 스피드버턴이 있으면
그룹중에 버턴 하나를 클릭 했을때 그룹의 나머지 버턴이 자동으로 올라오는 것을 의미합니다.
그룹에 버턴이 단 하나면 있다면 그냥 눌려진 상태로 있게 만들어주는 프로퍼티인 것이죠.
현재 버턴의 상태는 Down 프로퍼티에 나타납니다.
물론 이 Down 프로퍼티에 true를 지정하면 눌려진 상태로, false를 지정하면 정상 상태로 제어도 가능하죠.
팁이라기 보다는 그냥 스피드 버턴의 사용법이었네요.
>>>>> 참고
같은 그룹내의 다른 버튼을 누르면 이전에 선택된 버튼이 Up되지만, 이미 선택된 버튼을 한번 더 누르면?
AllowAllUp = false 면 그 놈은 튀어 나오지 않습니다. 그룹 내의 버튼 하나는 반드시 눌린 상태로 있어야 합니다.
AllowAllUp = true 면 튀어 나옵니다. 그룹내의 선택된 버튼이 없는 상태가 됩니다.
피드 구독하기:
덧글 (Atom)