Results 1 to 7 of 7

Thread: Creating your own control... Custom font issues...

  1. #1
    amac
    Guest

    Creating your own control... Custom font issues...

    I am creating a URL static control, which I guess would be simular to the windows SysLink control... The reason I am creating this is because the SysLink control is not available unless users have the CommCtrl32.dll version 6.+.

    Handled messages:
    WM_SETFONT:
    If the controls style has the underline style set, I get the LOGFONT structure for the font being passed in and set the lfUnderline member to true, and create a new font. This new font is stored in a struct, which is unique for each control of this class.

    WM_PAINT:
    I select the font stored in the controls struct into the current DC, and draw the text... after I do this I select the original font back into the DC.

    WM_LBUTTONDOWN:
    Changes the controls mode ( changes the color ) and forces the control to be repainted.

    The problem is when I click on the control... the text color is changed fine and the font that should be used... is.... But... the font for other controls on the Dialog are changed... to Shell Dlg or something, which I didn't expect to happen...

    I was wondering if anyone had any ideas why this may be happening or any tips when using custom fonts.

    I can make the code available if need be.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I assume you use
    HFONT oldFont = SelectObject(hdc, newFont);

    and later:
    SelectObject(hdc, oldFont);

    right?

    Can do nothing else without the code...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    amac
    Guest
    Yes, I do.

    I am also open to any suggests that might make things easier for me now... and in the future.
    Attached Files Attached Files

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You forgot the break after the WM_PAINT of your control. That causes the problem (though I don't know how).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    One thing: you should make your control UNICODE-compatible NOW. It is always harder to do it later, and it is harder to make a dll compatible than an exe (dlls should have both in one, unlike exes)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    amac
    Guest
    How would I accomplish this?


    Do I export two functions on UNICODE and the other not?

    and then in the header file define macros to point to the correct one... kinda like how MS does it?

    Have one function SomethingA() and another SomethingW(), and then define a macro Something() that changes depending on whether or not UNICODE is defined??

    Shoud the internals of the DLL use UNICODE, and the ANSI functions converts its string input into UNICODE?

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yep, exactly.
    Just be careful when using UNICODE on the internal functions because Win9x does not support much UNICODE (just a few like MessageBoxW). If somewhere you are using a W function that is not implemented in 9x you have to completly rewrite the A version of your function. (And therefore all that call it).
    It's mainly a copy, paste 'n' correct thing, but it blows up the dll.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width