Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[module] Dlg 5.01


  • Please log in to reply
37 replies to this topic
majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
OUTDATED. Dlg is now maintained via Formsframework.

Common Dialogs

Download          Documentation


Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
One strange thing happening. If you check the code you will see lines:

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.
Posted Image

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
This is normal. You only give the address of i, and i is stored as a string. Use a pointer instead: "intP", i like in
<!-- m -->http://www.autohotke...topic16755.html<!-- m -->

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
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.
Posted Image

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
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.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
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
Posted Image

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
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.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
well, msdn explicitely states where it requires null char counted and where not.
Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
I reordered things a little
Posted Image

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
Very cool! 8)

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?

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
I tried this and it showed me folder icon

s := "c:\windows\system32\shell32.dll"
idx := 4
ChooseIcon(s, idx)

About COM, nothing special, just IE.
Posted Image

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
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.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

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:\).

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

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).

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
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.
Posted Image