Click here to Skip to main content
15,899,475 members
Home / Discussions / C#
   

C#

 
GeneralRe: Connection string problem Pin
Harvey Saayman11-Feb-08 22:57
Harvey Saayman11-Feb-08 22:57 
GeneralRe: Connection string problem Pin
Dave Kreskowiak11-Feb-08 3:49
mveDave Kreskowiak11-Feb-08 3:49 
GeneralRe: Connection string problem Pin
Pete O'Hanlon11-Feb-08 2:41
mvePete O'Hanlon11-Feb-08 2:41 
GeneralRe: Connection string problem Pin
D i x y11-Feb-08 17:06
D i x y11-Feb-08 17:06 
GeneralRe: Connection string problem Pin
Harvey Saayman11-Feb-08 20:35
Harvey Saayman11-Feb-08 20:35 
GeneralRe: Connection string problem Pin
Ravenet11-Feb-08 3:10
Ravenet11-Feb-08 3:10 
QuestionHow to Add a Font in Setup Project Pin
Bajrang Singh10-Feb-08 20:04
Bajrang Singh10-Feb-08 20:04 
AnswerRe: How to Add a Font in Setup Project Pin
Rupesh Kumar Swami10-Feb-08 20:18
Rupesh Kumar Swami10-Feb-08 20:18 
hi,
before some time ago , i face this problem. i find the net to resolve this problem and find solution which i decribe below. Note that following code is in vb.net so convert it in c#

first of all add this font to your application for example "ITCKRIST.TTF"
now imports following namespace in module or form level

Imports System.Drawing<br />
Imports System.Text<br />
Imports System.Collections.Generic<br />
Imports System.ComponentModel<br />

now call the following API as following




Private Declare Auto Function AddFontMemResourceEx Lib "Gdi32.dll" _<br />
   (ByVal pbFont As IntPtr, ByVal cbFont As Integer, _<br />
   ByVal pdv As Integer, ByRef pcFonts As Integer) As IntPtr<br />


now write a function as following

Public Function GetFont(ByVal FontResource() As String) As _<br />
        Drawing.Text.PrivateFontCollection<br />
        'Get the namespace of the application    <br />
        Dim NameSpc As String = _<br />
            Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()<br />
        Dim FntStrm As IO.Stream<br />
        Dim FntFC As New Drawing.Text.PrivateFontCollection()<br />
        Dim i As Integer<br />
        For i = 0 To FontResource.GetUpperBound(0)<br />
            'Get the resource stream area where the font is located<br />
            FntStrm = _<br />
        Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _<br />
        NameSpc + "." + FontResource(i))<br />
            'Load the font off the stream into a byte array<br />
            Dim ByteStrm(CType(FntStrm.Length, Integer)) As Byte<br />
            FntStrm.Read(ByteStrm, 0, Int(CType(FntStrm.Length, Integer)))<br />
            'Allocate some memory on the global heap<br />
            Dim FntPtr As IntPtr = _<br />
                Runtime.InteropServices.Marshal.AllocHGlobal( _<br />
                Runtime.InteropServices.Marshal.SizeOf(GetType(Byte)) * _<br />
                    ByteStrm.Length)<br />
            'Copy the byte array holding the font into the allocated memory.<br />
            Runtime.InteropServices.Marshal.Copy(ByteStrm, 0, _<br />
                FntPtr, ByteStrm.Length)<br />
            'Add the font to the PrivateFontCollection<br />
            FntFC.AddMemoryFont(FntPtr, ByteStrm.Length)<br />
            Dim pcFonts As Int32<br />
            pcFonts = 1<br />
            AddFontMemResourceEx(FntPtr, ByteStrm.Length, 0, pcFonts)<br />
            'Free the memory<br />
            Runtime.InteropServices.Marshal.FreeHGlobal(FntPtr)<br />
        Next<br />
        Return FntFC<br />
    End Function<br />
<br />

almost work is done . Now you can change font of any control. for example


dim strFont(0) As String<br />
    dim FntFC As New Drawing.Text.PrivateFontCollection()<br />
<br />
	strFont(0) = "ITCKRIST.TTF"<br />
        FntFC = GetFont(strFont)<br />
<br />
        Label1.Font = New Font(FntFC.Families(0), 16)<br />
        Label2.Font = New Font(FntFC.Families(0), 16)<br />


hope this helps

Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)

My Company

AnswerRe: How to Add a Font in Setup Project Pin
Giorgi Dalakishvili10-Feb-08 20:25
mentorGiorgi Dalakishvili10-Feb-08 20:25 
GeneralRe: How to Add a Font in Setup Project Pin
Rupesh Kumar Swami10-Feb-08 20:39
Rupesh Kumar Swami10-Feb-08 20:39 
GeneralAn unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll in c# Pin
ramyanaidu10-Feb-08 18:36
ramyanaidu10-Feb-08 18:36 
GeneralRe: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll in c# Pin
Martin#10-Feb-08 20:24
Martin#10-Feb-08 20:24 
GeneralPrinting 128-bit integer in decimal Pin
Skippums10-Feb-08 15:59
Skippums10-Feb-08 15:59 
GeneralRe: Printing 128-bit integer in decimal Pin
Luc Pattyn11-Feb-08 1:41
sitebuilderLuc Pattyn11-Feb-08 1:41 
GeneralRe: Printing 128-bit integer in decimal Pin
Skippums11-Feb-08 5:20
Skippums11-Feb-08 5:20 
GeneralRe: Printing 128-bit integer in decimal Pin
Luc Pattyn11-Feb-08 6:06
sitebuilderLuc Pattyn11-Feb-08 6:06 
AnswerRe: Printing 128-bit integer in decimal Pin
Skippums11-Feb-08 5:50
Skippums11-Feb-08 5:50 
QuestionBackground image refreshing on Form resizing? Pin
Jacob Dixon10-Feb-08 13:19
Jacob Dixon10-Feb-08 13:19 
AnswerRe: Background image refreshing on Form resizing? Pin
Jacob Dixon10-Feb-08 13:27
Jacob Dixon10-Feb-08 13:27 
QuestionNew gradient background for Button...? Pin
Edmundisme10-Feb-08 11:23
Edmundisme10-Feb-08 11:23 
AnswerRe: New gradient background for Button...? Pin
Joachim Kerschbaumer10-Feb-08 21:48
Joachim Kerschbaumer10-Feb-08 21:48 
GeneralRe: New gradient background for Button...? Pin
Edmundisme11-Feb-08 7:37
Edmundisme11-Feb-08 7:37 
AnswerRe: New gradient background for Button...? Pin
Abhijit Jana10-Feb-08 22:03
professionalAbhijit Jana10-Feb-08 22:03 
GeneralRe: New gradient background for Button...? Pin
Edmundisme11-Feb-08 7:38
Edmundisme11-Feb-08 7:38 
AnswerRe: New gradient background for Button...? Pin
Ravenet11-Feb-08 3:13
Ravenet11-Feb-08 3:13 

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.