Click here to Skip to main content
15,914,452 members
Home / Discussions / C#
   

C#

 
AnswerRe: HotKey Indicator Pin
Nader Elshehabi14-Sep-06 9:43
Nader Elshehabi14-Sep-06 9:43 
Questionchange form background image Pin
Muller214-Sep-06 4:53
Muller214-Sep-06 4:53 
AnswerRe: change form background image Pin
Judah Gabriel Himango14-Sep-06 5:13
sponsorJudah Gabriel Himango14-Sep-06 5:13 
GeneralRe: change form background image Pin
Muller214-Sep-06 5:49
Muller214-Sep-06 5:49 
GeneralRe: change form background image Pin
User 665814-Sep-06 6:16
User 665814-Sep-06 6:16 
QuestionConvert existing classes to have .designer.cs files Pin
amymarie314-Sep-06 4:53
amymarie314-Sep-06 4:53 
AnswerRe: Convert existing classes to have .designer.cs files Pin
Judah Gabriel Himango14-Sep-06 5:15
sponsorJudah Gabriel Himango14-Sep-06 5:15 
QuestionCreateFontInderect Pin
Draders2314-Sep-06 4:30
Draders2314-Sep-06 4:30 
I'm drawing text using TextOut and when I required text to be vertical I needed to use LogFont to set the orientation. Hovever when texting it on the origional function I made everytime it draws it, its slightly different and reall messed up. Like it will be much bigger and italic and striked outdespite the LOGFONT object saying otherwise.

Here's an image of what it looks like: http://www.draders.com/images/CreateFontIndirect.jpg[^]

The function is:

public static void DrawString(Graphics g, string s, Font Font, Color ForeColour, int x, int y) {<br />
            IntPtr hdc = g.GetHdc();<br />
            LOGFONT LF = new LOGFONT();<br />
            Font.ToLogFont(LF);<br />
           <br />
            IntPtr fntNew = CreateFontIndirect(ref LF);<br />
            IntPtr fntOld = SelectObject(hdc, fntNew);<br />
<br />
            SetTextColor(hdc, RGB(ForeColour));<br />
            SetBkMode(hdc, BackgroundMode.TRANSPARENT);<br />
            TextOut(hdc, x, y, s, System.Text.Encoding.Default.GetByteCount(s));<br />
            SelectObject(hdc, fntOld);<br />
            DeleteObject(fntNew);<br />
            g.ReleaseHdc(hdc);<br />
        }


The logfont produced (using the default forms font) is:

LOGFONT
   lfHeight: -11
   lfWidth: 0
   lfEscapement: 0
   lfOrientation: 0
   lfWeight: FW_NORMAL
   lfItalic: 0
   lfUnderline: 0
   lfStrikeOut: 0
   lfCharSet: SHIFTJIS_CHARSET
   lfOutPrecision: OUT_DEFAULT_PRECIS
   lfClipPrecision: CLIP_DEFAULT_PRECIS
   lfQuality: DEFAULT_QUALITY
   lfPitchAndFamily: FF_DONTCARE
   lfFaceName: Microsoft Sans Serif

I noticed the height was negative and all examples I've seen set it to a positive value, so I tried setting it to 11 before calling CreateFontIndirect and that caused it to not draw at all.

The LOGFONT object and CreateFontIndirect function I used are:

        [DllImport("gdi32")]<br />
        internal static extern IntPtr CreateFontIndirect([In, MarshalAs(UnmanagedType.LPStruct)] ref LOGFONT lplf);<br />
<br />
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]<br />
        internal class LOGFONT {<br />
            public int lfHeight;<br />
            public int lfWidth;<br />
            public int lfEscapement;<br />
            public int lfOrientation;<br />
            public FontWeight lfWeight;<br />
            public byte lfItalic;<br />
            public byte lfUnderline;<br />
            public byte lfStrikeOut;<br />
            public FontCharSet lfCharSet;<br />
            public FontPrecision lfOutPrecision;<br />
            public FontClipPrecision lfClipPrecision;<br />
            public FontQuality lfQuality;<br />
            public FontPitchAndFamily lfPitchAndFamily;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]<br />
            public string lfFaceName;<br />
}


Any help or ideas on what I'm doing wrong would be great!
Questionhow can i use UI Wizard in c# Pin
Parshant Verma14-Sep-06 4:29
Parshant Verma14-Sep-06 4:29 
AnswerRe: how can i use UI Wizard in c# Pin
Judah Gabriel Himango14-Sep-06 5:09
sponsorJudah Gabriel Himango14-Sep-06 5:09 
Questionhow to add image in crystal report Pin
cauvang14-Sep-06 4:04
cauvang14-Sep-06 4:04 
AnswerRe: how to add image in crystal report Pin
Sebastien Lachance14-Sep-06 4:25
Sebastien Lachance14-Sep-06 4:25 
AnswerRe: how to add image in crystal report Pin
Hamid_RT14-Sep-06 9:46
Hamid_RT14-Sep-06 9:46 
QuestionFirst exception very slow when debugging Pin
Soundman32.214-Sep-06 3:50
Soundman32.214-Sep-06 3:50 
AnswerRe: First exception very slow when debugging Pin
Judah Gabriel Himango14-Sep-06 5:17
sponsorJudah Gabriel Himango14-Sep-06 5:17 
QuestionDllImport and calling conventions Pin
Le centriste14-Sep-06 3:45
Le centriste14-Sep-06 3:45 
AnswerRe: DllImport and calling conventions Pin
Judah Gabriel Himango14-Sep-06 5:18
sponsorJudah Gabriel Himango14-Sep-06 5:18 
QuestionHow do I log Which application becomes active. Pin
CJayMeister14-Sep-06 3:41
CJayMeister14-Sep-06 3:41 
AnswerRe: How do I log Which application becomes active. Pin
Judah Gabriel Himango14-Sep-06 5:45
sponsorJudah Gabriel Himango14-Sep-06 5:45 
Questionwhat we call [modified] Pin
Parshant Verma14-Sep-06 3:39
Parshant Verma14-Sep-06 3:39 
AnswerRe: what we call Pin
Le centriste14-Sep-06 3:48
Le centriste14-Sep-06 3:48 
AnswerRe: what we call Pin
Judah Gabriel Himango14-Sep-06 5:08
sponsorJudah Gabriel Himango14-Sep-06 5:08 
QuestionDllImport and datatypes Pin
Le centriste14-Sep-06 3:36
Le centriste14-Sep-06 3:36 
AnswerRe: DllImport and datatypes Pin
V.14-Sep-06 4:11
professionalV.14-Sep-06 4:11 
QuestionDataGrid with Label + TextBox + Listbox Pin
nmandaliya14-Sep-06 3:09
nmandaliya14-Sep-06 3:09 

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.