AutoHotkey Community

It is currently May 25th, 2012, 2:29 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 157 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 11  Next
Author Message
 Post subject:
PostPosted: April 22nd, 2007, 1:26 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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 :D

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 ?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2007, 10:14 pm 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 772
Location: Texas, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2007, 10:26 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2007, 9:09 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2007, 11:21 pm 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 772
Location: Texas, USA
majkinetor wrote:
The function is fixed.

I gave it a quick try/see. The function appears to work. Thanks for your help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2007, 1:04 pm 
Offline

Joined: January 18th, 2006, 7:39 am
Posts: 274
Location: Conway, Arkansas
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2007, 1:09 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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 8)

Thx.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2007, 1:46 pm 
Offline

Joined: January 18th, 2006, 7:39 am
Posts: 274
Location: Conway, Arkansas
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2007, 2:06 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
They're very handy, indeed.

Ofc they are handy.
Those are common dialogs :D

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 ?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2007, 1:45 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 772
Location: Texas, USA
v1.2.1

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

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2007, 9:11 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
v1.22
- ChooseIcon now returns 1-based index (previously was 0 based)
- Fix: ChoseFont didn't return false on Cancel

Thx

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2007, 4:29 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 772
Location: Texas, USA
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2007, 8:32 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2007, 3:16 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 772
Location: Texas, USA
v1.2.2

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

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2007, 12:13 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Fixed, thx.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 157 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 11  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], lblb and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group