function WinMain(hInstance: HINST; hPrevInstance: HINST; lpCmdLine: PChar; nCmdShow: integer)
: integer;
stdcall;
var
Msg: TMsg;
myClass: PWideChar;
myTitle: PWideChar;
dwStyle: DWORD;
wc: TWndClassEx;
X: integer;
Y: integer;
IsInitialized: Bool;
rc: TRect;
Path:
string;
begin
myClass := '
POPUPWINDOW';
wc.cbSize := SIZEOF(wc);
IsInitialized := GetClassInfoEx(hInstance, myClass, wc);
if IsInitialized = False
then
begin
wc.cbSize := SIZEOF(wc);
wc.style := CS_HREDRAW
or CS_VREDRAW
or CS_DBLCLKS;
wc.lpfnWndProc := @WndProc;
wc.cbClsExtra := 0;
wc.cbWndExtra := EXTEND_EXTRA * 4;
wc.hInstance := hInstance;
wc.hIcon := 0;
wc.hCursor := LoadCursor(0, IDC_ARROW);
wc.hbrBackground := 0;
wc.lpszMenuName :=
nil;
wc.lpszClassName := myClass;
wc.hIconSm := wc.hIcon;
if RegisterClassEx(wc) <> 0
then
IsInitialized := True;
end;
if IsInitialized
then
begin
dwExStyle := 0;
dwStyle := WS_POPUP;
SetRect(rc, 0, 0, XMIN_SIZE, YMIN_SIZE);
AdjustWindowRectEx(rc, dwStyle, False, dwExStyle);
X := MAX((GetSystemMetrics(SM_CXSCREEN) - rc.Right - rc.left)
div 2, 0);
Y := MAX((GetSystemMetrics(SM_CYSCREEN) - rc.Bottom - rc.Top)
div 2, 0);
// Create The Window
myTitle := '
Drawing64';
MainHandle := CreateWindowEx(dwExStyle, myClass,
// Classen Name
myTitle,
// Window Titel
dwStyle,
// Definierte Window Style
X, Y,
// Windows Position
rc.Right - rc.left,
// Windows Weite
rc.Bottom - rc.Top,
// Windows Höhe
0,
// Kein Parent Window
0,
// Kein Menu
wc.hInstance,
// Instance
nil);
// Nichts zu WM_CREATE hinzufügen
if MainHandle <> 0
then
begin
// Flag zum Neustarten wenn Skin geändert wurde
Restart := False;
UserAppDataDir := GetSpecialFolder(CSIDL_APPDATA);
// Direktory erstellen wenn nicht vorhanden
if not ForceDirectories(UserAppDataDir + '
\BrewIdeas\Drawing64')
then
begin
raise Exception.Create('
Cannot create' + UserAppDataDir + '
\BrewIdeas\Drawing64');
Halt;
end;
Path := UserAppDataDir + '
\BrewIdeas\Drawing64\';
InitPath;
DefSkin := DrawingIni.ReadString('
SkinPath', '
Skin', ExtractFilePath(ParamStr(0))
+ '
Skins\Blue\Drawing64.ske');
DrawingIni.Free;
// Skin Initialisieren und einstellungen laden
SKAERO_InitSkin(MainHandle, DefSkin, True, True);
AddChildControls(MainHandle, wc.hInstance);
// Ini laden
LoadIni;
// Window Anzeigen
SKAERO_ShowMainWindow(MainHandle, 5);
// Emuliert Aero in WinXP wenn in der Ini aktiviert
if SKAERO_AEROEMULATE <> 0
then
SetTimer(MainHandle, SKAERO_AERO_TIMER, SKAERO_AEROTIMERDELAY,
nil);
SetTimer(MainHandle, DRAWING_TIMER, 0,
nil);
// Windows Messagen verarbeiten
while GetMessage(Msg, 0, 0, 0)
do
begin
if IsDialogMessage(MainHandle, Msg) = False
then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
// Falls aktiviert Timer beenden
if SKAERO_AEROEMULATE <> 0
then
KillTimer(MainHandle, SKAERO_AERO_TIMER);
SKAERO_Free;
end;
// end WinHandle
end
else
UnRegisterClass(wc.lpszClassName, hInstance);
if Restart
then
Result := ShellExecute(0, '
open', PWideChar(ParamStr(0)),
nil,
nil, SW_SHOW)
else
Result := Msg.WParam;
end;
{$ENDREGION}