Schriftgröße ändern



  • Moinsen,

    ich versuche verzweifelt in einem Dialog die Schriftgröße einer Überschrift zu ändern. Leider passiert gar nichts! Die Methode wird ausgeführt aber auf meinem Display ändert sich überhaupt nichts! Hab in der Forumsuche auch nichts gefunden.

    Das ist meine Methode die den Titel eines Dialogs ausgeben soll

    void CDlg\1::SetTitle()
    {
    /*	//Zeichnen der großen Beyedrdynamic Schrift
    	CFont font;
    	VERIFY(font.CreateFont(
    	   8,                        // nHeight
    	   0,                         // nWidth
    	   0,                         // nEscapement
    	   0,                         // nOrientation
    	   FW_NORMAL,                 // nWeight
    	   FALSE,                     // bItalic
    	   FALSE,                     // bUnderline
    	   0,                         // cStrikeOut
    	   ANSI_CHARSET,              // nCharSet
    	   OUT_DEFAULT_PRECIS,        // nOutPrecision
    	   CLIP_DEFAULT_PRECIS,       // nClipPrecision
    	   DEFAULT_QUALITY,           // nQuality
    	   DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
    	   _T("Tahoma")));                 // lpszFacename
    
    	// Use the font which you just created.
    	//CClientDC dc(this);
    	CPaintDC dc(this);
    	CString title=" beyerdynamic))))";
    
    	CFont* def_font = dc.SelectObject(&font);
    	dc.ExtTextOut(20, 50, ETO_OPAQUE, NULL,title, NULL);
    	dc.SelectObject(def_font);
    
    	// Finished with the font, now delete the font object.
    //	font.DeleteObject();
    */
    	// This code fragment shows how to create a font object,
    // select the font object into a DC (device context) for text
    // drawing, and finally delete the font object.
    
    // Initializes a CFont object with the characteristics given 
    // in a LOGFONT structure.
    	CFont font;
    	LOGFONT lf;
    	memset(&lf, 0, sizeof(LOGFONT));       // Zero out the structure.
    	lf.lfHeight = 12;                      // Request a 12-pixel-height font.
    	lstrcpy(lf.lfFaceName, _T("Tahoma"));   // Request a face name "Arial".
    	VERIFY(font.CreateFontIndirect(&lf));  // Create the font.
    
    	// Use the font you just created.
    	CClientDC dc(this);
    	CFont* def_font = dc.SelectObject(&font);
    		CString title=" beyerdynamic))))";
    	dc.ExtTextOut(5, 5, ETO_OPAQUE, NULL,title, NULL);
    	dc.SelectObject(def_font);
    
    	// Finished with the font, now delete the font object.
    //	font.DeleteObject();
    
    }
    

    Beide varianten (obere ist ja auskommentiert) ändern nichts.

    die Methode wird von InitDialog aufgerufen.

    Wer was Rat?

    Danke....



  • Ist klar, deine Werte sind nur in der OnInit gültig. Sobald die OnPain kommt, und die kommt nach OnInit, wird wieder standardmäßig drüber gezeichnet.



  • Einfach den Font als Member-Variable des Dialogs deklarieren.
    In der OnInit initialisieren und anschließend nach Herzenslust im Dialog verwenden...

    Z.B. die Überschrift: für diese eine Membervariable (CStatic) anlegen und dieser dann den Font zuweisen (auch in OnInit)



  • Hi!
    Danke für die Hilfe!

    hab es vorhin schon hinbekommen. Bin auf den gleichen Lösungsansatz wie Ihr gekommen.

    🙂

    Klappt wunderbar!

    Greetz Monne


Anmelden zum Antworten