Page 2 of 3

Re: Resizing third-party window that has a minimum

Posted: Thu Apr 07, 2022 4:26 am
by SharkyEXE
breeze4me

Hello

Thank You Very Much!

Re: Resizing third-party window that has a minimum

Posted: Sun Apr 10, 2022 7:50 pm
by SharkyEXE
breeze4me

Hello

Excusme, please

I have very-very little code

I use 2 version code

Code: Select all

#BFFM_INITIALIZED = 1

Structure FolderNewPos
  x.l
  y.l
  w.l
  h.l
EndStructure

#App_WndProcString = "AppOldWndProc"

Global newpos.FolderNewPos

Procedure FolderWndProc(hWnd, Message, wParam, lParam)
  Protected old = GetProp_(hWnd, #App_WndProcString)
  
  If Message = #WM_ACTIVATE
    SetWindowPos_(hWnd, 0, newpos\x, newpos\y, newpos\w, newpos\h, #SWP_NOZORDER | #SWP_NOOWNERZORDER | #SWP_FRAMECHANGED)
    SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, old)
    RemoveProp_(hWnd, #App_WndProcString)
  EndIf
  
  ProcedureReturn CallWindowProc_(old, hWnd, Message, wParam, lParam)
EndProcedure

; Procedure EnumChildProc(hwnd, lParam)
;   Protected Buffer.s{64}
;   
;   If GetClassName_(hwnd, @Buffer, 63)
;     If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
;       SetWindowLong_(hwnd, #GWL_STYLE, GetWindowLong_(hwnd, #GWL_STYLE) & ~#TVS_SINGLEEXPAND)
;       ProcedureReturn 0
;     EndIf
;   EndIf
;   
;   ProcedureReturn 1
; EndProcedure

Procedure BrowseCallbackProc(hwnd, uMsg, lParam, lpData)
  Protected Buffer.s, hShell, hTree, old
  
  If uMsg = #BFFM_INITIALIZED
    Repeat
      hShell = GetDlgItem_(hwnd, 0)
      If hShell
        hTree = GetDlgItem_(hShell, 100)
        If hTree
          Buffer = Space(64)
          If GetClassName_(hTree, @Buffer, 63)
            If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
              SetWindowLong_(hTree, #GWL_STYLE, GetWindowLong_(hTree, #GWL_STYLE) & ~#TVS_SINGLEEXPAND)
              Break
            EndIf
          EndIf
        EndIf
      EndIf
      
      ;EnumChildWindows_(hwnd, @EnumChildProc(), 0)   ;If the above attempt fails, try again here.
      Break
    ForEver
    
    old = SetWindowLongPtr_(hwnd, #GWLP_WNDPROC, @FolderWndProc())
    SetProp_(hwnd, #App_WndProcString, old)
  EndIf
  
  ProcedureReturn 0
EndProcedure


newpos\x = 50
newpos\y = 50
newpos\w = 400
newpos\h = 500

Define dir.BROWSEINFO
dir\lpfn = @BrowseCallbackProc()
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
SHBrowseForFolder_(@dir)
In default, little code

Code: Select all

Define dir.BROWSEINFO
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
SHBrowseForFolder_(@dir)
have resize windows - left, right, up, down

Please, write, how use little code

Code: Select all

Define dir.BROWSEINFO
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
SHBrowseForFolder_(@dir)
and add code for
if i click on folder - NOT expand tree
Thank You!

Re: Resizing third-party window that has a minimum

Posted: Sun Apr 10, 2022 11:57 pm
by breeze4me
SharkyEXE wrote: Sun Apr 10, 2022 7:50 pm Please, write, how use little code
...
and add code for
if i click on folder - NOT expand tree

Here's a little modified procedures for easy use, so just paste it where you need it and use it.

1. Paste the entire code where you want it.
2. Use it as follows.
3. Process the returned value of the GetFolder() function as desired.

Code: Select all

FolderPIDL  = GetFolder("title string here", 50, 70, 350, 500)  ;Move and resize the window.
or

Code: Select all

FolderPIDL  = GetFolder("title string here", 300, 200)   ;Move only
Full code.

Code: Select all

Procedure FolderWndProc(hWnd, Message, wParam, lParam)
  Protected old = GetProp_(hWnd, "AppOldWndProc")
  Protected Flag, *NewPosition.RECT
  
  If Message = #WM_ACTIVATE
    *NewPosition = GetProp_(hWnd, "WndPosData")
    If *NewPosition
      Flag = #SWP_NOZORDER | #SWP_NOOWNERZORDER | #SWP_FRAMECHANGED
      If *NewPosition\right = #PB_Ignore Or *NewPosition\bottom = #PB_Ignore
        Flag | #SWP_NOSIZE
      EndIf
      SetWindowPos_(hWnd, 0, *NewPosition\left, *NewPosition\top, *NewPosition\right, *NewPosition\bottom, Flag)   ;Move and/or resize the window.
    EndIf
    SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, old)
    RemoveProp_(hWnd, "AppOldWndProc")
    RemoveProp_(hWnd, "WndPosData")
  EndIf
  
  ProcedureReturn CallWindowProc_(old, hWnd, Message, wParam, lParam)
EndProcedure

Procedure BrowseCallbackProc(hwnd, uMsg, lParam, *lpData)
  Protected Buffer.s, hShell, hTree, old
  
  If uMsg = #BFFM_INITIALIZED
    Repeat
      hShell = GetDlgItem_(hwnd, 0)
      If hShell
        hTree = GetDlgItem_(hShell, 100)
        If hTree
          Buffer = Space(64)
          If GetClassName_(hTree, @Buffer, 63)
            If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
              SetWindowLong_(hTree, #GWL_STYLE, GetWindowLong_(hTree, #GWL_STYLE) & ~#TVS_SINGLEEXPAND)  ;Prevent an item from expanding with a single click.
              Break
            EndIf
          EndIf
        EndIf
      EndIf
      
      Break
    ForEver
    
    old = SetWindowLongPtr_(hwnd, #GWLP_WNDPROC, @FolderWndProc())
    SetProp_(hwnd, "AppOldWndProc", old)
    SetProp_(hwnd, "WndPosData", *lpData)
  EndIf
  
  ProcedureReturn 0
EndProcedure

Procedure GetFolder(Title.s, x, y, Width = #PB_Ignore, Height = #PB_Ignore)
  Protected dir.BROWSEINFO
  Protected NewPosition.RECT
  
  NewPosition\left = x
  NewPosition\top = y
  NewPosition\right = Width
  NewPosition\bottom = Height
  
  dir\lpszTitle = @Title
  dir\lParam = @NewPosition         ;Specify new position for the folder selection window.
  dir\lpfn = @BrowseCallbackProc()  ;Specify the procedure for positioning folder selection window and for preventing one-click expansion.
  
  dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
  ProcedureReturn SHBrowseForFolder_(@dir)
EndProcedure

; Example 1
;FolderPIDL  = GetFolder("title string here", 50, 70, 350, 500)

; Example 2
;FolderPIDL  = GetFolder("title string here", 300, 200)
And the following is a code that only has a way to prevent an item from expanding with a single click. (No resizing or moving the window)

Code: Select all

Procedure BrowseCallbackProc(hwnd, uMsg, lParam, *lpData)
  Protected Buffer.s, hShell, hTree
  
  If uMsg = #BFFM_INITIALIZED
    hShell = GetDlgItem_(hwnd, 0)
    If hShell
      hTree = GetDlgItem_(hShell, 100)
      If hTree
        Buffer = Space(64)
        If GetClassName_(hTree, @Buffer, 63)
          If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
            SetWindowLong_(hTree, #GWL_STYLE, GetWindowLong_(hTree, #GWL_STYLE) & ~#TVS_SINGLEEXPAND)  ;Prevent an item from expanding with a single click.
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  
  ProcedureReturn 0
EndProcedure

Define dir.BROWSEINFO

dir\lpfn = @BrowseCallbackProc()         ;Specify the procedure for preventing one click expansion.
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
SHBrowseForFolder_(@dir)

Re: Resizing third-party window that has a minimum

Posted: Mon Apr 11, 2022 4:50 am
by SharkyEXE
breeze4me

Hello

1) Thank you very much, your little code

Code: Select all

Procedure BrowseCallbackProc(hwnd, uMsg, lParam, *lpData)
  Protected Buffer.s, hShell, hTree
  
  If uMsg = #BFFM_INITIALIZED
    hShell = GetDlgItem_(hwnd, 0)
    If hShell
      hTree = GetDlgItem_(hShell, 100)
      If hTree
        Buffer = Space(64)
        If GetClassName_(hTree, @Buffer, 63)
          If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
            SetWindowLong_(hTree, #GWL_STYLE, GetWindowLong_(hTree, #GWL_STYLE) & ~#TVS_SINGLEEXPAND)  ;Prevent an item from expanding with a single click.
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  
  ProcedureReturn 0
EndProcedure

Define dir.BROWSEINFO

dir\lpfn = @BrowseCallbackProc()         ;Specify the procedure for preventing one click expansion.
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
SHBrowseForFolder_(@dir)
is better for me!

2) Your code

1) little code

Code: Select all

Define dir.BROWSEINFO
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
SHBrowseForFolder_(@dir)
+
2) little code for
if i click on folder - NOT expand tree
3) For little size compiled exe file, i use very-very older version PureBasic 4.30 x64

Please, how fix this error

Image

In PureBasic 5.70 x86 - do not error

Image

Thank You!

Re: Resizing third-party window that has a minimum

Posted: Mon Apr 11, 2022 7:36 am
by breeze4me
SharkyEXE wrote: Mon Apr 11, 2022 4:50 am
3) For little size compiled exe file, i use very-very older version PureBasic 4.30 x64

Please, how fix this error
Try this.

Code: Select all

FindString(LCase(Buffer), "treeview", 1)

Re: Resizing third-party window that has a minimum

Posted: Mon Apr 11, 2022 7:26 pm
by SharkyEXE
breeze4me wrote: Mon Apr 11, 2022 7:36 am

Code: Select all

FindString(LCase(Buffer), "treeview", 1)
Hello

Thank You very much

I moded your code number 2

I comment line

Before

Code: Select all

If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
After

Code: Select all

; If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
After line

Code: Select all

; If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
add your stroke (fix)

Code: Select all

If FindString(LCase(Buffer), "treeview", 1)
Full code work perfectly

Code: Select all

Procedure BrowseCallbackProc(hwnd, uMsg, lParam, *lpData)
  Protected Buffer.s, hShell, hTree
  
  If uMsg = #BFFM_INITIALIZED
    hShell = GetDlgItem_(hwnd, 0)
    If hShell
      hTree = GetDlgItem_(hShell, 100)
      If hTree
        Buffer = Space(64)
        If GetClassName_(hTree, @Buffer, 63)
          ; If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
          If FindString(LCase(Buffer), "treeview", 1)
            SetWindowLong_(hTree, #GWL_STYLE, GetWindowLong_(hTree, #GWL_STYLE) & ~#TVS_SINGLEEXPAND)  ;Prevent an item from expanding with a single click.
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  
  ProcedureReturn 0
EndProcedure

Define dir.BROWSEINFO

dir\lpfn = @BrowseCallbackProc()         ;Specify the procedure for preventing one click expansion.
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
SHBrowseForFolder_(@dir)
Work perfectly on PureBasic 4.30 x64

Image

Work perfectly on PureBasic 5.70 x86

Image

Re: Resizing third-party window that has a minimum

Posted: Tue Apr 12, 2022 4:18 pm
by SharkyEXE
breeze4me wrote: Mon Apr 11, 2022 7:36 am
Hello

I have minimal mod

Code: Select all

; Minimal size compile '*.exe' - PureBasic 4.30

Command.s = ProgramParameter()  ; e.g.: "SET varname="

Procedure BrowseCallbackProc(hwnd, uMsg, lParam, *lpData)
  Protected Buffer.s, hShell, hTree
  
  If uMsg = #BFFM_INITIALIZED
    hShell = GetDlgItem_(hwnd, 0)
    If hShell
      hTree = GetDlgItem_(hShell, 100)
      If hTree
        Buffer = Space(64)
        If GetClassName_(hTree, @Buffer, 63)
          ; If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
          If FindString(LCase(Buffer), "treeview", 1)
            SetWindowLong_(hTree, #GWL_STYLE, GetWindowLong_(hTree, #GWL_STYLE) & ~#TVS_SINGLEEXPAND)  ;Prevent an item from expanding with a single click.
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  
  Path$ = Path.s

  If Path$

  If Right(Path$,2) <> ":\" : Path$ = Left(Path$,Len(Path$)-1) : EndIf
  
  If command And Right(command,1) <> "=" : command + " " : EndIf 

  Path$ = Chr('"')+Path$+Chr('"')

  OpenConsole()
  PrintN(command + Path$)

  Sleep_(5000)
  
  EndIf

  ProcedureReturn 0
EndProcedure

Define dir.BROWSEINFO

dir\lpfn = @BrowseCallbackProc()         ;Specify the procedure for preventing one click expansion.
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
SHBrowseForFolder_(@dir)
Why errox, how fix error?

I have this

If i one click left button mouse on C:\, i one click left button mouse OK - in console=cmd i have path C:\ (with symbol \ after C:)

If i one click left button mouse on C:\Windows, i one click left button mouse OK - in console=cmd i have path C:\Windows (without symbol \ after word Windows)

Image

Re: Resizing third-party window that has a minimum

Posted: Tue Apr 12, 2022 5:15 pm
by breeze4me
SharkyEXE wrote: Tue Apr 12, 2022 4:18 pm Why errox, how fix error?

I have this

If i one click left button mouse on C:\, i one click left button mouse OK - in console=cmd i have path C:\ (with symbol \ after C:)

If i one click left button mouse on C:\Windows, i one click left button mouse OK - in console=cmd i have path C:\Windows (without symbol \ after word Windows)
Try this.

Code: Select all

; Minimal size compile '*.exe' - PureBasic 4.30

Command.s = ProgramParameter()  ; e.g.: "SET varname="

Procedure BrowseCallbackProc(hwnd, uMsg, lParam, *lpData)
  Protected Buffer.s, hShell, hTree
  
  If uMsg = #BFFM_INITIALIZED
    hShell = GetDlgItem_(hwnd, 0)
    If hShell
      hTree = GetDlgItem_(hShell, 100)
      If hTree
        Buffer = Space(64)
        If GetClassName_(hTree, @Buffer, 63)
          ; If FindString(Buffer, "treeview", 1, #PB_String_NoCase)
          If FindString(LCase(Buffer), "treeview", 1)
            SetWindowLong_(hTree, #GWL_STYLE, GetWindowLong_(hTree, #GWL_STYLE) & ~#TVS_SINGLEEXPAND)  ;Prevent an item from expanding with a single click.
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  
  ProcedureReturn 0
EndProcedure


Define dir.BROWSEINFO

dir\lpfn = @BrowseCallbackProc()         ;Specify the procedure for preventing one click expansion.
dir\ulFlags = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE   ; #BIF_NEWDIALOGSTYLE flag is essential. Without the flag, child controls cannot be rearranged.
Result = SHBrowseForFolder_(@dir)

If Result
  
  Path$ = Space(#MAX_PATH)       ;Create a buffer to receive the string as a result of SHGetPathFromIDList function.
  
  SHGetPathFromIDList_(Result, @Path$)   ;Convert the returned result to a file system path.
  
  If Path$
    ; The converted path string is as follows.
    ; C:\
    ; C:\Windows
    
    Path$ = Chr('"')+Path$+Chr('"')
    
    If command And Right(command,1) <> "=" : command + " " : EndIf 
    
    OpenConsole()
    PrintN(command + Path$)
    
    Sleep_(5000)
    
  EndIf
EndIf

Re: Resizing third-party window that has a minimum

Posted: Tue Apr 12, 2022 6:28 pm
by SharkyEXE
breeze4me wrote: Tue Apr 12, 2022 5:15 pm
Try this.

https://www.purebasic.fr/english/viewto ... 70#p583070
Hello

Thank You Very Much

Excellent, work perfectly!

Image
Image
Image
Image

Re: Resizing third-party window that has a minimum

Posted: Sun Jun 05, 2022 9:35 am
by SharkyEXE
breeze4me

Hello

On delphi programmers language possible make this select folder

Image

But size windows DO not change - left, right, up, down

As possible, make on PureBasic + make change size windows - left, right, up, down

Thank You!

Re: Resizing third-party window that has a minimum

Posted: Sun Jun 05, 2022 8:20 pm
by breeze4me
SharkyEXE wrote: Sun Jun 05, 2022 9:35 am Image
That dialog window is a way of using a custom template. (using GetOpenFileName with #OFN_ENABLETEMPLATE or #OFN_ENABLETEMPLATEHANDLE flags)
This method is impossible to automatically resize. Automatic resizing must have the OFN_EXPLORER flag, but it cannot be used with the template flags.
What defines an old-style common dialog?

That is, the size or position of all controls should be calculated each time and manually rearranged according to the size of the window.
So, I think it would be easier to make a new custom window and handle it.



Edit:
First of all, the code below is NOT a solution, and it's an incomplete code.

I couldn't get the Delphi template, so I modified MS's open file template and played with it as a test.
So the arrangement of dialog controls is very different. :mrgreen:

Save the following code as "FileOpen.rc" and create "FileOpen.res" file with the MS resource compiler.
rc /r FileOpen.rc
Or, run the PB code attached below and create "FileOpen.res" file.

Code: Select all

FILEOPENORD DIALOG LOADONCALL MOVEABLE DISCARDABLE  36, 24, 268, 134
STYLE 2160853124
CAPTION "Open"
FONT 8, "MS Shell Dlg"
BEGIN
    LTEXT           "Folder &name:", 0x0442, 6, 6, 76, 9
    EDITTEXT        0x0480, 6, 16, 90, 12, 66688
    LISTBOX         0x0460, 6, 32, 90, 68, 2166867

    LTEXT           "&Folders:", 0x444, 110, 6, 96, 9
    LTEXT           "", 0x0440, 110, 16, 96, 9, 128
    LISTBOX         0x0461, 110, 32, 96, 68, 2166867

    LTEXT           "List files of &type:", 0x0441, 6, 104, 90, 9
    COMBOBOX        0x0470, 6, 114, 90, 96, 2162755

    LTEXT           "Dri&ves:", 0x0443, 110, 104, 96, 9
    COMBOBOX        0x0471, 110, 114, 96, 68, 2163539

    DEFPUSHBUTTON   "OK", 1, 212, 6, 50, 14, 131072
    PUSHBUTTON      "Cancel", 2, 212, 24, 50, 14, 131072

    PUSHBUTTON      "&Help", 0x040e, 212, 46, 50, 14, 131072
    AUTOCHECKBOX    "&Read only", 0x0410, 212, 68, 50, 12, 196608
END

Code: Select all

File$ = "Z:\FileOpen.res"

If FileSize(File$) = -1
  If CreateFile(0, File$)
    WriteData(0, ?label_FileOpen_res, 676)
    CloseFile(0)
    Debug "Done."
  EndIf
EndIf

DataSection
  label_FileOpen_res:
  ;- "Z:\FileOpen.res"   Size: 676 bytes
  ;{
  Data.q $0000002000000000, $0000FFFF0000FFFF, $0000000000000000, $0000000000000000, $000000340000024E, $004900460005FFFF, $0050004F0045004C, $0052004F004E0045
  Data.q $0000000000000044, $0000000004091030, $80CC00C400000000, $0024000E00000000, $00000086010C0018, $00650070004F0000, $004D00080000006E, $0068005300200053
  Data.q $0020006C006C0065, $00000067006C0044, $0000000050020000, $0009004C00060006, $00460082FFFF0442, $00650064006C006F, $006E002600200072, $003A0065006D0061
  Data.q $5081048000000000, $0010000600000000, $FFFF0480000C005A, $0000000000000081, $0000000050A11053, $0044005A00200006, $00000083FFFF0460, $5002000000000000
  Data.q $0006006E00000000, $FFFF044400090060, $006F004600260082, $007200650064006C, $00000000003A0073, $0000000050020080, $000900600010006E, $00000082FFFF0440
  Data.q $50A1105300000000, $0020006E00000000, $FFFF046100440060, $0000000000000083, $0000000050020000, $0009005A00680006, $004C0082FFFF0441, $0020007400730069
  Data.q $0065006C00690066, $0066006F00200073, $0079007400260020, $0000003A00650070, $5021004300000000, $0072000600000000, $FFFF04700060005A, $0000000000000085
  Data.q $0000000050020000, $000900600068006E, $00440082FFFF0443, $0076002600690072, $0000003A00730065, $5021035300000000, $0072006E00000000, $FFFF047100440060
  Data.q $0000000000000085, $0000000050030001, $000E0032000600D4, $004F0080FFFF0001, $000000000000004B, $0000000050030000, $000E0032001800D4, $00430080FFFF0002
  Data.q $00650063006E0061, $000000000000006C, $0000000050030000, $000E0032002E00D4, $00260080FFFF040E, $0070006C00650048, $5003000300000000, $004400D400000000
  Data.q $FFFF0410000C0032, $0065005200260080, $006F002000640061, $00000079006C006E
  Data.a $00, $00, $00, $00
  label_FileOpen_res_End:
  ;}
EndDataSection
Test code:

Code: Select all

EnableExplicit

Import "Z:\FileOpen.res" : EndImport

Structure STRUC_ControlInfo
  Handle.i
  rt.RECT
EndStructure

Enumeration
  #TextFile
  #EditFile
  #ListboxFile
  
  #TextFolder0
  #TextFolder1
  #ListboxFolder
  
  #TextType
  #ComboType
  
  #TextDrive
  #ComboDrive
  
  #ButtonOK
  #ButtonCancel
  #ButtonHelp
  
  #CheckReadOnly
EndEnumeration

Structure STRUC_Distance
  left.l
  top1.l
  top2.l
  bottom.l
  Gap1.l
  Gap2.l
EndStructure

Global SelChanged

Procedure OFNHookProcOldStyle(hdlg, uiMsg, wParam, lParam)
  Protected MainWindow.RECT
  Protected r.RECT, PartWidth, left, Width, Height
  Protected Buffer.s{256}
  
  Static *ofn.OPENFILENAME
  Static Dim Controls.STRUC_ControlInfo(13)
  Static c.STRUC_Distance
  
  If uiMsg = SelChanged
    If wParam = $471
      DlgDirSelectEx_(hdlg, @Buffer, 255, $461)
      Buffer = RTrim(Buffer, ".")
      SetWindowText_(Controls(#EditFile)\Handle, Buffer)
    EndIf
    
    If wParam = $461
      DlgDirSelectEx_(hdlg, @Buffer, 255, $461)
      Buffer = RTrim(Buffer, ".")
      SetWindowText_(Controls(#EditFile)\Handle, Buffer)
    EndIf
  EndIf
  
  If uiMsg = #WM_INITDIALOG
    *ofn = lParam
    
    GetClientRect_(hdlg, MainWindow)
    
    With Controls(#TextFile)
      \Handle = GetDlgItem_(hdlg, $442)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    With Controls(#EditFile)
      \Handle = GetDlgItem_(hdlg, $480)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      SendMessage_(\Handle, #EM_SETREADONLY, 1, 0)
      Buffer = PeekS(*ofn\lpstrInitialDir)
      SetWindowText_(\Handle, Buffer)
    EndWith
    With Controls(#ListboxFile)
      \Handle = GetDlgItem_(hdlg, $460)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      c\bottom = MainWindow\bottom - \rt\bottom
    EndWith
    
    With Controls(#TextFolder0)
      \Handle = GetDlgItem_(hdlg, $444)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    With Controls(#TextFolder1)
      \Handle = GetDlgItem_(hdlg, $440)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    With Controls(#ListboxFolder)
      \Handle = GetDlgItem_(hdlg, $461)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    
    With Controls(#TextType)
      \Handle = GetDlgItem_(hdlg, $441)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      c\top1 = MainWindow\bottom - \rt\top
    EndWith
    With Controls(#ComboType)
      \Handle = GetDlgItem_(hdlg, $470)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      c\top2 = MainWindow\bottom - \rt\top
      EnableWindow_(\Handle, 0)
    EndWith
    
    With Controls(#TextDrive)
      \Handle = GetDlgItem_(hdlg, $443)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    With Controls(#ComboDrive)
      \Handle = GetDlgItem_(hdlg, $471)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    
    With Controls(#ButtonOK)
      \Handle = GetDlgItem_(hdlg, 1)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      c\left = MainWindow\right - \rt\left
    EndWith
    With Controls(#ButtonCancel)
      \Handle = GetDlgItem_(hdlg, 2)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    With Controls(#ButtonHelp)
      \Handle = GetDlgItem_(hdlg, $40e)
      GetWindowRect_(\Handle, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    
    With Controls(#CheckReadOnly)
      \Handle = GetDlgItem_(hdlg, $410)
      ShowWindow_(\Handle, #SW_HIDE)
      ;GetWindowRect_(\Handle, @\rt)
      ;MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    
    c\Gap1 = Controls(#ListboxFolder)\rt\left - Controls(#ListboxFile)\rt\right
    c\Gap2 = Controls(#ButtonOK)\rt\left - Controls(#ListboxFolder)\rt\right
    
    SetFocus_(Controls(#ButtonOK)\Handle)
  EndIf
  
  
  #Mode = 1
  
  If uiMsg = #WM_COMMAND
    If wParam & $FFFF = $460
      ProcedureReturn 1
    EndIf
    
    If wParam & $FFFF = 1
      GetWindowText_(Controls(#EditFile)\Handle, @Buffer, 255)
      
      If FindString(Buffer, ":\")
        SetWindowText_(Controls(#EditFile)\Handle, Buffer)
        PokeS(*ofn\lpstrFile, Buffer)
        
        PostMessage_(hdlg, #WM_COMMAND, #IDABORT, 1)
        ProcedureReturn 1
      EndIf
      
      CompilerIf #Mode = 1
        SetWindowText_(Controls(#EditFile)\Handle, Buffer)
        PostMessage_(hdlg, #WM_COMMAND, #IDOK, 0)
      CompilerEndIf
    EndIf
    
    CompilerIf #Mode = 1
      If wParam & $FFFF = $461
        DlgDirSelectEx_(hdlg, @Buffer, 255, $461)
        Buffer = RTrim(Buffer, ".")
        SetWindowText_(Controls(#EditFile)\Handle, Buffer)
      EndIf
    CompilerEndIf
  EndIf
  
  If uiMsg = #WM_SIZE
    GetClientRect_(hdlg, r)
    Width = r\right - r\left
    Height = r\bottom - r\top
    
    PartWidth = (Width - c\Gap1 - c\Gap2 - Controls(#ListboxFile)\rt\left - c\left) /2
    
    With Controls(#TextFile)
      SetWindowPos_(\Handle, 0, 0, 0, PartWidth, \rt\bottom - \rt\top, #SWP_NOMOVE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    With Controls(#EditFile)
      SetWindowPos_(\Handle, 0, 0, 0, PartWidth, \rt\bottom - \rt\top, #SWP_NOMOVE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    With Controls(#ListboxFile)
      SetWindowPos_(\Handle, 0, 0, 0, PartWidth, Height - c\bottom - \rt\top, #SWP_NOMOVE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    
    left = Controls(#ListboxFile)\rt\left + PartWidth + c\Gap1
    
    With Controls(#TextFolder0)
      SetWindowPos_(\Handle, 0, left, \rt\top, PartWidth, \rt\bottom - \rt\top, #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    With Controls(#TextFolder1)
      SetWindowPos_(\Handle, 0, left, \rt\top, PartWidth, \rt\bottom - \rt\top, #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    With Controls(#ListboxFolder)
      SetWindowPos_(\Handle, 0, left, \rt\top, PartWidth, Height - c\bottom - \rt\top, #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    
    With Controls(#TextType)
      SetWindowPos_(\Handle, 0, \rt\left, Height - c\top1, PartWidth, \rt\bottom - \rt\top, #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    With Controls(#ComboType)
      SetWindowPos_(\Handle, 0, \rt\left, Height - c\top2, PartWidth, \rt\bottom - \rt\top, #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    
    With Controls(#TextDrive)
      SetWindowPos_(\Handle, 0, left, Height - c\top1, PartWidth, \rt\bottom - \rt\top, #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    With Controls(#ComboDrive)
      SetWindowPos_(\Handle, 0, left, Height - c\top2, PartWidth, \rt\bottom - \rt\top, #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    
    left = Width - c\left
    
    With Controls(#ButtonOK)
      SetWindowPos_(\Handle, 0, left, \rt\top, 0, 0, #SWP_NOSIZE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    With Controls(#ButtonCancel)
      SetWindowPos_(\Handle, 0, left, \rt\top, 0, 0, #SWP_NOSIZE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    With Controls(#ButtonHelp)
      SetWindowPos_(\Handle, 0, left, \rt\top, 0, 0, #SWP_NOSIZE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
    EndWith
    ;With Controls(#CheckReadOnly)
    ;  SetWindowPos_(\Handle, 0, left, \rt\top, 0, 0, #SWP_NOSIZE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
    ;EndWith
  EndIf
  
  ProcedureReturn 0
EndProcedure

Procedure.s OldStyleSelectionDlg(sInitDir.s = "")
  Protected ofn.OPENFILENAME, sResult.s
  Protected sDescription.s, sFilter.s, StringLen
  Protected sFiles.s{256}
  Protected *Buffer, *FilterBuffer
  
  If sInitDir = "" : sInitDir = "C:\" : EndIf
  
  sDescription = "All Files (*.*)"
  sFilter = "*.*"
  StringLen + StringByteLength(sDescription) + StringByteLength(sFilter) + SizeOf(Character) * 3
  
  *FilterBuffer = AllocateMemory(StringLen)
  If *FilterBuffer = 0 : ProcedureReturn "" : EndIf
  
  *Buffer = *FilterBuffer
  CopyMemoryString(sDescription, @*Buffer)
  *Buffer + SizeOf(Character)
  CopyMemoryString(sFilter, @*Buffer)
  *Buffer + SizeOf(Character)
  
  With ofn
      \lStructSize = SizeOf(OPENFILENAME)
      ;\hWndOwner
      \hInstance = GetModuleHandle_(0)
      \lpstrFilter = *FilterBuffer
      ;\lpstrCustomFilter
      ;\nMaxCustFilter
      \nFilterIndex = 0
      \lpstrFile = @sFiles
      \nMaxFile = 254
      ;\lpstrFileTitle
      ;\nMaxFileTitle
      \lpstrInitialDir = @sInitDir
      \lpstrTitle = @"Select a directory"
      \Flags = #OFN_ENABLETEMPLATE | #OFN_LONGNAMES | #OFN_NONETWORKBUTTON | #OFN_ENABLEHOOK
      ;\nFileOffset
      ;\nFileExtension
      ;\lpstrDefExt
      ;\lCustData
      \lpfnHook = @OFNHookProcOldStyle()
      \lpTemplateName = @"FILEOPENORD"
  EndWith
  
  SelChanged = RegisterWindowMessage_("commdlg_LBSelChangedNotify")
  
  If GetOpenFileName_(ofn)
    sResult = GetPathPart(PeekS(@sFiles))
  EndIf
  
  If *FilterBuffer : FreeMemory(*FilterBuffer) : EndIf
  
  ProcedureReturn sResult
EndProcedure

Debug OldStyleSelectionDlg()
Conclusion:
Just use PB gadgets to create your own selection dialog window. :twisted:

Re: Resizing third-party window that has a minimum

Posted: Mon Jun 06, 2022 6:59 pm
by SharkyEXE
breeze4me

Hello

Thank You very much!

Image

I need help

1) Swap the left and right parts
2) In Field Folder name write full path, include letter, C:\Windows, without "\" in end stroke
Write C:\Windows
Not write C:\Windows\ (without "\" in end stroke)
3) If possible, Button OK and Cancel move below lines Drive

Image

Re: Resizing third-party window that has a minimum

Posted: Tue Jun 07, 2022 5:23 am
by breeze4me
SharkyEXE wrote: Mon Jun 06, 2022 6:59 pm 1) Swap the left and right parts
2) In Field Folder name write full path, include letter, C:\Windows, without "\" in end stroke
Write C:\Windows
Not write C:\Windows\ (without "\" in end stroke)
3) If possible, Button OK and Cancel move below lines Drive
All right, so here's the modified code.

Code: Select all

File$ = "Z:\FileOpen.res"

If FileSize(File$) = -1
  If CreateFile(0, File$)
    WriteData(0, ?label_FileOpen_res, 736)
    CloseFile(0)
    Debug "Done."
  EndIf
EndIf

DataSection
  label_FileOpen_res:
  ;- "Z:\FileOpen.res"   Size: 736 bytes
  ;{
  Data.q $0000002000000000, $0000FFFF0000FFFF, $0000000000000000, $0000000000000000, $000000340000028C, $004900460005FFFF, $0050004F0045004C, $0052004F004E0045
  Data.q $0000000000000044, $0000000004091030, $FFFF000100000000, $0000000000000000, $0024000E80CC00C4, $000000CE00DA0018, $00650070004F0000, $000000080000006E
  Data.q $00200053004D0000, $006C006500680053, $006C00440020006C, $0000000000000067, $5002000000000000, $0009006000060006, $0082FFFF00000444, $006C006F00460026
  Data.q $0020007200650064, $0065006D0061006E, $000000000000003A, $0000048000000000, $0012000650810080, $00000490000B00CC, $000000000081FFFF, $0000000000000000
  Data.q $001E000650A11053, $0000046100960060, $000000000083FFFF, $0000000000000000, $001E007250020000, $0000044100090060, $0069004C0082FFFF, $0066002000740073
  Data.q $00730065006C0069, $00200066006F0020, $0070007900740026, $00000000003A0065, $0000000000000000, $002A007250200043, $0000047000600060, $000000000085FFFF
  Data.q $0000000000000000, $003C007250A11053, $0000046000600060, $000000000083FFFF, $0000000000000000, $009B007250020000, $0000044300090060, $007200440082FFFF
  Data.q $0065007600260069, $00000000003A0073, $0000000000000000, $00A7007250210353, $0000047100440060, $000000000085FFFF, $0000000000000000, $00BA006650030001
  Data.q $00000001000E0032, $004B004F0080FFFF, $0000000000000000, $5003000000000000, $000E003200BA00A0, $0080FFFF00000002, $0063006E00610043, $00000000006C0065
  Data.q $0000000000000000, $00BA000648030000, $0000040E000E002A, $004800260080FFFF, $00000070006C0065, $0000000000000000, $4881048000000000, $000C005A00B40006
  Data.q $0081FFFF00000480, $0000000000000000, $4002008000000000, $000C0BB800120006, $0082FFFF00000440, $0000000000000000, $4802000300000000, $000C002A00BA0036
  Data.q $0080FFFF00000410, $0061006500520026, $006E006F00200064, $000000000079006C
  label_FileOpen_res_End:
  ;}
EndDataSection

Code: Select all

FILEOPENORD DIALOGEX 36, 24, 218, 206
STYLE 2160853124
CAPTION "Open"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
    LTEXT           "&Folder name:",0x444,6,6,96,9
    EDITTEXT        0x490,6,18,204,11,128,1152
    LISTBOX         0x461,6,30,96,150,2166867
    LTEXT           "List files of &type:",0x441,114,30,96,9
    COMBOBOX        0x470,114,42,96,96,2097219
    LISTBOX         0x460,114,60,96,96,2166867
    LTEXT           "Dri&ves:",0x443,114,155,96,9
    COMBOBOX        0x471,114,167,96,68,2163539
    DEFPUSHBUTTON   "OK",1,102,186,50,14,131072
    PUSHBUTTON      "Cancel",2,160,186,50,14,131072
    PUSHBUTTON      "&Help",0x40e,6,186,42,14,NOT 268435456 | 134348800
    EDITTEXT        0x480,6,180,90,12, 134218880 | NOT 268435456
    LTEXT           "",0x440,6,18,3000,12,128 | NOT 268435456
    CONTROL         "&Read only",0x410,"Button",NOT 268435456 | 134348803,54,186,42,12
END

Code: Select all

EnableExplicit

Import "Z:\FileOpen.res" : EndImport

Structure STRUC_ControlInfo
  hWnd.i
  rt.RECT
  OrigWidth.l
  OrigHeight.l
EndStructure

Enumeration
  #EditFolderFullPath
  #ListboxFolder
  
  #TextType
  #ComboType
  
  #ListboxFile
  
  #TextDrive
  #ComboDrive
  
  #ButtonOK
  #ButtonCancel
  
  #TextFolderFullPath
EndEnumeration

Procedure OFNHookProcOldStyle(hdlg, uiMsg, wParam, lParam)
  Protected MainWindow.RECT, *mmi.MINMAXINFO
  Protected hWinPosInfo, LboxFolderWidth, LboxFileWidth, x
  Protected Buffer.s{256}
  
  Static *ofn.OPENFILENAME
  Static Dim Controls.STRUC_ControlInfo(9)
  Static SelChanged
  
  Static WinMinW, WinMinH
  Static LeftMargin, MidMargin, RightMargin, LeftOK, LeftCancel, TopTextDrive, TopComboDrive, TopButtons, LboxFolderBottomMargin, LboxFileBottomMargin
  Static LboxFolderWidthRatio.f
  
  If uiMsg = SelChanged
    If wParam = $471
      GetWindowText_(Controls(#TextFolderFullPath)\hWnd, @Buffer, 255)
      SetWindowText_(Controls(#EditFolderFullPath)\hWnd, Buffer)
    EndIf
    
    If wParam = $461
      GetWindowText_(Controls(#TextFolderFullPath)\hWnd, @Buffer, 255)
      SetWindowText_(Controls(#EditFolderFullPath)\hWnd, Buffer)
    EndIf
  EndIf
  
  If uiMsg = #WM_INITDIALOG
    *ofn = lParam
    
    If *ofn
      If *ofn\lCustData
        SelChanged = PeekI(*ofn\lCustData + 8)
        PokeI(*ofn\lCustData + 8, 0)
      EndIf
    EndIf
    
    SetWindowLongPtr_(hdlg, #GWL_STYLE, GetWindowLongPtr_(hdlg, #GWL_STYLE) | #WS_CLIPCHILDREN)
    SetWindowPos_(hdlg, 0, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
    
    GetClientRect_(hdlg, MainWindow)
    
    With Controls(#EditFolderFullPath)
      \hWnd = GetDlgItem_(hdlg, $490)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      SendMessage_(\hWnd, #EM_SETREADONLY, 1, 0)
      \OrigHeight = \rt\bottom - \rt\top
      If *ofn
        If *ofn\lpstrInitialDir
          Buffer = PeekS(*ofn\lpstrInitialDir)
          If FileSize(Buffer) = -2
            If Right(Buffer, 2) <> ":\"
              Buffer = RTrim(Buffer, "\")
            EndIf
            SetWindowText_(\hWnd, Buffer)
          EndIf
        EndIf
      EndIf
    EndWith
    
    With Controls(#ListboxFolder)
      \hWnd = GetDlgItem_(hdlg, $461)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      \OrigWidth = \rt\right - \rt\left
    EndWith
    
    With Controls(#TextType)
      \hWnd = GetDlgItem_(hdlg, $441)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      \OrigHeight = \rt\bottom - \rt\top
    EndWith
    
    With Controls(#ComboType)
      \hWnd = GetDlgItem_(hdlg, $470)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      \OrigHeight = \rt\bottom - \rt\top
      EnableWindow_(\hWnd, 0)
    EndWith
    
    With Controls(#ListboxFile)
      \hWnd = GetDlgItem_(hdlg, $460)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    
    With Controls(#TextDrive)
      \hWnd = GetDlgItem_(hdlg, $443)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      \OrigHeight = \rt\bottom - \rt\top
    EndWith
    
    With Controls(#ComboDrive)
      \hWnd = GetDlgItem_(hdlg, $471)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
      \OrigHeight = \rt\bottom - \rt\top
    EndWith
    
    With Controls(#ButtonOK)
      \hWnd = GetDlgItem_(hdlg, 1)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    
    With Controls(#ButtonCancel)
      \hWnd = GetDlgItem_(hdlg, 2)
      GetWindowRect_(\hWnd, @\rt)
      MapWindowPoints_(0, hdlg, @\rt, 2)
    EndWith
    
    With Controls(#TextFolderFullPath)
      \hWnd = GetDlgItem_(hdlg, $440)
    EndWith
    
    LeftMargin = Controls(#ListboxFolder)\rt\left
    MidMargin = Controls(#ListboxFile)\rt\left - Controls(#ListboxFolder)\rt\right
    RightMargin = MainWindow\right - Controls(#ListboxFile)\rt\right
    
    LeftOK = MainWindow\right - Controls(#ButtonOK)\rt\left
    LeftCancel = MainWindow\right - Controls(#ButtonCancel)\rt\left
    
    TopTextDrive = MainWindow\bottom - Controls(#TextDrive)\rt\top
    TopComboDrive = MainWindow\bottom - Controls(#ComboDrive)\rt\top
    TopButtons = MainWindow\bottom - Controls(#ButtonOK)\rt\top
    
    LboxFolderWidthRatio = Controls(#ListboxFolder)\OrigWidth / (MainWindow\right - LeftMargin - RightMargin - MidMargin)
    
    LboxFolderBottomMargin = MainWindow\bottom - Controls(#ListboxFolder)\rt\bottom
    LboxFileBottomMargin = MainWindow\bottom - Controls(#ListboxFile)\rt\bottom
    
    GetWindowRect_(hdlg, MainWindow)
    With MainWindow
      WinMinW = \right - \left
      WinMinH = \bottom - \top
    EndWith
    
    SetFocus_(Controls(#ButtonOK)\hWnd)
  EndIf
  
  If uiMsg = #WM_GETMINMAXINFO
    *mmi = lParam
    If *mmi
      *mmi\ptMinTrackSize\x = WinMinW
      *mmi\ptMinTrackSize\y = WinMinH
    EndIf
  EndIf
  
  If uiMsg = #WM_SIZE
    GetClientRect_(hdlg, MainWindow)
    
    hWinPosInfo = BeginDeferWindowPos_(9)
    If hWinPosInfo
      
      LboxFolderWidth = (MainWindow\right - LeftMargin - RightMargin - MidMargin) * LboxFolderWidthRatio
      LboxFileWidth = MainWindow\right - LeftMargin - RightMargin - MidMargin - LboxFolderWidth
      x = LeftMargin + LboxFolderWidth + MidMargin
      
      With Controls(#EditFolderFullPath)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, 0, 0, MainWindow\right - LeftMargin - RightMargin, \OrigHeight, #SWP_NOMOVE | #SWP_NOZORDER)
      EndWith
      With Controls(#ListboxFolder)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, 0, 0, LboxFolderWidth, MainWindow\bottom - LboxFolderBottomMargin - \rt\top, #SWP_NOMOVE | #SWP_NOZORDER)
      EndWith
      With Controls(#TextType)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, x, \rt\top, LboxFileWidth, \OrigHeight, #SWP_NOZORDER)
      EndWith
      With Controls(#ComboType)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, x, \rt\top, LboxFileWidth, \OrigHeight, #SWP_NOZORDER)
      EndWith
      With Controls(#ListboxFile)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, x, \rt\top, LboxFileWidth, MainWindow\bottom - LboxFileBottomMargin - \rt\top, #SWP_NOZORDER)
      EndWith
      With Controls(#TextDrive)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, x, MainWindow\bottom - TopTextDrive, LboxFileWidth, \OrigHeight, #SWP_NOZORDER)
      EndWith
      With Controls(#ComboDrive)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, x, MainWindow\bottom - TopComboDrive, LboxFileWidth, \OrigHeight, #SWP_NOZORDER)
      EndWith
      With Controls(#ButtonOK)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, MainWindow\right - LeftOK, MainWindow\bottom - TopButtons, 0, 0, #SWP_NOSIZE | #SWP_NOZORDER)
      EndWith
      With Controls(#ButtonCancel)
        DeferWindowPos_(hWinPosInfo, \hWnd, 0, MainWindow\right - LeftCancel, MainWindow\bottom - TopButtons, 0, 0, #SWP_NOSIZE | #SWP_NOZORDER)
      EndWith
      
      EndDeferWindowPos_(hWinPosInfo)
      
      RedrawWindow_(hdlg, 0, 0, #RDW_ALLCHILDREN | #RDW_UPDATENOW | #RDW_NOERASE | #RDW_INTERNALPAINT | #RDW_VALIDATE | #RDW_FRAME)
    EndIf
  EndIf
  
  If uiMsg = #WM_COMMAND
    If wParam & $FFFF = $460
      ProcedureReturn 1
    EndIf
    
    If wParam & $FFFF = 1
      GetWindowText_(Controls(#EditFolderFullPath)\hWnd, @Buffer, 255)
      If *ofn
        If *ofn\lCustData
          PokeS(*ofn\lCustData, Buffer)
        EndIf
      EndIf
      
      PostMessage_(hdlg, #WM_COMMAND, #IDABORT, 1)
      ProcedureReturn 1
    EndIf
  EndIf
  
  ProcedureReturn 0
EndProcedure

Procedure.s OldStyleSelectionDlg(sInitDir.s = "")
  Protected ofn.OPENFILENAME, sResult.s
  Protected sDescription.s, sFilter.s, StringLen, SelChanged
  Protected sFiles.s{256}
  Protected *Buffer, *FilterBuffer
  
  If sInitDir = "" : sInitDir = "C:\" : EndIf
  
  sDescription = "All Files (*.*)"
  sFilter = "*.*"
  StringLen + StringByteLength(sDescription) + StringByteLength(sFilter) + SizeOf(Character) * 3
  
  *FilterBuffer = AllocateMemory(StringLen)
  If *FilterBuffer = 0 : ProcedureReturn "" : EndIf
  
  *Buffer = *FilterBuffer
  CopyMemoryString(sDescription, @*Buffer)
  *Buffer + SizeOf(Character)
  CopyMemoryString(sFilter, @*Buffer)
  
  SelChanged = RegisterWindowMessage_("commdlg_LBSelChangedNotify")
  
  PokeI(@sFiles + 8, SelChanged)
  
  With ofn
      \lStructSize = SizeOf(OPENFILENAME)
      ;\hWndOwner
      \hInstance = GetModuleHandle_(0)
      \lpstrFilter = *FilterBuffer
      ;\lpstrCustomFilter
      ;\nMaxCustFilter
      \nFilterIndex = 0
      \lpstrFile = @sFiles
      \nMaxFile = 254
      ;\lpstrFileTitle
      ;\nMaxFileTitle
      \lpstrInitialDir = @sInitDir
      \lpstrTitle = @"Select Directory"
      \Flags = #OFN_ENABLETEMPLATE | #OFN_LONGNAMES | #OFN_NONETWORKBUTTON | #OFN_ENABLEHOOK
      ;\nFileOffset
      ;\nFileExtension
      ;\lpstrDefExt
      \lCustData = @sFiles
      \lpfnHook = @OFNHookProcOldStyle()
      \lpTemplateName = @"FILEOPENORD"
  EndWith
  
  If GetOpenFileName_(ofn)
    If sFiles
      sResult = RTrim(sFiles, "\")
    EndIf
  EndIf
  
  If *FilterBuffer : FreeMemory(*FilterBuffer) : EndIf
  
  ProcedureReturn sResult
EndProcedure

Debug OldStyleSelectionDlg()

Re: Resizing third-party window that has a minimum

Posted: Tue Jun 07, 2022 5:36 pm
by SharkyEXE
breeze4me

Hello

Excelent!

Image

Your wtite, that may be write this windows on PureBasic

Image

use PB gadgets

Please, help me, write this windows on PureBasic

Image

use PB gadgets + make change size windows - left, right, up, down

Thank You!

Re: Resizing third-party window that has a minimum

Posted: Tue Jun 07, 2022 5:47 pm
by breeze4me
SharkyEXE wrote: Tue Jun 07, 2022 5:36 pm use PB gadgets + make change size windows - left, right, up, down
I mean, not a dialog window with the same appearance, but a dialog window with the same functionality.
You can use the ExplorerCombo, ExplorerList and ExplorerTree gadgets.