Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog Questions - Read-Only and Word Wrap
#1
Hi,

1. Is there an global way to display a dialog in a read-only mode (e.g. all Edit controls disabled) or do I have to create a 2nd version (or page) of the dialog using read-only Edit controls? This is in reference to an INI user settings dialog that loads the existing key values and rewrites the data back to the INI.

Alternatively - and perhaps better - is there a method where all Edit controls are initially read-only, and then provide some per-control method (checkbox, button, ctl-click, whatever) to enable editing a control?

2. Also having trouble getting wrap to display long strings in Edit box (mailto email lists) - it still displays on one line, only with [] added. When written back to the INI the formatting is screwed up so that it won't read the lists properly next time.

Thanks,

S

If you want to take a look, I've attached the files.


Attached Files
.zip   MurFTP_Config_Dlg.zip (Size: 3.19 KB / Downloads: 421)
#2
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "16 17 18 19 20 21 22 23 24 29 30 31 3"
str e16fs e17fu e18fp e19w e20pu e21pv e22ed e23epu e24epv e29et e30pg sb31 c3Res
if(!ShowDialog("MurFTP_Config_Dlg" &MurFTP_Config_Dlg &controls)) ret
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 245 312 "Dialog"
;16 Edit 0x54030084 0x200 56 9 96 14 "fs"
;17 Edit 0x54030084 0x200 56 25 96 14 "fu"
;18 Edit 0x54030084 0x200 56 41 96 14 "fp"
;19 Edit 0x54030084 0x200 56 57 96 14 "w"
;20 Edit 0x54030084 0x200 56 73 96 14 "pu"
;21 Edit 0x54030084 0x200 56 89 96 14 "pv"
;22 Edit 0x54030084 0x200 56 116 96 14 "ed"
;23 Edit 0x54030084 0x200 56 144 178 28 "epu"
;24 Edit 0x54030084 0x200 56 174 178 28 "epv"
;29 Edit 0x54030084 0x200 56 216 176 14 "et"
;30 Edit 0x54030084 0x200 56 242 176 14 "pg"
;1 Button 0x54030001 0x4 136 290 48 15 "OK"
;14 Static 0x54000000 0x0 6 218 50 12 "Event Types"
;2 Button 0x54030000 0x4 186 290 48 15 "Cancel"
;4 Static 0x54000000 0x0 6 10 48 13 "FTP Server"
;5 Static 0x54000000 0x0 6 26 48 13 "FTP User"
;6 Static 0x54000000 0x0 6 42 48 13 "FTP Password"
;8 Static 0x54000000 0x0 6 58 48 13 "Web Address"
;9 Static 0x54000000 0x0 6 74 48 13 "Public Subdir"
;10 Static 0x54000000 0x0 6 90 48 13 "Private Subdir"
;11 Static 0x54000000 0x0 6 118 48 12 "Audio Editor"
;12 Static 0x54000000 0x0 6 148 48 13 "Email List (pub)"
;13 Static 0x54000000 0x0 6 176 48 12 "Email List (priv)"
;15 Static 0x54000000 0x0 6 244 46 13 "Ping URL"
;31 Static 0x5400100E 0x20000 162 6 74 126 ""
;3 Button 0x54012003 0x0 6 284 94 21 "Restore Defaults [](Tick > OK)"
;33 Button 0x54032000 0x0 114 268 48 14 "Enable"
;32 Button 0x54020007 0x0 2 276 102 30 ""
;28 Button 0x54020007 0x0 2 236 236 24 ""
;27 Button 0x54020007 0x0 2 210 236 24 ""
;26 Button 0x54020007 0x0 2 138 236 68 ""
;25 Button 0x54020007 0x0 2 110 154 24 ""
;7 Button 0x54020007 0x0 2 2 154 104 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030002 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,EnableWindow(id(16 hDlg) 0)
,EnableWindow(id(17 hDlg) 0)
,EnableWindow(id(18 hDlg) 0)
,EnableWindow(id(19 hDlg) 0)
,EnableWindow(id(20 hDlg) 0)
,EnableWindow(id(21 hDlg) 0)
,EnableWindow(id(22 hDlg) 0)
,EnableWindow(id(23 hDlg) 0)
,EnableWindow(id(24 hDlg) 0)
,EnableWindow(id(29 hDlg) 0)
,EnableWindow(id(30 hDlg) 0)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 33
,str Disable Enable
,_s.getwintext(id(33 hDlg))
,if _s = "Disable"
,,Enable = "Enable"
,,Enable.setwintext(id(33 hDlg))
,,EnableWindow(id(16 hDlg) 0)
,,EnableWindow(id(17 hDlg) 0)
,,EnableWindow(id(18 hDlg) 0)
,,EnableWindow(id(19 hDlg) 0)
,,EnableWindow(id(20 hDlg) 0)
,,EnableWindow(id(21 hDlg) 0)
,,EnableWindow(id(22 hDlg) 0)
,,EnableWindow(id(23 hDlg) 0)
,,EnableWindow(id(24 hDlg) 0)
,,EnableWindow(id(29 hDlg) 0)
,,EnableWindow(id(30 hDlg) 0)
,else
,,Disable = "Disable"
,,Disable.setwintext(id(33 hDlg))
,,EnableWindow(id(16 hDlg) 1)
,,EnableWindow(id(17 hDlg) 1)
,,EnableWindow(id(18 hDlg) 1)
,,EnableWindow(id(19 hDlg) 1)
,,EnableWindow(id(20 hDlg) 1)
,,EnableWindow(id(21 hDlg) 1)
,,EnableWindow(id(22 hDlg) 1)
,,EnableWindow(id(23 hDlg) 1)
,,EnableWindow(id(24 hDlg) 1)
,,EnableWindow(id(29 hDlg) 1)
,,EnableWindow(id(30 hDlg) 1)

,case IDOK
,case IDCANCEL
ret 1

i have made the edit boxes multiline, u may need to make edit boxes thicker to display multi line i havent played much with them b4.
started the edit boxes disabled
there is button there to enable them and vice verser.

not sure about ini files,


and also for ur outputs ive made it proberly a bit reader friendly

out "NEW OUTPUT INI DATA"
out "%s -- editor" editor
out "%s -- fserver" fserver
out "%s -- uname" uname
out "%s -- pword" pword
out "%s -- pubdir" pubdir
out "%s -- privdir" privdir
out "%s -- website" website
out "%s -- pub_mailto" pub_mailto
out "%s --priv_mailto" priv_mailto

out "%s -- pingurl" pingurl
out "%s -- etypelist" etypelist
out ""
#3
this may help also with the limits for edit controls

* Single-line edit controls are limited to a maximum of 32K (32,767 bytes) of text and, of course, to a single line. By default, single-line edit controls are limited to 30,000 characters. An application can change this limit to a maximum of 32,767 characters with the EM_LIMITTEXT message described in "Edit Control Messages," later in this article.
* Multiple-line edit controls are limited to a maximum of 64K (65,535 bytes) of text. Whether a multiple-line edit control is actually able to approach this limit is based on how the edit control uses memory. Techniques to control the way edit controls use memory are described in the next section, "Edit Controls and Memory." Multiple-line edit controls are also limited to the following:
o characters per line of text
o lines of text
o pixels per line of text
#4
Hey Craig,

Thanks for your good work, which does indeed work and better still, helps me along conceptually.

On mem limits, sorry but I'm not quite clear on the application here.

BTW I did get the Wrap function to work in the Edit boxes by removing the flag 1 (which reassembles the delimited string for processing. Makes perfect sense. It was there so that the main macro can send the email list via mailto).

You can see the result by uncommenting the two Wrap lines (lines 34/35 and removing the 1 at the end of each.

Thanks again for enabling me to disable!!

Steve
#5
the limits is about how much u can use in a single edit box. how many characters and so on, as u said the full string wasnt fully copied to the edit control, and i dont know how inis work, just thought that the string was to large for edit, but u said u got it all sorted out now so dont worry about that.
#6
Thanks
My fault, I didn't explain it well. One problem was that I wanted a string that was too long to fit in the Edit box display to word-wrap to new lines. This I got working as described above.

The second problem - that I still have - is that I need to restore the str output back to the single-line format b/c is incorrectly written back to the INI file as a multi-line, breaking the INI format.

For example:

wrap.ini
Code:
Copy      Help
[email]
pub_mailto="name@www.site.org, name2@www.site.org, name3@site.org, name4@site.org"

Running this macro:
Macro
Code:
Copy      Help
out
str pub_mailto
out "ORIGINAL INI VALUE"
rget(pub_mailto "pub_mailto" "email" "c:\wrap.ini")
out pub_mailto
out ""
out "WORD WRAP FOR MULTI-LINE EDIT BOX FORMATTING"
pub_mailto.wrap(40 "" ",")
out pub_mailto

Results in the following output:
Code:
Copy      Help
ORIGINAL INI VALUE
name@www.site.org, name2@www.site.org, name3@site.org, name4@site.org

WORD WRAP FOR MULTI-LINE EDIT BOX FORMATTING
name@www.site.org, name2@www.site.org,
name3@site.org, name4@site.org

The problem: I need to restore/condense/reformat the string output back to the Original formatting (i,e., a single line of email addresses, each separated by a comma and space - like what is in the INI file above. Replacerx for "[]" didn't work. Also tried repx with CR and LF codes with no luck.

Any help is appreciated!

S

EDIT: I should mention that the actual macro (as opposed to this sample) is for adding/removing names from the list, so simply pointing back to the original string won't work.
#7
Nevermind...

Multiline edit control is my new friend.

Thanks again for your enable/disable (and output clean-up!).
#8
Very quickly looked at your post and saw problem with escape characters [] ''' etc in str
Not sure if exactly relevant but did you try playing around with the "escape" function - it's described in the qm helpfile but I pasted the entry below.
Stuart



[/quote]Replace escape sequences to characters or vice versa
Syntax
s.escape([flags])



Parts
s - str variable.

flags - one of values below. Default: 0.

0 replace escape sequences ( '', [], [digits]) to characters (", new line, character).
1 replace unsafe characters (", new line, [ , '') to escape sequences.
8 urldecode.
9 urlencode. That is, replace all characters except 0-9, A-Z, a-z, _, - and . to escape sequences in form %xx, where xx is character code in hexadecimal format.
10 same as 8, but decode + to space.
11 same as 9, but encode space to +.



Remarks
Replaces escape sequences to characters, or vice versa.



QM 2.3.0. Removed flag 2 (don't escape characters above 127). Now does not escape these characters. It is because of possible problems with UTF-8.



See also: str.encrypt, str.ansi

Quote:Replace escape sequences to characters or vice versa
Syntax
s.escape([flags])



Parts
s - str variable.

flags - one of values below. Default: 0.

0 replace escape sequences ( '', [], [digits]) to characters (", new line, character).
1 replace unsafe characters (", new line, [ , '') to escape sequences.
8 urldecode.
9 urlencode. That is, replace all characters except 0-9, A-Z, a-z, _, - and . to escape sequences in form %xx, where xx is character code in hexadecimal format.
10 same as 8, but decode + to space.
11 same as 9, but encode space to +.



Remarks
Replaces escape sequences to characters, or vice versa.



QM 2.3.0. Removed flag 2 (don't escape characters above 127). Now does not escape these characters. It is because of possible problems with UTF-8.



See also: str.encrypt, str.ansi

#9
Thanks for taking a look...

Following the original postings on this, I did incorporate the escape sequence you mention.

So upon reading the data from the ini...

pub_mailto.escape(0)
etypelist.escape(0)

...and then the reverse escape(1) for writing back to the ini, and all works like a charm.
#10
Super-stoked that I could help direct you to a solution.
When I was working on something requiring an ini file, Gintaras showed me how to do it with xml. I am not entirely sure I understand why xml is advantageous but it seems like the more modern robust way of doing things and the newere versions of QM support it. I am starting to get the hang of it for multiple different mini-applications I have been writing in QM-script.

Here is the link...Gintaras' solution is kind of way down into it though:

Filling in Button/Edit Text in Dialogs from ini vs macro

Filling in Button/Edit Text in Dialogs from ini vs macro



Good luck,

Stuart
#11
Thanks for the link to XML use - I am in the same boat you are/were...I fully understand INI, which I am using primarily to make my macro (aka albatross) self contained with settings easily editable as opposed to registry use. It looks like XML is the future based on how many programs now use them to store presets etc, and XML offers at least the same benefits as INI, with the exception that it is nowhere near as readable in a text editor.

So...I loaded up Gin's XML example and it sure looks cool, but what exactly does it do?

Thanks!
#12
XML is readable/editable in a text editor.

ini:
[a]
b=bbbb
c=cccc
[d]
e=eeee

xml:
<root>
<a>
<b>bbbb</b>
<c>cccc</c>
</a>
<d>
<e>eeee</e>
</d>
</root>
#13
I was just saying I don't find them as *easy* to read (not can't be):

<UserPreset>
<int name="Can Modify" value="1"/>
<member name="Preset">
<list name="Categories" type="list">
<item>
<string name="Name" value="Add"/>
<list name="Commands" type="list">
<item>
<string name="Name" value="Multiple"/>
<string name="Key" value="Ctrl+T"/>
</item>
</list>
</item>
<item>
<string name="Name" value="Zoom"/>
<string name="Key" value="Shift+H"/>
</item>
<item>
<string name="Name" value="Zoom Out"/>
<string name="Key" value="Shift-G"/>
</item>
</list>
</item>
</list>
</member>
</UserPreset>


What Does that XML demo PhrasePicker macro actually do?
#14
Don't remember, it is not my code or was not my idea.
Possibly you can find here easier examples. Search for IXml.
#15
It's a dialog that allows you to assign often used stock or custom phrases to tab after tab of buttons in the multipage dialog, that are then available for pasting into documents. The small button on each page of the dialog allow you to rename the buttons (i.e. to help you remember what phrase it brings up (displayed in the large text box).
This was kind of a simplified version for the purposes of the forum. I have customized it a lot since then but the xml part works awesomely (THanks Gintaras!!!) for storing the phrases as well as the button titles.

By the way, In this version, it puts your choices on the clipboard.

Enjoy,
Stuart


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

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 476 182 "MultiTabPhraseFillerMacro"
;1 Button 0x54030001 0x4 328 136 48 14 "OK"
;2 Button 0x54030000 0x4 386 136 48 14 "Cancel"
;4 Edit 0x54231044 0x200 272 16 202 112 ""
;6 Button 0x54012000 0x0 340 156 78 16 "Update Macro Text?"
;101 Button 0x54032000 0x0 6 18 117 14 ""
;102 Button 0x54032000 0x0 6 32 117 14 ""
;103 Button 0x54032300 0x0 6 46 117 14 ""
;104 Button 0x54032300 0x0 6 60 117 14 ""
;105 Button 0x54032000 0x0 6 74 117 14 ""
;106 Button 0x54032000 0x0 138 18 117 14 ""
;107 Button 0x54032000 0x0 138 32 117 14 ""
;108 Button 0x54032000 0x0 138 46 117 14 ""
;109 Button 0x54032000 0x0 138 60 117 14 ""
;110 Button 0x54032000 0x0 138 74 117 14 ""
;111 Button 0x54032000 0x0 6 100 117 14 ""
;112 Button 0x54032000 0x0 6 114 117 14 ""
;113 Button 0x54032000 0x0 6 128 117 14 ""
;114 Button 0x54032000 0x0 6 142 117 14 ""
;115 Button 0x54032000 0x0 6 156 117 14 ""
;116 Button 0x54032000 0x0 138 100 117 14 ""
;117 Button 0x54032000 0x0 138 114 117 14 ""
;118 Button 0x54032000 0x0 138 128 117 14 ""
;119 Button 0x54032000 0x0 138 142 117 14 ""
;120 Button 0x54032000 0x0 138 156 117 14 ""
;121 Button 0x54032000 0x0 123 18 10 14 ".."
;122 Button 0x54032000 0x0 123 32 10 14 ".."
;123 Button 0x54032000 0x0 123 46 10 14 ".."
;124 Button 0x54032000 0x0 123 60 10 14 ".."
;125 Button 0x54032000 0x0 123 74 10 14 ".."
;126 Button 0x54032000 0x0 255 18 10 14 ".."
;127 Button 0x54032000 0x0 255 32 10 14 ".."
;128 Button 0x54032000 0x0 255 46 10 14 ".."
;129 Button 0x54032000 0x0 255 60 10 14 ".."
;130 Button 0x54032000 0x0 255 74 10 14 ".."
;131 Button 0x54032000 0x0 123 100 10 14 ".."
;132 Button 0x54032000 0x0 123 114 10 14 ".."
;133 Button 0x54032000 0x0 123 128 10 14 ".."
;134 Button 0x54032000 0x0 123 142 10 14 ".."
;135 Button 0x54032000 0x0 123 156 10 14 ".."
;136 Button 0x54032000 0x0 255 100 10 14 ".."
;137 Button 0x54032000 0x0 255 114 10 14 ".."
;138 Button 0x54032000 0x0 255 128 10 14 ".."
;139 Button 0x54032000 0x0 255 142 10 14 ".."
;140 Button 0x54032000 0x0 255 156 10 14 ".."
;5 Static 0x54000010 0x20004 6 430 389 1 ""
;3 SysTabControl32 0x54000040 0x0 2 0 492 182 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "0" ""

class CToolTip m_htt ;;delete this if already declared in init2

str controls = "4"
str e4

str-- tag ;;was MacroID

;load xml file
str-- xmlfile="$desktop$\SampleMacros.xml"
if(!dir(xmlfile)) _s="<SampleMacros></SampleMacros>"; _s.setfile(xmlfile) ;;first time, create new file with no data
IXml-- xml
xml=CreateXml
xml.FromFile(xmlfile)
IXmlNode-- xr=xml.RootElement ;;this will be often used
IXmlNode ne

if(!ShowDialog("MultiTabPhraseFillerMacro" &MultiTabPhraseFillerMacro &controls)) ret

e4.setclip
act win("Microsoft Word" "OpusApp")
'Ai;;menu for inserting comments into Word Doc
'm;;brings up a new comment dialog in Word
0.5
outp e4
ret
;messages
CToolTip-- tt ;;CToolTip variables usually can be declared with thread scope (- or --). If thread can have multiple instances of the same dialog, use window scope (SetProp/GetProp). Don't use global and local.
sel message
,case WM_INITDIALOG
,;tab control
,int i t htb=id(3 hDlg)
,TCITEM ti.mask=TCIF_TEXT
,str st="A[]B[]C[]D[]E[]F[]G[]H[]I[]J[]K[]L"
,foreach(ti.pszText st) SendMessage htb TCM_INSERTITEMA i &ti; i+1
,
,;tooltips
,tt.Create(hDlg)
,tt.AddTool(hDlg 4 "Text changes apply only for this comment insertion. To permanently change text, Choose Update Macro Text")
,for(i 121 141) tt.AddTool(hDlg i "Click to Change Button Text")
,
,t=0; goto g11 ;;select first tab
,case WM_DESTROY
,,tt.Destroy
,case WM_SETCURSOR
,,tt.OnWmSetcursor(wParam lParam)
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case 6
,,if(!tag.len) ret
,,str NewMacroText
,,NewMacroText.getwintext(id(4 hDlg))
,,if(mes("Are you sure you want to permanently change macro text[](i.e. changes will also apply to future sessions)?" "Macro Text Change Confirmation" "OC?")!='O') ret
,,xr.SetChild(tag NewMacroText)
,,xml.ToFile(xmlfile)
,case else
,if(wParam>=101 and wParam<=140)
,,t=SendMessage(id(3 hDlg) TCM_GETCURSEL 0 0) ;;tab
,,
,,if(wParam>=101 and wParam<=120) ;;big button
,,,i=wParam-100
,,,tag.from("e" t*100+i)
,,,_s=xr.Child(tag).Value; err
,,,_s.setwintext(id(4 hDlg))
,,else ;;small [...] button
,,,wParam-20
,,,i=wParam-100
,,,tag.from("e" t*100+i)
,,,str OldButtonText NewButtonText ChangeText
,,,OldButtonText.getwintext(id(wParam hDlg))
,,,ChangeText.format("Change button text from ''%s'' to:" OldButtonText)
,,,if(!inp(NewButtonText ChangeText "Change Button Text" "Enter new button title here.....")) ret
,,,ne=xr.Child(tag); if(!ne) ne=xr.Add(tag)
,,,ne.SetAttribute("b" NewButtonText)
,,,xml.ToFile(xmlfile)
,,,NewButtonText.setwintext(id(wParam hDlg))
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case TCN_SELCHANGE
,t=SendMessage(nh.hwndFrom TCM_GETCURSEL 0 0)
,;g11
,;set text of buttons in this tab
,for i 1 21
,,NewButtonText=xr.Child(_s.from("e" t*100+i)).AttributeValue("b"); err NewButtonText=""
,,NewButtonText.setwintext(id(i+100 hDlg))
,;click first button to update tag and the textbox
,but 101 hDlg


Forum Jump:


Users browsing this thread: 1 Guest(s)