View Issue Details

IDProjectCategoryView StatusLast Update
0037100PackagesLCLpublic2020-06-05 09:39
ReporterZdravko Gabrovski Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOSWindows 
Summary0037100: Can not create StatusBar control under Win32 LCL Dll application
DescriptionThe problem was described here:
https://forum.lazarus.freepascal.org/index.php?topic=46780.0
and comes from Application.Handle = 0 in LCL Dll applications in InitializePreferredStatusBarHeight procedure in Win32WSComCtrls.pp
The proposed fix check if Application handle is = 0 and IsLibrary = True ,to take current form handle instead of Application.Handle.
In that case, CreateWindowExW will not fail with 1406 error.

  Parent := TWin32WidgetSet(WidgetSet).AppHandle;
  if ( Parent=0 ) and IsLibrary and Assigned( Screen.ActiveForm ) then <----- The fix
    Parent := Screen.ActiveForm.Handle; <-----
  PreferredSizeStatusBar := CreateWindowExW(0, STATUSCLASSNAMEW,
    nil, Flags,
    0, 0, 0, 0, Parent, 0, HInstance, nil);
Steps To Reproduceas desribed here https://forum.lazarus.freepascal.org/index.php?topic=46780.0
and here https://bugs.freepascal.org/view.php?id=37079

TagsNo tags attached.
Fixed in Revisionr63288
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Zdravko Gabrovski

2020-05-17 22:12

reporter  

win32wscomctrls.diff (619 bytes)   
Index: lcl/interfaces/win32/win32wscomctrls.pp
===================================================================
--- lcl/interfaces/win32/win32wscomctrls.pp	(revision 63135)
+++ lcl/interfaces/win32/win32wscomctrls.pp	(working copy)
@@ -302,6 +302,8 @@
 begin
   Flags := WS_CHILD or WS_CLIPSIBLINGS or WS_CLIPCHILDREN;
   Parent := TWin32WidgetSet(WidgetSet).AppHandle;
+  if ( Parent=0 ) and IsLibrary and Assigned( Screen.ActiveForm ) then
+    Parent := Screen.ActiveForm.Handle;
   PreferredSizeStatusBar := CreateWindowExW(0, STATUSCLASSNAMEW,
     nil, Flags,
     0, 0, 0, 0, Parent, 0, HInstance, nil);
win32wscomctrls.diff (619 bytes)   

Juha Manninen

2020-06-04 22:12

developer   ~0123229

Applied, thanks.
Hey developers, why do I have to apply Windows patches although I don't have Windows now? Why nobody takes care of them? This is a shame!

Zdravko Gabrovski

2020-06-05 09:39

reporter   ~0123240

It is working fine!
Many thanks!

Issue History

Date Modified Username Field Change
2020-05-17 22:12 Zdravko Gabrovski New Issue
2020-05-17 22:12 Zdravko Gabrovski File Added: win32wscomctrls.diff
2020-06-04 21:53 Juha Manninen Assigned To => Juha Manninen
2020-06-04 21:53 Juha Manninen Status new => assigned
2020-06-04 22:12 Juha Manninen Status assigned => resolved
2020-06-04 22:12 Juha Manninen Resolution open => fixed
2020-06-04 22:12 Juha Manninen Fixed in Revision => r63288
2020-06-04 22:12 Juha Manninen LazTarget => -
2020-06-04 22:12 Juha Manninen Widgetset Win32/Win64 => Win32/Win64
2020-06-04 22:12 Juha Manninen Note Added: 0123229
2020-06-05 09:39 Zdravko Gabrovski Status resolved => closed
2020-06-05 09:39 Zdravko Gabrovski Note Added: 0123240