View Issue Details

IDProjectCategoryView StatusLast Update
0037100PackagesLCLpublic2020-05-17 22:12
ReporterZdravko Gabrovski Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
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 Revision
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)   

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