 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Mon Mar 05, 2007 2:16 pm Post subject: [module] CmnDlg 4.1 - Common Dialogs |
|
|
| Code: | #Singleinstance, force
#NoEnv
Gui, +LastFound
hGui := WinExist()
Gui, Add, Button, w100 y+10 gOnBtn ,Icon
Gui, Add, Button, w100 y+10 gOnBtn ,Color
Gui, Add, Button, w100 y+10 gOnBtn ,Font
Gui, Add, Button, w100 y+10 gOnBtn ,Open
Gui, Add, Button, w100 y+10 gOnBtn ,Save
Gui, Add, Button, w100 y+10 gOnBtn ,Find
Gui, Add, Button, w100 y+10 gOnBtn ,Replace
Gui, Add, Edit, ym+5 w300 h220,Input / Output
Gui, Show, autosize
return
Set(txt){
ControlSetText, Edit1, %txt%
}
OnBtn:
if A_GuiControl = Icon
if CmnDlg_Icon(icon, idx, hGui)
Set("Path: " icon "`r`nIndex: " idx)
if A_GuiControl = Color
if CmnDlg_Color( color, hGui )
Set("Color: " color)
if A_GuiControl = Font
if CmnDlg_Font( font, style, color, true, hGui)
Set("Font: " font "`r`nStyle: " style "`r`nColor: " color)
if A_GuiControl = Open
{
res := CmnDlg_Open(hGui, "Select several files", "All Files (*.*)|Audio (*.wav; *.mp2; *.mp3)|Documents (*.txt)", "", "d:\", "", "ALLOWMULTISELECT FILEMUSTEXIST HIDEREADONLY")
StringReplace, res, res, `n, `r`n, A
Set(res)
}
if A_GuiControl = Save
Set(CmnDlg_Save(hGui, "Select several files", "All Files (*.*)|Audio (*.wav; *.mp2; *.mp3)|Documents (*.txt)", "", "c:\"))
if A_GuiControl = Find
CmnDlg_Find(hGui, "OnFind", "d")
if A_GuiControl = Replace
CmnDlg_Replace(hGui, "OnFind", "d")
return
OnFind(Event, Flags, FindWhat, ReplaceWith){
Set("Event: " event "`r`nFlags: " flags "`r`nFindWhat: " FindWhat (ReplaceWith != "" ? "`r`nReplaceWith: " ReplaceWith : "") )
}
#include CmnDlg.ahk |
_________________

Last edited by majkinetor on Wed Jul 02, 2008 11:07 am; edited 65 times in total |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Mon Mar 05, 2007 2:21 pm Post subject: |
|
|
One strange thing happening. If you check the code you will see lines:
| Code: | VarSetCapacity(i, 4, 0)
InsertInteger(idx, i, 0)
r := DllCall("shell32.dll\PickIconDlg", "uint", hGui, "uint", &wIcon, "uint", size, "int", &i) |
if I do this without VarSetCapacity and InsertInteger it will not work, the windows will receive ascii codes. Like, if you set idx := 1 31st icon will be selected as ASCII(1) = 31.
Now, this is strange, I expect dll call to handle this as I specify "uint" as an parameter. _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1337
|
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Mon Mar 05, 2007 3:02 pm Post subject: |
|
|
ah... my mistake.. i somehow confused uint with intp
Hmm.. something is wrong with the function. Suddenly it stoped returning new path upon selection.... The index is returned correctly but the path stays the same as on input for some reason, even if you change it. _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1337
|
Posted: Mon Mar 05, 2007 3:43 pm Post subject: |
|
|
| Looks like the script doesn't count the null terminator character at all. Then, lstrlen function might not function as expected. That could be a cause. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Mon Mar 05, 2007 3:46 pm Post subject: |
|
|
Argh I must get some sleep..
I changed the func, and left something that was there in my initial runs.. count of chars that i removed latter...
Btw, it counts null char, that is the reason for 1025 ~ Max_PATH*2 + 1
ok, just redownload _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1337
|
Posted: Mon Mar 05, 2007 4:09 pm Post subject: |
|
|
| I didn't mean the buffer length, 1025 + 1 is far more than enough mostly even with Unicode function, I suppose. I meant the parameter like StrLen() etc. To be safer, they should be like StrLen() + 1 etc IMO. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Mon Mar 05, 2007 4:30 pm Post subject: |
|
|
well, msdn explicitely states where it requires null char counted and where not. _________________
 |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Mon Mar 05, 2007 8:37 pm Post subject: |
|
|
I reordered things a little _________________
 |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Mon Mar 05, 2007 11:14 pm Post subject: |
|
|
Very cool!
Icon doesn't insert correctly into your example for me.
Wondering... Does anybody know what the exact system requirements are for these emerging COM/OLE scripts? Does it need NT or IE or anything? |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Mon Mar 05, 2007 11:54 pm Post subject: |
|
|
I tried this and it showed me folder icon
| Code: | s := "c:\windows\system32\shell32.dll"
idx := 4
ChooseIcon(s, idx) |
About COM, nothing special, just IE. _________________
 |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Mon Mar 05, 2007 11:57 pm Post subject: |
|
|
Ok, I see, your example does not add the actual selected icon, only the first.
I guess COM/OLE needs IE3, from reading a bit, and it should be available from Win95 on... Now I'm still wondering if all the COM scripts here actually would work on a Win95 system with IE3. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1337
|
Posted: Mon Mar 05, 2007 11:58 pm Post subject: |
|
|
| majkinetor wrote: | | Btw, it counts null char, that is the reason for 1025 ~ Max_PATH*2 + 1 |
Hmm, where did you get MAX_PATH is 512?
AFAIK, MAX_PATH is 260 = 3 + 256 + 1, and the last 1 is indeed for the terminating null (:the first 3 is for drive like C:\). |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1337
|
Posted: Tue Mar 06, 2007 12:02 am Post subject: |
|
|
| n-l-i-d wrote: | | I guess COM/OLE needs IE3, from reading a bit, and it should be available from Win95 on... Now I'm still wondering if all the COM scripts here actually would work on a Win95 system with IE3. |
I'm afraid that you're a bit confused. There is no COM here, comdlg32.dll is Common Dialog (:there is indeed a custom comdlg32.ocx which is used by VB). |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Tue Mar 06, 2007 9:38 am Post subject: |
|
|
well, max path is 260 TCHARS AFAIK. SO, in unicode terms it is double. Why I used double of double, don't ask... was very sleepy and crashed yesterday, I made bunch of trivial errors. I didn't use 260, but degree of 2 as it is the fastest to alocate buffers with such size. _________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|