Click here to Skip to main content
14,329,915 members

C / C++ / MFC

 
GeneralRe: Break when address reading Pin
Member 1308136910-Sep-18 15:49
memberMember 1308136910-Sep-18 15:49 
AnswerRe: Break when address reading Pin
Richard Andrew x6410-Sep-18 8:17
professionalRichard Andrew x6410-Sep-18 8:17 
GeneralRe: Break when address reading Pin
Member 1308136910-Sep-18 15:50
memberMember 1308136910-Sep-18 15:50 
AnswerRe: Break when address reading Pin
«_Superman_»23-Sep-18 22:30
professional«_Superman_»23-Sep-18 22:30 
Questionconfusion about fonts in Windows Pin
Alexander Kindel6-Sep-18 8:43
memberAlexander Kindel6-Sep-18 8:43 
AnswerRe: confusion about fonts in Windows Pin
leon de boer6-Sep-18 17:12
memberleon de boer6-Sep-18 17:12 
GeneralRe: confusion about fonts in Windows Pin
Alexander Kindel6-Sep-18 18:21
memberAlexander Kindel6-Sep-18 18:21 
GeneralRe: confusion about fonts in Windows Pin
leon de boer7-Sep-18 8:41
memberleon de boer7-Sep-18 8:41 
There is no requirement to enumerate the font you can just straight ask for it.
I am going to assume you know how to get a device context for your window to display it in.
I am going to assume the font is a TTF font.

If you want to test it just type in any name of a truetype and it should change how any new text sent to the window displays .. try "Gabriola" or something crazy like that and what it does Smile | :) .

// This code assumes you have a device context for you display window which you will pass in. 
// You get that from GetDC from BeginPaint depending where you are using this

// It is also relying that your font name is "Bravura" if it isn't change it to what you called it as the facename

#include <tchar.h>    // I don't know if your text is unicode or ansi this gets the string  copy around issue
BOOL SetFontToDC(HDC Dc)
{  
   LOGFONT lf = {0 };
   HANDLE TTFHandle;
   lf.lfHeight = -16; 	// This is the font height .. negative means absolute height required no adjusting
   lf.lfWeight = FW_NORMAL; // Set font weight .. piles of options here bold, extra bold etc
   lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; // Tells windows you want TTF font
   _tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Bravura")); // Copy the facename .. that is the name you called your font
   TTFHandle = CreateFontIndirect(&lf);	 // Tell windows to load a logical font for you (indirect aka automated no asks or prompts)
   if (TTFHandle != INVALID_HANDLE_VALUE) // If the create worked
   {
      SelectObject(Dc, TTFHandle);    // Select the font to the Screen DC .. any text to that DC will display in that font
      return TRUE;                    // Return success
    }
    return FALSE;                      // Return failure
}

You get what the indirect is about, it means programatically no user prompts or asking. So this will not ask any questions it will fail quiet if we have done something wrong. On the API that is what any indirect call usually means and yes its a strange terminology as well. Direct is the opposite it means ask the user directly.

There are other options you can ask it for about the font on the LOGFONT structure but none of it is mandatory, 0 for any field means default which is why I zeroed the structure at create.
tagLOGFONTA | Microsoft Docs[^]
In vino veritas


modified 8-Sep-18 0:25am.

GeneralRe: confusion about fonts in Windows Pin
Alexander Kindel11-Sep-18 13:24
memberAlexander Kindel11-Sep-18 13:24 
AnswerRe: confusion about fonts in Windows Pin
Richard Andrew x649-Sep-18 8:17
professionalRichard Andrew x649-Sep-18 8:17 
GeneralRe: confusion about fonts in Windows Pin
leon de boer9-Sep-18 18:04
memberleon de boer9-Sep-18 18:04 
Questionneed help with unix commands Pin
Member 139744595-Sep-18 13:24
memberMember 139744595-Sep-18 13:24 
AnswerRe: need help with unix commands Pin
Peter_in_27805-Sep-18 19:49
professionalPeter_in_27805-Sep-18 19:49 
AnswerRe: need help with unix commands Pin
Richard MacCutchan5-Sep-18 21:59
protectorRichard MacCutchan5-Sep-18 21:59 
QuestionRe: need help with unix commands Pin
David Crow6-Sep-18 5:45
memberDavid Crow6-Sep-18 5:45 
AnswerRe: need help with unix commands Pin
jeron16-Sep-18 6:31
memberjeron16-Sep-18 6:31 
AnswerRe: need help with unix commands Pin
Richard MacCutchan6-Sep-18 7:04
protectorRichard MacCutchan6-Sep-18 7:04 
QuestionUnable to receive custom Ethernet frame Pin
Donnie_Song1-Sep-18 16:45
memberDonnie_Song1-Sep-18 16:45 
SuggestionRe: Unable to receive custom Ethernet frame Pin
Richard MacCutchan1-Sep-18 21:58
protectorRichard MacCutchan1-Sep-18 21:58 
GeneralRe: Unable to receive custom Ethernet frame Pin
Donnie_Song1-Sep-18 22:04
memberDonnie_Song1-Sep-18 22:04 
GeneralRe: Unable to receive custom Ethernet frame Pin
Richard MacCutchan1-Sep-18 22:43
protectorRichard MacCutchan1-Sep-18 22:43 
GeneralRe: Unable to receive custom Ethernet frame Pin
Donnie_Song1-Sep-18 23:06
memberDonnie_Song1-Sep-18 23:06 
GeneralRe: Unable to receive custom Ethernet frame Pin
Victor Nijegorodov1-Sep-18 23:19
memberVictor Nijegorodov1-Sep-18 23:19 
GeneralRe: Unable to receive custom Ethernet frame Pin
Richard MacCutchan1-Sep-18 23:25
protectorRichard MacCutchan1-Sep-18 23:25 
GeneralRe: Unable to receive custom Ethernet frame Pin
Jochen Arndt2-Sep-18 0:31
mveJochen Arndt2-Sep-18 0:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.