mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 14:59:30 +02:00
win32: minor refactoring
git-svn-id: trunk@29243 -
This commit is contained in:
parent
2b5f589e66
commit
50f08451fd
@ -151,6 +151,8 @@ type
|
||||
procedure CheckPipeEvents;
|
||||
|
||||
function WinRegister: Boolean;
|
||||
|
||||
procedure CreateAppHandle;
|
||||
protected
|
||||
function CreateThemeServices: TThemeServices; override;
|
||||
public
|
||||
|
@ -116,7 +116,6 @@ const
|
||||
ICC_PAGESCROLLER_CLASS);
|
||||
var
|
||||
ICC: TINITCOMMONCONTROLSEX;
|
||||
SysMenu: HMENU;
|
||||
Handle: HWND;
|
||||
DC: HDC;
|
||||
AIcon: HICON;
|
||||
@ -148,37 +147,10 @@ begin
|
||||
// Create parent of all windows, 'button on taskbar'
|
||||
if not IsLibrary then
|
||||
begin
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS then
|
||||
FAppHandle := CreateWindowW(@ClsNameW,
|
||||
PWideChar(UTF8ToUTF16(Application.Title)),
|
||||
WS_POPUP or WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
|
||||
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
||||
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
||||
0, 0, HWND(nil), HMENU(nil), HInstance, nil)
|
||||
else
|
||||
FAppHandle := CreateWindow(@ClsName, PChar(Utf8ToAnsi(Application.Title)),
|
||||
WS_POPUP or WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
|
||||
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
||||
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
||||
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
|
||||
{$else}
|
||||
FAppHandle := CreateWindow(@ClsName, PChar(Application.Title), WS_POPUP or
|
||||
WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
|
||||
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
||||
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
||||
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
|
||||
{$endif}
|
||||
AllocWindowInfo(FAppHandle);
|
||||
|
||||
CreateAppHandle;
|
||||
// set nice main icon
|
||||
AIcon := Windows.LoadIcon(MainInstance, 'MAINICON');
|
||||
AppSetIcon(AIcon, AIcon);
|
||||
// remove useless menuitems from sysmenu
|
||||
SysMenu := Windows.GetSystemMenu(FAppHandle, False);
|
||||
Windows.DeleteMenu(SysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
|
||||
Windows.DeleteMenu(SysMenu, SC_SIZE, MF_BYCOMMAND);
|
||||
Windows.DeleteMenu(SysMenu, SC_MOVE, MF_BYCOMMAND);
|
||||
end;
|
||||
|
||||
// initialize ScreenInfo
|
||||
@ -694,6 +666,39 @@ begin
|
||||
Assert(False, 'Trace:WinRegister - Exit');
|
||||
end;
|
||||
|
||||
procedure TWin32WidgetSet.CreateAppHandle;
|
||||
var
|
||||
SysMenu: HMENU;
|
||||
begin
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS then
|
||||
FAppHandle := CreateWindowW(@ClsNameW,
|
||||
PWideChar(UTF8ToUTF16(Application.Title)),
|
||||
WS_POPUP or WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
|
||||
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
||||
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
||||
0, 0, HWND(nil), HMENU(nil), HInstance, nil)
|
||||
else
|
||||
FAppHandle := CreateWindow(@ClsName, PChar(Utf8ToAnsi(Application.Title)),
|
||||
WS_POPUP or WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
|
||||
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
||||
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
||||
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
|
||||
{$else}
|
||||
FAppHandle := CreateWindow(@ClsName, PChar(Application.Title), WS_POPUP or
|
||||
WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
|
||||
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
||||
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
||||
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
|
||||
{$endif}
|
||||
AllocWindowInfo(FAppHandle);
|
||||
// remove useless menuitems from sysmenu
|
||||
SysMenu := Windows.GetSystemMenu(FAppHandle, False);
|
||||
Windows.DeleteMenu(SysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
|
||||
Windows.DeleteMenu(SysMenu, SC_SIZE, MF_BYCOMMAND);
|
||||
Windows.DeleteMenu(SysMenu, SC_MOVE, MF_BYCOMMAND);
|
||||
end;
|
||||
|
||||
function TWin32WidgetSet.CreateThemeServices: TThemeServices;
|
||||
begin
|
||||
Result := TWin32ThemeServices.Create;
|
||||
|
Loading…
Reference in New Issue
Block a user