Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_CheckBox = 500
Global hDlg,hChild As Dword, MinX,CaptionPos As Long
Function PBMain() As Long
Dialog New Pixels, 0, "",400,200,200,100,%WS_ThickFrame Or %WS_Popup To hDlg 'no caption, allow resizig
Control Add CheckBox, hDlg, %IDC_CheckBox, "Caption at Top", 10,30,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local x,y,Style,w,h,ww,hh As Long, pt As Point, MM As MinMaxInfo Ptr
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_CheckBox
Control Get Check hDlg, %IDC_CheckBox To CaptionPos
Dialog Get Loc hDlg To x,y
MoveParent x,y
End Select
Case %WM_GETMINMAXINFO
MM=Cb.LParam
@MM.ptMinTrackSize.x = MinX
@MM.ptMinTrackSize.y = 30
Case %WM_InitDialog
Style = %WS_Overlapped Or %WS_Caption Or %WS_SysMenu Or %WS_MinimizeBox Or %WS_MaximizeBox
Dialog New Pixels, hDlg, "Upside Down Dialog",0,0,0,0, Style To hChild
Dialog Show Modeless hChild Call ChildProc
Case %WM_Size
ResizeParentMoveChild
End Select
End Function
CallBack Function ChildProc() As Long
Local x,y,w,h As Long, ptm,ptc,pt As Point, MM As MINMAXINFO Ptr
Select Case Cb.Msg
Case %WM_GETMINMAXINFO
MM=Cb.LParam
MinX = @MM.ptMinTrackSize.x + 3
Case %WM_Move
MoveParent Lo(Word,Cb.LParam),Hi(Word,Cb.LParam)
Case %WM_NCActivate
If IsFalse(Cb.WParam) Then Function = 1
Case %WM_Destroy
Dialog End hDlg
End Select
End Function
Sub ResizeParentMoveChild
Local w,h,ww,hh As Long
Dialog Get Size hDlg To w,h
If w < MinX Then Dialog Set Size hDlg, MinX,h
Dialog Get Size hChild To ww,hh
Dialog Set Size hChild,w-4,hh
Dialog Set Loc hChild,-1,h-32
End Sub
Sub MoveParent(x As Long, y As Long)
Local w,h As Long, pt As Point
Dialog Get Size hDlg To w,h
ClientToScreen hChild, pt
If CaptionPos Then
Dialog Set Loc hDlg, pt.x-5, pt.y - 24 'top
Else
Dialog Set Loc hDlg, pt.x-5, pt.y - h + 7 'bottom
End If
End Sub
'gbs_00762
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm