AutoHotkey Community

It is currently May 27th, 2012, 11:16 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 166 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12  Next
Author Message
 Post subject:
PostPosted: April 15th, 2011, 9:46 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Lexikos wrote:
Just FYI, the first two examples can be done with format(), the prototype formatting function I've included with the v2 alpha download. (It will be built in eventually.)


Glad to know it.. Thanks :)

Quote:
It's not quite as flexible as StrSet (for padding)


I get 20 spaces with StrSet( A_Space, 20 ) or Replicate( A_Space, 20 )

Will the following produce the same result or will it be trimmed to null?
Code:
MsgBox, % format("[{1:-20s}]", " ")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2011, 12:55 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
It produces the following:
Code:
[                    ]

This produces the same result:
Code:
MsgBox, % format("[{1:20s}]", "")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2011, 6:25 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Nice.. Thanks! :)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 9th, 2011, 9:33 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Quote:
GuiDefaultFont()
AutoHotkey uses the 'default GUI font' for controls, if you do not specify one in your script.
This 'default GUI font' is system wide and the same one being used in MenuBar.
GuiDefaultFont() returns the Fontname & Fontsize.


Code:
GuiDefaultFont() {        ; By SKAN www.autohotkey.com/forum/viewtopic.php?p=465438#465438
 hFont := DllCall( "GetStockObject", UInt,17 ) ; DEFAULT_GUI_FONT
 VarSetCapacity( LF, szLF := 60*( A_IsUnicode ? 2:1 ) )
 DllCall("GetObject", UInt,hFont, Int,szLF, UInt,&LF )
 hDC := DllCall( "GetDC", UInt,hwnd ), DPI := DllCall( "GetDeviceCaps", UInt,hDC, Int,90 )
 DllCall( "ReleaseDC", Int,0, UInt,hDC ), S := Round( ( -NumGet( LF,0,"Int" )*72 ) / DPI )
Return DllCall( "MulDiv",Int,&LF+28, Int,1,Int,1, Str ), DllCall( "SetLastError", UInt,S )
}

A_GuiFont     := GuiDefaultFont()
A_GuiFontSize := A_LastError

MsgBox, %A_GuiFont%`t%A_GuiFontSize%





Quote:
Control_GetFont()
Given an handle to a GuiControl, Control_GetFont() will return the Fontname & Fontsize.


Code:
Control_GetFont( hwnd ) { ; www.autohotkey.com/forum/viewtopic.php?p=465438#465438 By SKAN
 SendMessage 0x31, 0, 0, , ahk_id %hwnd% ; WM_GETFONT                 Created: 27-Apr-2011
 IfEqual,ErrorLevel,FAIL, Return
 hFont := Errorlevel, VarSetCapacity( LF, szLF := 60*( A_IsUnicode ? 2:1 ) )
 DllCall("GetObject", UInt,hFont, Int,szLF, UInt,&LF )
 hDC := DllCall( "GetDC", UInt,hwnd ), DPI := DllCall( "GetDeviceCaps", UInt,hDC, Int,90 )
 DllCall( "ReleaseDC", Int,0, UInt,hDC ), S := Round( ( -NumGet( LF,0,"Int" )*72 ) / DPI )
Return DllCall( "MulDiv",Int,&LF+28, Int,1,Int,1, Str ), DllCall( "SetLastError", UInt,S )
}




_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2011, 9:56 pm 
SKAN: Could you create an index post in the first post? I always have great trouble locating a specific post in your threads, an index would help a lot. (and you keep changing the title)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2011, 10:10 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Anonymous wrote:
SKAN: Could you create an index post in the first post?


I was thinking of splitting-out the important ones into separate topics,
but yes, an index would not hinder any future split.
I will post an index in a couple of days.

Quote:
I always have great trouble locating a specific post in your threads


:oops:

Quote:
and you keep changing the title


I change it before I post a new one, so it reflects in email notifications ( for those watching the topic )
BTW, all functions have the "post subject:" filled. One could always search for titles.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 10th, 2011, 1:42 pm 
SKAN wrote:
All functions have the "post subject:" filled. One could always search for titles.

Good tip, thanks. And thanks in advance for your index post 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2011, 12:58 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Update: AccuSleep() was not AHK_Lw compatible, now rectified.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2012, 12:46 pm 
Thanks a lot for the LDOM function, but I have an error (using value of uninitialized variable) when I run following code:
Code:
LDOM(TimeStr="") {
  If TimeStr=
     TimeStr = %A_Now%
  StringLeft Date,TimeStr,6 ; YearMonth
  Date1 = %Date%
  Date1+= 31,D              ; A day in next month
  StringLeft Date1,Date1,6  ; YearNextmonth
  Date1-= %Date%,D          ; Difference in days
  Return Date1
}

   FormatTime, ActualMonth,, yyyyMM
   LastDay := LDOM(%ActualMonth%)


How can I deactivate this warning?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2012, 12:47 pm 
For info, the warning points on this line:
Code:
LastDay := LDOM(%ActualMonth%)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2012, 12:48 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Try removing the percent signs:

Code:
LastDay := LDOM(%ActualMonth%)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2012, 1:09 pm 
Thanks a lot, it works.

I don't understand why we should not put % here, but anyway, its perfect now :)


Report this post
Top
  
Reply with quote  
PostPosted: May 9th, 2012, 3:45 pm 
SKAN: Could you do one more step: Receiving the Font Style (and Font Color if possible) in Function Control_GetFont(). Thanks.


Report this post
Top
  
Reply with quote  
PostPosted: May 9th, 2012, 4:33 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Guest wrote:
SKAN: Could you do one more step: Receiving the Font Style


What do you mean by Font Style? Like Italic, underline etc.?
Please take a look at the Logfont structure:
Code:
typedef struct tagLOGFONT {
  LONG  lfHeight;
  LONG  lfWidth;
  LONG  lfEscapement;
  LONG  lfOrientation;
  LONG  lfWeight;
  BYTE  lfItalic;
  BYTE  lfUnderline;
  BYTE  lfStrikeOut;
  BYTE  lfCharSet;
  BYTE  lfOutPrecision;
  BYTE  lfClipPrecision;
  BYTE  lfQuality;
  BYTE  lfPitchAndFamily;
  TCHAR lfFaceName[LF_FACESIZE];
} LOGFONT, *PLOGFONT;


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 9th, 2012, 5:28 pm 
Offline
User avatar

Joined: January 9th, 2010, 5:56 am
Posts: 101
Location: a corner in the world
yes, i'm new to DllCall and Struct :oops: .
Thanks for your tips, i made a small change and luckily ,it worked :D
Code:
Control_GetFont( hwnd ,ByRef Name,ByRef Style,ByRef Size) { ; www.autohotkey.com/forum/viewtopic.php?p=465438#465438 
; Mod by nothing
 SendMessage 0x31, 0, 0, , ahk_id %hwnd% ; WM_GETFONT                 
 IfEqual,ErrorLevel,FAIL, Return
 hFont := Errorlevel, VarSetCapacity( LF, szLF := 60*( A_IsUnicode ? 2:1 ) ), DllCall("GetObject", UInt,hFont, Int,szLF, UInt,&LF ) , hDC := DllCall( "GetDC", UInt,hwnd ), DPI := DllCall( "GetDeviceCaps", UInt,hDC, Int,90 ) , DllCall( "ReleaseDC", Int,0, UInt,hDC )
 Name := DllCall( "MulDiv",Int,&LF+28, Int,1,Int,1, Str )
 Style := Trim(((W:=NumGet(LF,16,"Int"))=700 ? " Bold" : W=400 ? "" : " w" W ) . (NumGet(LF,20,"UChar") ? " Italic" : "") . (NumGet(LF,21,"UChar") ? " Underline" : "") . (NumGet(LF,22,"UChar") ? " StrikeOut" : ""))
 Size := Round( ( -NumGet( LF,0,"Int" )*72 ) / DPI )
}

TYVM.

_________________
nothing is impossible with ahk (_L).
Excuse my bad English.
Now, focus on X-GUI Creator - an easy,simple,fast way to design GUI.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 166 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: nomissenrojb, Rajat and 58 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