Skip to content

Instantly share code, notes, and snippets.

View freeonterminate's full-sized avatar

HOSOKAWA Jun freeonterminate

View GitHub Profile
@freeonterminate
freeonterminate / uIfExp.pas
Last active June 23, 2018 09:12
If expression
(*
* If expression - ternary operator like C.
*
* HOW TO USE
* 1. uses uIfExp;
* 2. IfExp<TYPE>(BooleanValue) - TRUE_VALUE or FALSE_VALUE
* or
* IfExp<TYPE>(BooleanValue).ThenElse(TRUE_VALUE, FALSE_VALUE);
*
* EXAMPLE
@freeonterminate
freeonterminate / uTabControlHelper.pas
Created June 19, 2015 03:08
TTabControl で先頭のタブをプログラムで変更可能にするヘルパー
unit uTabControlHelper;
interface
uses
FMX.TabControl;
type
TTabControlHelper = class helper for TTabControl
private
unit JavaSample;
interface
uses
Androidapi.JNI.GraphicsContentViewText;
function SaveJavaBitmapToFile(
const iSrc: JBitmap; // JBitmap は android.graphics.Bitmap です。同様に接頭辞 J で始まる物は全部 Java のクラスです
const iFileName: String): Boolean;
@freeonterminate
freeonterminate / FMX.MemoHelper.pas
Last active August 29, 2015 14:17
TMemo.Lines.Add を高速化する。
(*
* TMemoHelper
8 [Method List]
* FastAdd - Fast Add Method
*
* [How to use]
* 1. uses FMX.MemoHelper;
* 2. Memo1.FastAdd('something');
*)
@freeonterminate
freeonterminate / FixBackToFront.pas
Last active August 29, 2015 14:04
バックグラウンドプロセス化したアプリが Front に戻ってきたとき真っ黒問題に対処するコード
//
// あんまり、おこらないかもしれない!
//
// IFMXApplicationEventService をTPlatformServices.Current.GetPlatformService から取り出して
// AppEventService.SetApplicationEventHandler(AppEvent); をして
// そのイベントハンドラで以下の様にする
function TLifecycleManager.AppEvent(
iAppEvent: TApplicationEvent;
iContext: TObject): Boolean;
@freeonterminate
freeonterminate / NoHungUp.pas
Created May 19, 2014 10:43
こうすると正しくコンパイルエラー
program Project1;
type
TFoo<T> = class; // interface から class に変えた
TBaz<T> = record
Value: TFoo<TArray<T>>; // E2604 ジェネリック型を再帰的に使用しています
end;
TFoo<T> = class
@freeonterminate
freeonterminate / Hang.pas
Last active August 29, 2015 14:01
最小限の Hung Up コード
program Project1;
type
IFoo<T> = interface;
TBar<T> = record
Value: IFoo<TArray<T>>;
end;
IFoo<T> = interface
@freeonterminate
freeonterminate / Generics.pas
Created May 19, 2014 09:15
Delphi Generics
program Project1;
uses
System.SysUtils;
type
TTest<T> = record
Value: T;
end;
unit uKeyHook;
interface
uses
Winapi.Windows;
type
TKeyHookEvent = procedure(const iVKKey, iState: DWORD) of object;
@freeonterminate
freeonterminate / NSWindowSample.pas
Last active August 29, 2015 13:57
OS X の API が、シームレスに扱える例です。
uses
Macapi.ObjectiveC,
Macapi.CocoaTypes,
Macapi.Foundation,
Macapi.AppKit,
FMX.Platform.Mac
procedure SetMinSize(const iForm: TForm; const iMinW, iMin: Integer);
var
Wnd: NSWindow; // OS X 用のクラスがそのまま使えてる