AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[module] CmnDlg 4.03 - Common Dialogs
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Sun Apr 22, 2007 1:26 pm    Post subject: Reply with quote

Quote:
I'm only making a fuss about this function because I'm hoping to use it in the future.

OFC, thats why I am provided it here, so ppl can use it in the future Very Happy

Quote:
One additional idiosyncrasy. The color value returned is sometimes correct but usually it's not.

I tested with all color values that are there. I was passing the color that was returned from the function itself (so if the return value was not correct, initial color would be different). There are only like 16 colors anyway so you can't pass in anything.

Can you gimme non-working example ?
_________________
Back to top
View user's profile Send private message MSN Messenger
jballi



Joined: 01 Oct 2005
Posts: 297
Location: Texas, USA

PostPosted: Sun Apr 22, 2007 10:14 pm    Post subject: Reply with quote

majkinetor wrote:
I tested with all color values that are there. I was passing the color that was returned from the function itself (so if the return value was not correct, initial color would be different). There are only like 16 colors anyway so you can't pass in anything.

For AHK, color is just another font option (attribute) like bold, underline, etc. Using the ChooseFont parameters as an example, the font and font options would be set as follows:

Code:
gui font, %pStyle% c%pColor%, %pFont%

The problem is that the value returned from the function is sometimes not interpreted by AHK as the color selected.


majkinetor wrote:
Can you gimme non-working example ?

If you select Blue, the function returns 0xff0000 which is interpreted by AHK (correctly I would say) as Red. It's important to point out that if you pass 0xff0000, the function interprets the value as Blue.

Thanks for your help.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Sun Apr 22, 2007 10:26 pm    Post subject: Reply with quote

Ah, I see.

I will try to fix this.
I didn't notice this as I use ChooseColor to set the font color in HexView.

Thx.
_________________
Back to top
View user's profile Send private message MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Mon Apr 23, 2007 9:09 am    Post subject: Reply with quote

The function is fixed. Test it with:

Code:
   ChooseFont( font := "Courier New", style := "s16 bold underline italic", color:=0xFF)

   Gui Font, %Style% c%Color%, %Font%
   Gui, Add, Text, ,hej jballi
   Gui, Show, Autosize
return


If you have further problems let me know. I want to make those functions 100% reliable and in AHK spirit as they are commonly used.
_________________
Back to top
View user's profile Send private message MSN Messenger
jballi



Joined: 01 Oct 2005
Posts: 297
Location: Texas, USA

PostPosted: Mon Apr 23, 2007 11:21 pm    Post subject: Reply with quote

majkinetor wrote:
The function is fixed.

I gave it a quick try/see. The function appears to work. Thanks for your help.
Back to top
View user's profile Send private message
skwire



Joined: 18 Jan 2006
Posts: 129
Location: Conway, Arkansas

PostPosted: Tue Apr 24, 2007 1:04 pm    Post subject: Reply with quote

Maybe I'm not understanding something about the ChooseIcon dialog but in my tests the index number (idx) always seemed to be off by one. I fixed it by adding the following two lines in red (feel free to suggest a more elegant solution):

Code:
ChooseIcon(ByRef sIcon, ByRef idx, hGui=0) {                               
    idx -= 1
    VarSetCapacity(wIcon, 1025, 0)
    if sIcon !=
    {
        r := DllCall("MultiByteToWideChar"
             , "UInt", 0             ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
             , "UInt", 0             ; dwFlags
             , "Str", sIcon          ; LPSTR lpMultiByteStr
             , "Int", StrLen(sIcon)  ; cbMultiByte: -1=null terminated
             , "UInt", &wIcon        ; LPCWSTR lpWideCharStr
             , "Int", 1025)          ; cchWideChar: 0 to get required size

        if !r
            return false
    }
   
;   r := DllCall("shell32.dll\PickIconDlg", "uint", hGui, "uint", &wIcon, "uint", 1025, "intp", idx)
   r := DllCall(DllCall("GetProcAddress", "Uint", DllCall("LoadLibrary", "str", "shell32.dll"), "Uint", 62), "uint", hGui, "uint", &wIcon, "uint", 1025, "intp", idx) ;Markus fix for Win2000
   if !r
        return false

   len := DllCall("lstrlenW", "UInt", &wIcon)
   VarSetCapacity(sIcon, len, 0)
   r := DllCall("WideCharToMultiByte"
         , "UInt", 0           ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
         , "UInt", 0           ; dwFlags
         , "UInt", &wIcon      ; LPCWSTR lpWideCharStr
         , "Int", len          ; cchWideChar: size in WCHAR values, -1=null terminated
         , "Str", sIcon        ; LPSTR lpMultiByteStr
         , "Int", len          ; cbMultiByte: 0 to get required size
         , "UInt", 0           ; LPCSTR lpDefaultChar
         , "UInt", 0)          ; LPBOOL lpUsedDefaultChar

    if !r
        return false
    idx += 1
    return true
}
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Tue Apr 24, 2007 1:09 pm    Post subject: Reply with quote

Yup, thx for reminding me about this.

Your fix is good enough, I will add it to the function. There is no "more elegant solution" as this is the difference between counting reference - in C it is usualy 0 while in AHK it is usualy 1.

Ofc, you can say that it is more elegant to write i++ and i-- in the function calls Cool

Thx.
_________________
Back to top
View user's profile Send private message MSN Messenger
skwire



Joined: 18 Jan 2006
Posts: 129
Location: Conway, Arkansas

PostPosted: Tue Apr 24, 2007 1:46 pm    Post subject: Reply with quote

Quote:
Ofc, you can say that it is more elegant to write i++ and i-- in the function calls


A means to an end. =]

Quote:
Thx.


You're welcome and thank you for the functions/wrappers. They're very handy, indeed.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Tue Apr 24, 2007 2:06 pm    Post subject: Reply with quote

Quote:
They're very handy, indeed.

Ofc they are handy.
Those are common dialogs Very Happy

Anyway, can anybody explain how to achieve equivalent "hGui" feature with FileOpenFile dialog. Becouse of hGui parameter in ChooseXXX functions, the dialog window is aligned properly to the caller window. If you omit this param, it will be shown at 0,0 coordinate. There is no such option with FileOpenFile/Dir and it is always shown at 0,0. You can't even automate window as script is stoped while dialog is active.

Is there anything I should know that I missed ?
_________________
Back to top
View user's profile Send private message MSN Messenger
jballi



Joined: 01 Oct 2005
Posts: 297
Location: Texas, USA

PostPosted: Wed Apr 25, 2007 1:45 am    Post subject: Reply with quote

v1.2.1

Minor bug. ChooseFont function is no longer returning false on Cancel. Was working correctly in v1.2.

Thanks.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Wed Apr 25, 2007 9:11 am    Post subject: Reply with quote

v1.22
- ChooseIcon now returns 1-based index (previously was 0 based)
- Fix: ChoseFont didn't return false on Cancel

Thx
_________________
Back to top
View user's profile Send private message MSN Messenger
jballi



Joined: 01 Oct 2005
Posts: 297
Location: Texas, USA

PostPosted: Thu Apr 26, 2007 4:29 am    Post subject: Reply with quote

I've been playing around with the ChooseFont function for a while and I have a couple of recommendations:
  • From an AHK perspective, color is just another font option so there is no reason to use a separate parameter for it since you have to put it back together with the other options in order to use it.

  • An optional Effects parameter would be beneficial when using the function to select a font without the sometimes extraneous Effects options (strikeout, underline, and color). If set to TRUE (the default), the dialog would be displayed as it does now (CF_EFFECTS = 0x100). If set to FALSE, the dialog would display without the Effects group of options (CF_EFFECTS = 0x000).

Them be my thoughts...
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Thu Apr 26, 2007 8:32 am    Post subject: Reply with quote

Hello jballi.

Quote:
From an AHK perspective, color is just another font option

I was thinking about this too. At first, I thought to put the color in pStyle also, but then, I realised that users will probably mostly want to do normal font change, without the color, so I isolated this param so returned pStyle doesn't have to be parsed by users to remove unwanted color.

It might not be bad idea to try to parse color from pStyle if pColor parameter is empty, and add new color to the style also. This way we can have both worlds.

Quote:
An optional Effects parameter

OK

Thx for ideas.
_________________
Back to top
View user's profile Send private message MSN Messenger
jballi



Joined: 01 Oct 2005
Posts: 297
Location: Texas, USA

PostPosted: Sun Apr 29, 2007 3:16 am    Post subject: Reply with quote

v1.2.2

Minor bug. The ChooseColor function modifies the value of the pColor parameter even if the Cancel button is clicked.

Thanks.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Sun Apr 29, 2007 12:13 pm    Post subject: Reply with quote

Fixed, thx.
_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 4 of 6

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group