forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Windows API question???????????
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Mon Dec 16, 2002 2:16 am    Post subject: Windows API question??????????? Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
ACE
Valued Newbie


Joined: 05 Sep 2002
Posts: 34

PostPosted: Wed Dec 18, 2002 10:27 pm    Post subject: Reply with quote

is not in the struct ? of course is in it

Rem (/*)

doesnt this post belongs to the developer forum ?

Rem (*/)

ACE
Back to top
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Wed Dec 18, 2002 11:32 pm    Post subject: Reply with quote

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. Confused

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu Dec 19, 2002 4:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Dec 19, 2002 4:52 pm    Post subject: Reply with quote

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. Wink

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu Dec 19, 2002 4:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Dec 19, 2002 4:58 pm    Post subject: Reply with quote

Good idea. Wink
_________________
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
View user's profile Send private message Send e-mail
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Thu Dec 19, 2002 6:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Dec 20, 2002 4:17 pm    Post subject: Reply with quote

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


Very Happy

_________________
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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Dec 20, 2002 5:01 pm    Post subject: Reply with quote

And you call that simple??? Confused Wink
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Dec 20, 2002 6:50 pm    Post subject: Reply with quote

Hi Skit3000,
What is so hard about that script Question 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. Wink

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Dec 20, 2002 8:38 pm    Post subject: Reply with quote

Hi All,
Well just for Skit3000 I went back and put remarks in my code Wink

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Dec 20, 2002 9:13 pm    Post subject: Reply with quote

Hi all me again,
For an exact listing of all the members of the LOGFONT structure and what they are for please navigate to Micro$oft's MSDN site here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_1wmq.asp .... Or you can download the Win32API help file from http://www.vdsworld.com/~dragon_sphere/Win32hlp.zip be warned though the Win32hlp.zip file is over 8mb in size Wink

Have fun,

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Dec 20, 2002 9:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Dec 20, 2002 9:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group