| View previous topic :: View next topic |
| Author |
Message |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Mon Dec 16, 2002 2:16 am Post subject: Windows API question??????????? |
|
|
Does anyone know how or if you can obtain the actual font name from a font handle returned by the WM_GETFONT message?
Thanks in advance,
Bill
ShinobiSoft _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
ACE Valued Newbie

Joined: 05 Sep 2002 Posts: 34
|
Posted: Wed Dec 18, 2002 10:27 pm Post subject: |
|
|
is not in the struct ? of course is in it
Rem (/*)
doesnt this post belongs to the developer forum ?
Rem (*/)
ACE |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Wed Dec 18, 2002 11:32 pm Post subject: |
|
|
This isn't a dll developer question. You can use @sendmsg() to retireve the font handle for just about any control. What I was wondering was if there was any way to find out the actual font name from the retrieved handle?
Keep in mind, I'm limiting the scope of this to the VDS language only. No use of an external dll here.  _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu Dec 19, 2002 4:42 pm Post subject: |
|
|
I took a look into vds_msg.zip, and found this:
| Quote: | WM_FONTCHANGE $01D Not useable
WM_SETFONT $030 Not useable
WM_GETFONT $031 Not useable
By Matt Roberts |
Maybe you can use the Gadget.dll to use this sendmessages... |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Dec 19, 2002 4:52 pm Post subject: |
|
|
That's incorrect Skit, WM_GETFONT works with VDS 3
and is in the VDS API help. It returns a number instead
of the font name, and that's what he's trying to figure out.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361

Last edited by Mac on Thu Dec 19, 2002 4:57 pm; edited 1 time in total |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu Dec 19, 2002 4:56 pm Post subject: |
|
|
| Oops... Maybe he can try to make a dialog with all fonts available, and then check for the numbers, till he has found the same... |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Dec 19, 2002 4:58 pm Post subject: |
|
|
Good idea.  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Thu Dec 19, 2002 6:24 pm Post subject: |
|
|
I think Gadget could be used in order to retrieve information about the font represented by
the font handle, but I'm not sure exactly how at this time... |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Dec 20, 2002 4:17 pm Post subject: |
|
|
bweckel,
Yes you can use Gadget to get the Font name from the font handle. Here is some simple code that shows how you can do that.
| Code: |
Rem Load Gadget with External
External Gadget.dll,demo
Rem Load the gdi32.dll and get it's memory address
%%gdi32 = @Gadget(demo,LoadLib,gdi32.dll)
Rem Define some constants to play with
Gadget demo,Constant,WM_CHAR,258
Gadget demo,Constant,WM_GETFONT,@Sum(0,$31)
Gadget demo,Constant,LF_FACESIZE,32
Gadget demo,Constant,LF_FULLFACESIZE,64
Rem Define the LOGFONT structure
Gadget demo,Structure,LOGFONT,lfHeight As Long;lfWidth As Long;lfEscapement As Long;lfOrientation As Long;lfWeight As Long;lfItalic As Byte;lfUnderline As Byte;lfStrikeOut As Byte;lfCharSet As Byte;lfOutPrecision As Byte;lfClipPrecision As Byte;lfQuality As Byte;lfPitchAndFamily As Byte;lfFaceName As Byte {@Diff(@Gadget(demo,LF_FACESIZE),1)}
Rem declare to Gadget the GetObject function from the gdi32.dll
Gadget demo,Declare,GetObject,%%gdi32,GetObject,hgdiobj As Handle;cbBuffer As Integer;lpvObject As Pointer,Integer
Rem Give the VDS program a title
title TEST
Rem Build a VDS dialog with one style, editbox, and text element.
DIALOG CREATE,TEST,-1,0,207,98
DIALOG ADD,STYLE,STYLE1,Times New Roman,10,,,
DIALOG ADD,EDIT,EDIT1,52,8,180,20,Here is some text,STYLE1
DIALOG ADD,TEXT,TEXT1,16,8,,,,STYLE1
rem Show the dialog
DIALOG SHOW
rem Build a List to hold the WM_CHAR message information
List create,1
Rem Get the dialog's window handle or ID
%%Main_hwnd = @winexists(TEST)
Rem Get the Editboxes window handle or ID
%%Edit1_hwnd = @winexists(~EDIT1)
Rem Send the WM_GETFONT message to the Editbox
%%hfont = @SendMsg(%%Edit1_hwnd,@Gadget(demo,WM_GETFONT),0,0)
Rem Call the GetObject function and pass it the Handle to the font of the edit box
Rem Pass the GetObject the size of the LOGFONT structure
Rem Pass the GetObject the memory Address of the LOGFONT structure
%%Ret = @Gadget(demo,GetObject,"%"%%hfont,@Gadget(demo,SizeOf,LOGFONT),@Gadget(demo,AddrOf,LOGFONT))
Rem The %%Ret variable holds the number of bytes copied to the LOGFONT structure
Rem Now use Gadget's mem Read function to read the bytes from the lfFaceName member of the LOGFONT structure as a string and assign it to the %%lfFaceName VDS variable
%%lfFaceName = @Gadget(demo,mem,Read,@Gadget(demo,AddrOf,LOGFONT.lfFaceName),String)
Rem Use a Info box to show the name of the Font held in %%lfFaceName
Info The Font Face is %%lfFaceName
Rem Initialize Gadget's Getmsg and Setmsg Commands and functions
gadget demo,setmsg
Rem Ok lets trap messages from the EDIT element
gadget demo,setmsg,trapfor,%%Edit1_hwnd
Rem Now lets tell gadget what messages to watch for...
gadget demo,setmsg,watchfor,%%Edit1_hwnd,@Gadget(demo,WM_CHAR)
Rem Now tell gadget to set the hook... Gadget will generate an event
rem called MSG everytime it see's the message WM_CHAR stated above
rem for the EDIT element....
%%HOOK = @gadget(demo,getmsg,eventhook,%%Main_hwnd,"MSG")
:evloop
Rem wait for the next VDS event
wait event
Rem goto the sub-routine that is the event name
goto @event()
:MSG
Rem clear our VDS List
LIST CLEAR,1
Rem Assign the information from Gadget's getmsg function to our list
LIST ASSIGN,1,@gadget(demo,getmsg)
Rem Get the handle of the VDS element that generated the message from our list.
%%Hwnd = @item(1,0)
If @Equal(%%Hwnd, %%Edit1_hwnd)
Rem If the element is our Editbox Assign what ever is in the lparam item
rem to VDS variable %I...Since we are only traping WM_CHAR it should be the ascii value of a character.
%I = @ITEM(1,2)
Rem Write the character to the TEXT element on our dialog. Both the character and it's ascii value.
dialog set,TEXT1,@CHR(%I) = %I
Rem end this IF statment.
End
Rem Return to the evloop sub-routine.
goto evloop
:CLOSE
Rem Close our window and clean up everything
Rem Clear our message hook
gadget demo,setmsg
Rem Unhook our Editbox element
gadget demo,setmsg,unhook,%%HOOK
Rem Clear our list
List clear,1
Rem Close our list
List close,1
Rem Free the gdi32.dll so if it needs to close it can and will
Gadget demo,FreeLib,%%gdi32
Rem Exit our program
exit
|
 _________________ Home of
Give VDS a new purpose!

Last edited by vdsalchemist on Fri Dec 20, 2002 7:11 pm; edited 1 time in total |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Fri Dec 20, 2002 5:01 pm Post subject: |
|
|
And you call that simple???  |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Dec 20, 2002 6:50 pm Post subject: |
|
|
Hi Skit3000,
What is so hard about that script Compared to some of the other scripts that I have seen on this website this is simple... You can PM me if you have any questions about how this works. I will be glad to explain it to you.  _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Dec 20, 2002 8:38 pm Post subject: |
|
|
Hi All,
Well just for Skit3000 I went back and put remarks in my code  _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Fri Dec 20, 2002 9:23 pm Post subject: |
|
|
MindPower thanks for your input, but I was actually wondering if there
was anyway that this could be done with out an extension dll. Since I'm
a registered user of gadget.dll I will keep the script above in mind, and
thanks for taking the time to put it together.
Thanks, _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Dec 20, 2002 9:31 pm Post subject: |
|
|
Your welcome,
It was nothing really. It did not take that long to do. It actually took longer to write the remarks than the code itself.... Anyway have fun... I will add this to my collection of examples for Gadget....
Also just to let you know what Skit3000 suggested will not work. The handle that is returned by the WM_GETFONT is not a number that is permenantly assigned to a font. That number is a handle to the memory location of the font that is loaded in a particular controls Device context. In other words if you have two Edit boxes with the same font the handle that the WM_GETFONT message returns will be different for each.
I currently do not know of any other way to get the Fonts name that a control is using. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|