Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing the size of the edit box
#1
Can someone help me please?

I would like the edit box to change size based on the toolbar being docked or undocked so I can always see all the text.

Function DFT_Main
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("DFT_Main" &DFT_Main)) ret

;BEGIN DIALOG
;0 "" 0x90CF0A44 0x100 0 0 222 134 "Dialog"
;3 ToolbarWindow32 0x54010000 0x0 0 0 222 17 ""
;4 Edit 0x54030080 0x200 0 0 224 136 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,DFT_TbInit hDlg
,
,case WM_CONTEXTMENU
,sel PopupMenu("Floating")
,,case 1
,,DFT_MakeFloating hDlg 1
,ret 1
,
,case WM_DESTROY
,ImageList_Destroy SendMessage(id(3 hDlg) TB_GETIMAGELIST 0 0)
,
,case WM_SIZE
,// Get window size and adjust edit box to match //
,int x y width height
,GetWinXY(hDlg &x &y &width &height)
,siz width-9 height-35 id(4 hDlg)
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 1001
,out "One"
,case 1002
,out "Two"
,;...
,
,case IDOK
,case IDCANCEL
ret 1

Function DFT_TbInit
Code:
Copy      Help
;/DFT_Main
function hDlg

;Initializes toolbar control.

int htb=id(3 hDlg)
SetWinStyle htb TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|CCS_NODIVIDER 1

;create imagelist just for example
int il=ImageList_Create(16 16 ILC_MASK|ILC_COLOR32 0 15)
Dir d; foreach(d "$QM$\*.ico" FE_Dir) ImageList_ReplaceIcon(il -1 GetFileIcon(d.FileName(1)))
SendMessage htb TB_SETIMAGELIST 0 il

ARRAY(TBBUTTON) a.create(8)
ARRAY(str) as="One[]Two[]Three[]Four[]Five[]Six[]Seven[]Eith"
int i
for i 0 a.len
,TBBUTTON& t=a[i]
,t.idCommand=1001+i
,t.iBitmap=i
,t.iString=SendMessage(htb TB_ADDSTRINGA 0 as[i])
,t.fsState=TBSTATE_ENABLED

SendMessage(htb TB_BUTTONSTRUCTSIZE sizeof(TBBUTTON) 0)
SendMessage(htb TB_ADDBUTTONS a.len &a[0])
SendMessage(htb TB_AUTOSIZE 0 0)

Function DFT_FloatingDlg
Code:
Copy      Help
;/DFT_Main
;\Dialog_Editor

;This is a floating window for the toolbar control.

function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90CC0A44 0x80 0 0 217 130 "Toolbar"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CONTEXTMENU
,sel PopupMenu("Docked")
,,case 1
,,DFT_MakeFloating hDlg 0
,ret 1
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,DFT_MakeFloating hDlg 0
,case else
,;relay toolbar button click messages to the main window
,SendMessage GetWindow(hDlg GW_OWNER) WM_COMMAND wParam lParam
ret 1

Function DFT_MakeFloating
Code:
Copy      Help
;/DFT_Main
function hDlg floating ;;floating: 1 floating, 0 docked.  hDlg must be parent of toolbar control

int htb=id(3 hDlg)

if floating
,;create floating parent window of the toolbar control and move the control there
,int hf=ShowDialog("DFT_FloatingDlg" &DFT_FloatingDlg 0 hDlg 1)
,SetParent htb hf
,
,;resize the new parent window to show whole toolbar control
,RECT r
,SendMessage htb TB_GETITEMRECT SendMessage(htb TB_BUTTONCOUNT 0 0)-1 &r ;;get rect of last button
,r.left=0; r.top=0
,AdjustWindowRectEx &r GetWinStyle(hf) 0 GetWinStyle(hf 1) ;;client -> window
,siz r.right-r.left r.bottom-r.top hf
else
,;move the control to the main window and destroy the floating window
,hf=hDlg
,hDlg=GetWindow(hDlg GW_OWNER)
,SetParent htb hDlg
,DestroyWindow hf

;todo:
;move/resize controls that are below the toolbar.
#2
Mabey if you use gettoolbar owner?
#3
I updated the code in
How to Create (un)Dockable Toolbars in Dialog
#4
You are so assume!!


Forum Jump:


Users browsing this thread: 3 Guest(s)