tengwer2 Posted March 13, 2012 Posted March 13, 2012 (edited) I am looking for a way to do with a script what I can do by changing the fonts of the message box, title bars,menus etc using the window color and appearance control panel. I would also like to get these values before I change them. I believe it can be done with _WinAPI_SystemParametersInfo and I have done the following so far and it is incomplete as I have scoured both this forum and msdn to figure out on my own how to do this using some code I found to do something similar. Could someone please complete or correct what I have here or point me to an example script. If someone could give me an example of changing the Active Titlebar font I can figure out the rest from there. Thanks for the help!Global Const $SPI_GETNONCLIENTMETRICS = 41Global Const $SPI_SETNONCLIENTMETRICS = 42Global Const $SPIF_SENDCHANGE = 2Global Const $SPIF_UPDATEINIFILE = 1Global Const $tagNONCLIENTMETRICS = "uint cbSize;int iBorderWidth;int iScrollWidth;int iScrollHeight;int iCaptionWidth;int iCaptionHeight;" & _ "byte lfCaptionFont[92];int iSmCaptionWidth;int iSmCaptionHeight;byte lfSmCaptionFont[92];int iMenuWidth;int iMenuHeight;" & _ "byte lfMenuFont[92];byte lfStatusFont[92];byte lfMessageFont[92]";int iPaddedBorderWidth"Global $nonclientmetrics = DllStructCreate($tagNONCLIENTMETRICS)DllStructSetData($nonclientmetrics, "cbSize", sizeof($nonclientmetrics))_WinAPI_SystemParametersInfo($SPI_SETNONCLIENTMETRICS, sizeof($nonclientmetrics), DllStructGetPtr($nonclientmetrics), 0)Func sizeof($struct) Return DllStructGetSize($struct)EndFunc ;==>sizeof Edited March 13, 2012 by tengwer2
tengwer2 Posted March 13, 2012 Author Posted March 13, 2012 I figured it out! For those interested here is a sample of code that will change fonts dynamically and give info. In this case it tells you the font height and name and then changes them for the titlebar, messagebox, statusbar, pallette, and menu. You can retrieve any other parts of the logfont info (font wieght, quality etc. ) by changing the element #." I also did the same thing for nonclientmetrics which allows you to see current settings such as border width and then change them on the fly. These are just rough samples of what can be done so try them out at your own risk. IF you do it is set to not save the changes to the system but to just broadcast the cahnges so a reboot should set things back the way they were. I did find that my scroll bars ended up a little off even after reboot and had to reset them manually. As I said this is just a start and needs refinement but the concept does work. font changing: expandcollapse popup$nonclientmetrics = DllStructCreate("uint cbSize;int iBorderWidth;int iScrollWidth;int iScrollHeight;int iCaptionWidth;int iCaptionHeight;" & _ "byte lfCaptionFont[60];int iSmCaptionWidth;int iSmCaptionHeight;byte lfSmCaptionFont[60];int iMenuWidth;int iMenuHeight;" & _ "byte lfMenuFont[60];byte lfStatusFont[60];byte lfMessageFont[60];int iPaddedBorderWidth") DLLStructSetData($nonclientmetrics,1,DllStructGetSize($nonclientmetrics)) Global Const $SPI_GETNONCLIENTMETRICS = 0x0029 Global Const $SPI_SETNONCLIENTMETRICS = 0x002A DLLCall("user32.dll","int","SystemParametersInfo","int",0x0029, _ "int",DllStructGetSize($nonclientmetrics), _ "ptr",DllStructGetPtr($nonclientmetrics),"int",0) ;active and inactive titlebar $logfont1 = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]",DLLStructGetPtr($nonclientmetrics,7)) ;pallette title (The Palette Title setting affects the title bar of floating palettes. _ ;Examples are: Paint's color box after dragging it away from the edge of the Paint window; Word 98's little help box $logfont2 = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]",DLLStructGetPtr($nonclientmetrics,10)) ;menu font $logfont3 = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]",DLLStructGetPtr($nonclientmetrics,13)) ;tool tip $logfont4 = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]",DLLStructGetPtr($nonclientmetrics,14)) ;message font $logfont5 = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]",DLLStructGetPtr($nonclientmetrics,15)) ;=============== GET FONT NAMES ================= MsgBox(4096,"","Titlebar Font is: " & DllStructGetData($logfont1,14) & @LF & _ ;numbers refer to each line of logfont structure (ie line 14 is typeface) "Pallette Title Font is: " & DllStructGetData($logfont2,14) & @LF & _ "Menu Font is: " & DllStructGetData($logfont3,14) & @LF & _ "Tool Tip and Status Font is: " & DllStructGetData($logfont4,14) & @LF & _ "MessageBox Font is: " & DllStructGetData($logfont5,14)) ;=============================================== ;=============== GET FONT HEIGHT ================= MsgBox(4096,"","Titlebar Font is: " & DllStructGetData($logfont1,1) & @LF & _ ;numbers refer to each line of logfont structure (ie line 14 is typeface) "Pallette Title Font is: " & DllStructGetData($logfont2,1) & @LF & _ "Menu Font is: " & DllStructGetData($logfont3,1) & @LF & _ "Tool Tip and Status Font is: " & DllStructGetData($logfont4,1) & @LF & _ "MessageBox Font is: " & DllStructGetData($logfont5,1)) ;=============================================== ;=============== SET FONT NAMES ================= DLLStructSetData($logfont1,14,"Segoe UI") DLLStructSetData($logfont2,14,"Segoe UI") DLLStructSetData($logfont3,14,"Segoe UI") DLLStructSetData($logfont4,14,"Segoe UI") DLLStructSetData($logfont5,14,"Segoe UI") ;=============================================== ;=============== SET FONT HEIGHT ================= DLLStructSetData($logfont1,1,-12) DLLStructSetData($logfont2,1,-12) DLLStructSetData($logfont3,1,-12) DLLStructSetData($logfont4,1,-12) DLLStructSetData($logfont5,1,-12) ;=============================================== DLLCall("user32.dll","int","SystemParametersInfo","int",0x002A, _ "int",DllStructGetSize($nonclientmetrics), _ "ptr",DllStructGetPtr($nonclientmetrics),"int",0) nonclientmetrics changing: $nonclientmetrics = DllStructCreate("uint cbSize;int iBorderWidth;int iScrollWidth;int iScrollHeight;int iCaptionWidth;int iCaptionHeight;" & _ "byte lfCaptionFont[60];int iSmCaptionWidth;int iSmCaptionHeight;byte lfSmCaptionFont[60];int iMenuWidth;int iMenuHeight;" & _ "byte lfMenuFont[60];byte lfStatusFont[60];byte lfMessageFont[60];int iPaddedBorderWidth") DLLStructSetData($nonclientmetrics,1,DllStructGetSize($nonclientmetrics)) Global Const $SPI_GETNONCLIENTMETRICS = 0x0029 Global Const $SPI_SETNONCLIENTMETRICS = 0x002A DLLCall("user32.dll","int","SystemParametersInfo","int",0x0029, _ "int",DllStructGetSize($nonclientmetrics), _ "ptr",DllStructGetPtr($nonclientmetrics),"int",0) ;=============GET DATA======================= $Data = DllStructGetData($nonclientmetrics,2) ; PADDED BORDER WIDTH MsgBox(4096,"",$Data) ;============================================ $Err = DLLCall("kernel32.dll","int","GetLastError") ;==================SET DATA================== DLLStructSetData($nonclientmetrics,2,0) ;;changes the 3rd parameter of nonclientmetrics "iscrollwidth" ;DLLStructSetData($nonclientmetrics,5,25) ;================================================= DLLCall("user32.dll","int","SystemParametersInfo","int",0x002A, _ "int",DllStructGetSize($nonclientmetrics), _ "ptr",DllStructGetPtr($nonclientmetrics),"int",0)
tengwer2 Posted March 13, 2012 Author Posted March 13, 2012 (edited) BTW the various elements that can be changed for fonts can be found doing a search for logfont structure and those of nonclientmetrics can be found under nonclientmetrics structure. I just realized that thes posts would have fit more properly under GUI Help and Support. Sorry about that. Perhaps this post can be moved? Edited March 13, 2012 by tengwer2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now