winapi - Get the position of the control in the Windows openfile dialog -


i application, have added dropdown box standard windows file open dialog. works fine, position drop box below file name , file mask edit controls, , label below labels these controls. how can positions of these controls , corresponding labels (it depends on windows version , maybe on theming, using constants make dialog fine on computer won't do)?

on vista+, should using ifiledialog, ifileopendialog , ifiledialogcustomize interfaces:

common item dialog

customizing dialog

you can use ifiledialogcustomize::addtext() , ifiledialogcustomize::addcombobox() methods add drop-down list , label dialog, , if needed use ifiledialogcontrolevents::onitemselected event react user selecting items in drop-down list.

however, cannot decide custom controls displayed when customizing dialog. ui layout controlled dialog itself:

the common item dialog implementation found in windows vista provides several advantages on implementation provided in earlier versions:
...
•enables simple customization of dialog, such setting label on ok button, without requiring hook procedure.
•supports more extensive customization of dialog addition of set of data-driven controls operate without win32 dialog template. this customization scheme frees calling process ui layout. since changes dialog design continue use data model, dialog implementation not tied specific current version of dialog.
...

the layout access provides order in add custom controls, , visual grouping. so, use ifiledialogcustomize::startvisualgroup() create new group, call addtext() , addcombobox() (in order) add controls group, , call ifiledialogcustomize::endvisualgroup().

on other hand, when using getopenfilename() instead, there different options customizing dialog, , allow finer grain control on dialog's layout:

customizing common dialog boxes

open , save dialog box customization

the preferred option create custom dialog box template , specify in openfilename structure. within template, can have whatever controls , layout want, , template can inserted child of standard explorer-style dialog, or replacement standard old-style dialog. msdn documents how custom-position template within explorer-style dialog:

explorer-style custom templates

to make room new controls, system expands default dialog box width , height of custom dialog box. default, controls custom dialog box positioned below controls in default dialog box. however, can override default positioning including static text control in custom dialog box template , assigning control identifier value of stc32. (this value defined in dlgs.h header file.) in case, system uses control point of reference determining position new controls. new controls above , left of stc32 control positioned same amount above , left of controls in default dialog box. new controls below , right of stc32 control positioned below , right of default controls. in general, each new control positioned has same position relative default controls had stc32 control. make room these new controls, system adds space left, right, bottom, , top of default dialog box needed.

the alternative, without using custom template, obtain dialog's own hwnd directly (which can gotten inside hook function assigned openfilename::lpfnhook field) , have full access whatever want dialog. microsoft assigned fixed control ids standard controls of explorer-style dialog (so must specify ofn_explorer flag approach work), , ids consistent across windows versions. ids meant used cdm_setcontroltext , cdm_hidecontrol messages, can used getdlgitem() hwnd of dialog controls, in case cmb13, edt1 , stc3 controls:

cmb13
drop-down combo box displays name of current file, allows user type name of file open, , select file has been opened or saved recently. earlier explorer-compatible applications without hook or dialog template. compare edt1.

edt1
edit control displays name of current file, or allows user type name of file open. compare cmb13.

stc3
label cmb13 combo box , edt1 edit control

once have hwnds, can manually query current positions , sizes, add custom drop-down list underneath them needed, , resize dialog's hwnd accommodate drop-down list.

whether use template or direct hwnd manipulation, need use dialog hook function process messages drop-down list needed, such cbn_selchange notification.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -