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
 
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: Tue Oct 16, 2007 8:16 am    Post subject: Reply with quote

It would be good to post sample.

Quote:
There is also another error when you try to load a standalone .ico
That error message is probably system one, i never tried to load ico myself, nor I like this dialog. I just made it for compliteness.
_________________
Back to top
View user's profile Send private message MSN Messenger
tic



Joined: 22 Apr 2007
Posts: 1271

PostPosted: Tue Oct 16, 2007 10:27 am    Post subject: Reply with quote

yeh it definitely is a system message, but was wondering why it appeared and how to get rid of it. to try it out, install Amun and then in the options part then choose an icon (not 1 within exe, dll etc)

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



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Tue Oct 16, 2007 12:12 pm    Post subject: Reply with quote

I tried this and it works here without errors:

Code:
 icon="c:\Art\Icons\icons\editcopy.ico"
 if CmnDlg_ChooseIcon(icon, idx := 4)
       msgbox Icon:   %icon%`nIndex:  %idx%


I checked out in Amon and saw what is going on. This is, however, behavior of the system and can not be changed.

There are many reasons not to like this system dialog. Thats why I created ChooseIconEx.
_________________
Back to top
View user's profile Send private message MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Thu Nov 22, 2007 10:39 am    Post subject: Reply with quote

Version 3.0
Added Find & Replace standard dialogs



Code:
;----------------------------------------------------------------------------------------------
; Function:     Find / Replace
;               Display standard Find and Replace dialog boxes
;
; Parameters:
;               hGui    - Handle to parents HWND
;               lbl     - Label used for communication with dialog. CmnDlg_Event, CmnDlg_FindWhat and CmnDlg_Flags hold the dialog data
;               flags   - Creation flags
;               deff    - Default text to be displayed at the start of the dialog box in find edit box
;               defr    - Default text to be displayed at the start of the dialog box in replace edit box
;
; Flags:        String containing list of creation flags. You can use "-" infronto of the flag to hide that GUI field
;               d - down radio button selected in Find dialog
;               w - whole word selected
;               c - match case selected
;
; Globals:      Dialog box is not modal, so it communicates with the script using 4 global variables:
;                   Event    - close, find, replace, replace_all
;                   Flags    - string contaning flags about user selection; each letter means user has selected that particular GUI element.
;                   FindWhat - user find text
;                ReplaceWith - user replace text
;   
; Returns:     
;               Handle of the dialog or 0 if dialog can't be created. Can also return "Invalid Label" if lbl is not valid.
;
CmnDlg_Find( hGui, lbl, flags="d", deff="")
CmnDlg_Replace( hGui, lbl, flags="", deff="", defr="")
 

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



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

PostPosted: Thu Nov 22, 2007 2:58 pm    Post subject: Reply with quote

I just started to play with the Find function and I ran into a problem. The Find dialog closes correctly when I click on the Cancel button but the dialog remains open when I click on the Find button. What do I need to do to get the Find dialog to close after I click on the Find button?

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



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Thu Nov 22, 2007 4:29 pm    Post subject: Reply with quote

Thats by design. Find and Replace dialogs are not modal, they stay open so user can press Find Next button again. There is also "close" event which notifies you the dialog is closed so you can free the data that u eventualy allocated for searhing.

You can manualy close the dialog whenever you want. The function returns handle of the dialog so code

Code:
#persistent
 Gui, +lastfound
 hDlg := CmnDlg_Find( WinExist(), "OnFind")
return

OnFind:
     Msgbox % CmnDlg_FindWhat
     WinClose, ahk_id %hDlg%
return


will close the dialog after user pressed find.
_________________
Back to top
View user's profile Send private message MSN Messenger
jballi



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

PostPosted: Sat Nov 24, 2007 2:06 am    Post subject: Reply with quote

majkinetor wrote:
Thats by design. Find and Replace dialogs are not modal, they stay open so user can press Find Next button again. There is also "close" event which notifies you the dialog is closed so you can free the data that u eventualy allocated for searhing.

Thanks for the feedback. I'll give it try.
Back to top
View user's profile Send private message
jballi



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

PostPosted: Sat Nov 24, 2007 6:18 am    Post subject: Reply with quote

I just started to test the Find dialog and I ran into a problem. The "-w" flag doesn't do anything. In fact, if the "-w" flag is defined, all other flags are ignored. I did a quick test on Replace dialog and the "-w" flag appears to work correctly.

Let me know if you need any additional information.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Sat Nov 24, 2007 11:38 am    Post subject: Reply with quote

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



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Wed Dec 05, 2007 3:20 pm    Post subject: Reply with quote

v4.0
Added Open/Save dialog.
MHT doc tonight.

Code:
;----------------------------------------------------------------------------------------------
; Function:  Open / Save
;            Display standard Open / Save dialog
;
; Parameters:
;            hGui            - Parent's handle, positive number by default 0 (influences dialog position)
;            Title          - Dialog title
;            Filter          - Specify filter as with FileSelectFile. Seperate multiple filters with "|"
;            DefultFilter    - Index of default filter, by default 1
;            Root          - Specifies startup directory and initial content of "File Name" edit.
;                        Directory must have trailing "\".
;            DefaulltExt     - Extension to append when none given
;            Flags           - White space separated list of flags, by default "FILEMUSTEXIST HIDEREADONLY ENABLEXPLORER"

;  Flags:
;         ALLOWMULTISELECT   - Specifies that the File Name list box allows multiple selections ...
;         CREATEPROMPT      - If the user specifies a file that does not exist, this flag caus ...
;         DONTADDTORECENT      - Prevents the system from adding a link to the selected file in t ...
;         EXTENSIONDIFFERENT   - Specifies that the user typed a file name extension that differs ...
;         FILEMUSTEXIST      - Specifies that the user can type only names of existing files in ...
;         FORCESHOWHIDDEN      - Forces the showing of system and hidden files, thus overriding t ...
;         HIDEREADONLY      - Hides the Read Only check box.                           ...
;         NOCHANGEDIR         - Restores the current directory to its original value if the user ...
;         NODEREFERENCELINKS   - Directs the dialog box to return the path and file name of the s ...
;         NOVALIDATE         - Specifies that the common dialog boxes allow invalid characters  ...
;         OVERWRITEPROMPT      - Causes the Save As dialog box to generate a message box if the s ...
;         PATHMUSTEXIST      - Specifies that the user can type only valid paths and file names ...
;         READONLY         - Causes the Read Only check box to be selected initially when the ...
;         SHOWHELP         - Causes the dialog box to display the Help button. The hGui recei ...
;         NOREADONLYRETURN   - Specifies that the returned file does not have the Read Only che ...
;         NOTESTFILECREATE   - Specifies that the file is not created before the dialog box is  ...
;
;  Returns:
;            Selected FileName or Emtpy when cancelled. If more then one file is selected they are separated by new line character.
;
;  Example:
;         CmnDlg_Open(0, "", "Text Files (*.txt)", "", "c:\Windows\setuplog", ".ahk")
;      


Big thanks to DerRaphael for initial code which I rewrote to fit the CmnDlg philosophy.

Among other things this dialog implements, notice that if you set correctly hGui, it will not pop up on 0,0 like FileSelectFile does, always (unless you do SetTimer mumbo jumbo)
_________________
Back to top
View user's profile Send private message MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Wed Dec 05, 2007 5:31 pm    Post subject: Reply with quote

MHT doc updated
_________________
Back to top
View user's profile Send private message MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Fri Jan 18, 2008 12:32 am    Post subject: Reply with quote

v4.01
Bug fix in Open/Save dialog
First page updated - docs online, direct download to script.
Dialog names are changed.
Back to top
View user's profile Send private message MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Fri Jan 18, 2008 6:56 pm    Post subject: Reply with quote

v4.03
Bug fix in Open dialog.
Back to top
View user's profile Send private message MSN Messenger
tic



Joined: 22 Apr 2007
Posts: 1271

PostPosted: Sun Jan 27, 2008 8:30 pm    Post subject: Reply with quote

your icon module doesnt give the correct idx. it always gives 1

this works fine for me:

Code:
CmnDlg_Icon(ByRef sIcon, ByRef idx, hGui=0)
{                             
   VarSetCapacity(wIcon, 1025, 0)
   If !DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "Str", sIcon, "Int", StrLen(sIcon), "UInt", &wIcon, "Int", 1025)
   Return, 0
      
   idx--
   If !DllCall(DllCall("GetProcAddress", "Uint", DllCall("LoadLibrary", "Str", "shell32.dll"), "Uint", 62), "UInt", hGui, "UInt", &wIcon, "UInt", 1025, "Intp", idx)
   Return, 0
   idx++

   Len := DllCall("lstrlenW", "UInt", &wIcon)
   VarSetCapacity(sIcon, Len, 0)
   Return, DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", &wIcon, "Int", Len, "Str", sIcon, "Int", Len, "UInt", 0, "UInt", 0) ? 1 : 0
}
Back to top
View user's profile Send private message
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
Page 6 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