View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0017965 | Patches | LCL | public | 2010-11-17 19:33 | 2011-01-04 16:02 |
Reporter | Christian Budde | Assigned To | Paul Ishenin | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 0.9.29 (SVN) | ||||
Target Version | 0.99.0 | Fixed in Version | 0.9.29 (SVN) | ||
Summary | 0017965: Hide task bar handler for libraries | ||||
Description | In case the LCL is used within a DLL (like in plugins), every time a form is shown, a taskbar handler is shown as well. This is different to the behaviours in Delphi and doesn't really make sense IMO. | ||||
Additional Information | I am aware that it is not officially supported to use the LCL in combination with DLLs, but maybe someone can have a look at this already. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 28859 | ||||
LazTarget | 0.99.0 | ||||
Widgetset | Win32/Win64 | ||||
Attached Files |
|
related to | 0017311 | closed | Paul Ishenin | Patches | There is no MainFormOnTaskBar property in Lazarus |
related to | 0017896 | closed | Juha Manninen | Lazarus | Special handling for libraries |
|
This issue might be related to the issue 17311 |
2010-11-17 19:53
|
LibraryIcon.patch (1,237 bytes)
Index: lcl/interfaces/win32/win32object.inc =================================================================== --- lcl/interfaces/win32/win32object.inc (revision 28296) +++ lcl/interfaces/win32/win32object.inc (working copy) @@ -130,7 +130,11 @@ Exit; end; - OleInitialize(nil); + // In case of a library Ole doesn't needed to be initialized (should be done + // by the main application + // TODO: Verify if this is indeed not needed. + if not IsLibrary then OleInitialize(nil); + //TODO: Remove when the WS interface is implemented // Common controls only need to be initialized when used // So they are initialized in the CreateHandle for common controls @@ -169,9 +173,13 @@ {$endif} AllocWindowInfo(FAppHandle); - // set nice main icon - AIcon := Windows.LoadIcon(MainInstance, 'MAINICON'); - AppSetIcon(AIcon, AIcon); + // eventually set nice main icon (if the project is not a library) + if not IsLibrary then + begin + AIcon := Windows.LoadIcon(MainInstance, 'MAINICON'); + AppSetIcon(AIcon, AIcon); + end; + // remove useless menuitems from sysmenu SysMenu := Windows.GetSystemMenu(FAppHandle, False); Windows.DeleteMenu(SysMenu, SC_MAXIMIZE, MF_BYCOMMAND); |
|
I just added a very conservative patch to reduce the function calls in case of a library. For example the main icon is not set and also the OleInitialize is not called (since it should be called by the host). However, this does not fix the issue at all, just as an addition |
2010-11-17 20:11
|
LibraryTaskbar.patch (7,161 bytes)
Index: lcl/include/application.inc =================================================================== --- lcl/include/application.inc (revision 28296) +++ lcl/include/application.inc (working copy) @@ -416,17 +416,21 @@ WidgetSet.AppInit(ScreenInfo); ScreenInfo.Initialized := True; Screen.UpdateScreen; + // set that we are initialized => all exceptions will be handled by our HandleException include(FFlags, AppInitialized); - // application icon - if LazarusResources.Find('MAINICON') <> nil then - Icon.LoadFromLazarusResource('MAINICON') - else + if not IsLibrary then begin - Res := FindResource(HInstance, PChar('MAINICON'), PChar(RT_GROUP_ICON)); - if Res <> 0 then - Icon.LoadFromResourceHandle(Hinstance, Res); + // application icon + if LazarusResources.Find('MAINICON') <> nil then + Icon.LoadFromLazarusResource('MAINICON') + else + begin + Res := FindResource(HInstance, PChar('MAINICON'), PChar(RT_GROUP_ICON)); + if Res <> 0 then + Icon.LoadFromResourceHandle(Hinstance, Res); + end; end; end; Index: lcl/interfaces/win32/win32object.inc =================================================================== --- lcl/interfaces/win32/win32object.inc (revision 28296) +++ lcl/interfaces/win32/win32object.inc (working copy) @@ -130,7 +130,11 @@ Exit; end; - OleInitialize(nil); + // In case of a library Ole doesn't needed to be initialized (should be done + // by the main application + // TODO: Verify if this is indeed not needed. + if not IsLibrary then OleInitialize(nil); + //TODO: Remove when the WS interface is implemented // Common controls only need to be initialized when used // So they are initialized in the CreateHandle for common controls @@ -145,39 +149,43 @@ end; end; - // Create parent of all windows, 'button on taskbar' - {$ifdef WindowsUnicodeSupport} - if UnicodeEnabledOS then - FAppHandle := CreateWindowW(@ClsNameW, - PWideChar(UTF8ToUTF16(Application.Title)), - WS_POPUP or WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX, + if not IsLibrary then + begin + // Create parent of all windows, 'button on taskbar' + {$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) - 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); + {$endif} + AllocWindowInfo(FAppHandle); - // 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); + // eventually set nice main icon (if the project is not a library) + 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 Handle := GetDesktopWindow; DC := Windows.GetDC(Handle); @@ -201,7 +209,8 @@ ------------------------------------------------------------------------------} procedure TWin32WidgetSet.AppMinimize; begin - Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0); + if FAppHandle <> 0 then + Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0); end; {------------------------------------------------------------------------------ @@ -213,7 +222,8 @@ ------------------------------------------------------------------------------} procedure TWin32WidgetSet.AppRestore; begin - Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_RESTORE, 0); + if FAppHandle <> 0 then + Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_RESTORE, 0); end; @@ -226,7 +236,8 @@ ------------------------------------------------------------------------------} procedure TWin32WidgetSet.AppBringToFront; begin - Windows.SetForegroundWindow(FAppHandle); + if FAppHandle <> 0 then + Windows.SetForegroundWindow(FAppHandle); end; procedure TWin32WidgetSet.SetDesigning(AComponent: TComponent); @@ -486,22 +497,24 @@ procedure TWin32WidgetSet.AppSetTitle(const ATitle: string); begin - {$ifdef WindowsUnicodeSupport} - if UnicodeEnabledOS then - begin - Windows.SetWindowTextW(FAppHandle, PWideChar(UTF8ToUTF16(ATitle))); - end else Windows.SetWindowText(FAppHandle, PChar(Utf8ToAnsi(ATitle))); - {$else} - Windows.SetWindowText(FAppHandle, PChar(ATitle)); - {$endif} + if FAppHandle <> 0 then + {$ifdef WindowsUnicodeSupport} + if UnicodeEnabledOS then + begin + Windows.SetWindowTextW(FAppHandle, PWideChar(UTF8ToUTF16(ATitle))); + end else Windows.SetWindowText(FAppHandle, PChar(Utf8ToAnsi(ATitle))); + {$else} + Windows.SetWindowText(FAppHandle, PChar(ATitle)); + {$endif} end; procedure TWin32WidgetSet.AppSetVisible(const AVisible: Boolean); begin - if AVisible then - Windows.ShowWindow(FAppHandle, SW_SHOW) - else - Windows.ShowWindow(FAppHandle, SW_HIDE); + if FAppHandle <> 0 then + if AVisible then + Windows.ShowWindow(FAppHandle, SW_SHOW) + else + Windows.ShowWindow(FAppHandle, SW_HIDE); end; function TWin32WidgetSet.AppRemoveStayOnTopFlags(const ASystemTopAlso: Boolean = False): Boolean; |
|
Any comments, please? The (second) patch is very simple and straight forward applying changes only in case of libraries. Any chance this can be applied to the development branch? It is not specific only for my case, it makes the entire Lazarus behalves more like Delphi (and other frameworks) in case of libraries. |
|
I have no comments. |
|
Thanks for the patch. I have applied it with minor modifications. I skipped the part from the forms.pas cause it has no influence on the taskbar button. I also skipped your changes aroung OleInitialize - it is not related to the issue title. If you think OleInitialize should not be used inside libraries then please point us to the documentation or create an appopriate test/research. And please open separate issues for separate problems. Please test and close if ok. |
|
Thanks. I'm currently testing it. So far it looks good, but atm. I can't compile the recent SVN snapshot (probably due to incompability with my FPC 2.5.1 snapshot release). |
|
I have tested this issue and it is now working as expected. However, I guess I should report another issue with the icon. It is discusable whether an icon is necessary or not for a library, but I think it is not, but as I said this is another issue. |
Date Modified | Username | Field | Change |
---|---|---|---|
2010-11-17 19:33 | Christian Budde | New Issue | |
2010-11-17 19:33 | Christian Budde | Widgetset | => Win32/Win64 |
2010-11-17 19:34 | Christian Budde | Note Added: 0043148 | |
2010-11-17 19:53 | Christian Budde | File Added: LibraryIcon.patch | |
2010-11-17 19:55 | Christian Budde | Note Added: 0043150 | |
2010-11-17 20:11 | Christian Budde | File Added: LibraryTaskbar.patch | |
2010-11-18 10:07 | Juha Manninen | Relationship added | related to 0017896 |
2010-11-18 10:10 | Juha Manninen | Relationship added | related to 0017311 |
2010-11-18 12:08 | Vincent Snijders | LazTarget | => - |
2010-11-18 12:08 | Vincent Snijders | Status | new => acknowledged |
2010-12-09 18:51 | Christian Budde | Note Added: 0044128 | |
2010-12-09 19:12 | Vincent Snijders | LazTarget | - => 0.99.0 |
2010-12-09 19:12 | Vincent Snijders | Note Added: 0044129 | |
2010-12-09 19:12 | Vincent Snijders | Target Version | => 0.99.0 |
2010-12-09 19:12 | Vincent Snijders | Project | Lazarus => Patches |
2011-01-04 08:36 | Paul Ishenin | Fixed in Revision | => 28859 |
2011-01-04 08:36 | Paul Ishenin | Status | acknowledged => resolved |
2011-01-04 08:36 | Paul Ishenin | Fixed in Version | => 0.9.29 (SVN) |
2011-01-04 08:36 | Paul Ishenin | Resolution | open => fixed |
2011-01-04 08:36 | Paul Ishenin | Assigned To | => Paul Ishenin |
2011-01-04 08:36 | Paul Ishenin | Note Added: 0044853 | |
2011-01-04 14:55 | Christian Budde | Note Added: 0044864 | |
2011-01-04 16:02 | Christian Budde | Status | resolved => closed |
2011-01-04 16:02 | Christian Budde | Note Added: 0044870 |