Click here to Skip to main content
15,885,546 members
Articles / Multimedia / DirectX

Rendering Text with Direct2D & DirectWrite

Rate me:
Please Sign up or sign in to vote.
4.94/5 (39 votes)
3 Jan 2015CPOL8 min read 105.8K   2.8K   76  
Direct2D, DirectWrite, Windows API, C++, std::shared_ptr and more
#pragma once
#ifndef __HWINCLASS_H__
#define __HWINCLASS_H__

#include "hwinobject.h"


namespace harlinn
{
    namespace windows
    {

        class WindowClass : public Object
        {
            String name;
            String menuName;

            UINT style;
            WNDPROC procedure;
            int classExtraBytes;
            int windowExtraBytes;
            HINSTANCE moduleHandle;
            HICON icon;
            HCURSOR cursor;
            HBRUSH backgroundBrush;
            HICON smallIcon;
        public:
            static String HWIN_EXPORT animate_class_name;
            static String HWIN_EXPORT datetimepick_class_name;
            static String HWIN_EXPORT hotkey_class_name;
            static String HWIN_EXPORT link_class_name;
            static String HWIN_EXPORT monthcal_class_name;
            static String HWIN_EXPORT nativefontctl_class_name;
            static String HWIN_EXPORT progress_class_name;
            static String HWIN_EXPORT rebar_class_name;
            static String HWIN_EXPORT status_class_name;
            static String HWIN_EXPORT toolbar_class_name;
            static String HWIN_EXPORT tooltips_class_name;
            static String HWIN_EXPORT trackbar_class_name;
            static String HWIN_EXPORT updown_class_name;
            static String HWIN_EXPORT button_class_name;
            static String HWIN_EXPORT combobox_class_name; 
            static String HWIN_EXPORT edit_class_name; 
            static String HWIN_EXPORT header_class_name;
            static String HWIN_EXPORT listbox_class_name;
            static String HWIN_EXPORT ipaddress_class_name;
            static String HWIN_EXPORT listview_class_name;
            static String HWIN_EXPORT pagescroller_class_name;
            static String HWIN_EXPORT scrollbar_class_name;
            static String HWIN_EXPORT static_class_name;
            static String HWIN_EXPORT tabcontrol_class_name;
            static String HWIN_EXPORT treeview_class_name;


            HWIN_EXPORT WindowClass();
            HWIN_EXPORT WindowClass(const WNDCLASSEX& wndClass);
            HWIN_EXPORT WindowClass(std::shared_ptr<const WindowClass> existingClass);
            HWIN_EXPORT ~WindowClass();

            HWIN_EXPORT WNDCLASSEX AsWNDCLASSEX() const;

            HWIN_EXPORT WindowClass& Register();


            HWIN_EXPORT const String& GetName() const;
            HWIN_EXPORT WindowClass& SetName( const String& theName);

            HWIN_EXPORT const String& GetMenuName() const;
            HWIN_EXPORT WindowClass& SetMenuName(const String& theMenuName);

            HWIN_EXPORT UINT GetStyle() const;
            HWIN_EXPORT WindowClass& SetStyle(UINT theStyle);

            HWIN_EXPORT WNDPROC GetProcedure() const;
            HWIN_EXPORT WindowClass& SetProcedure(WNDPROC theProcedure);

            HWIN_EXPORT int GetClassExtraBytes() const;
            HWIN_EXPORT WindowClass& SetClassExtraBytes(int theClassExtraBytes);

            HWIN_EXPORT int GetWindowExtraBytes() const;
            HWIN_EXPORT WindowClass& SetWindowExtraBytes(int theWindowExtraBytes);

            HWIN_EXPORT HINSTANCE GetModuleHandle() const;
            HWIN_EXPORT WindowClass& SetModuleHandle(HINSTANCE theModuleHandle);

            HWIN_EXPORT HICON GetIcon() const;
            HWIN_EXPORT WindowClass& SetIcon(HICON theIcon);

            HWIN_EXPORT HCURSOR GetCursor() const;
            HWIN_EXPORT WindowClass& SetCursor(HCURSOR theCursor);

            HWIN_EXPORT HBRUSH GetBackgroundBrush() const;
            HWIN_EXPORT WindowClass& SetBackgroundBrush(HBRUSH theBackgroundBrush);

            HWIN_EXPORT HICON GetSmallIcon() const;
            HWIN_EXPORT WindowClass& SetSmallIcon(HICON theSmallIcon);
            
        };


        

        class WindowClasses : public Object
        {
        public:

            typedef std::map<String, std::shared_ptr<WindowClass> > map_t;
        private:
            map_t map;

            void LoadStandardClasses();
            void LoadStandardClass(const String& className);
        public:
            HWIN_EXPORT WindowClasses();
            HWIN_EXPORT ~WindowClasses();
            
            static HWIN_EXPORT std::shared_ptr<WindowClass> GetClassInfo(const String& className);
            static HWIN_EXPORT std::shared_ptr<WindowClass> GetClassInfo(HINSTANCE hInstance, const String& className);


            HWIN_EXPORT std::shared_ptr<WindowClass> GetWindowClass(const String& className) const;
            HWIN_EXPORT bool Register(std::shared_ptr<WindowClass> theWindowClass);
        };

    };
};


#endif //__HWINMESSAGE_H__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Sea Surveillance AS
Norway Norway
Chief Architect - Sea Surveillance AS.

Specializing in integrated operations and high performance computing solutions.

I’ve been fooling around with computers since the early eighties, I’ve even done work on CP/M and MP/M.

Wrote my first “real” program on a BBC micro model B based on a series in a magazine at that time. It was fun and I got hooked on this thing called programming ...

A few Highlights:

  • High performance application server development
  • Model Driven Architecture and Code generators
  • Real-Time Distributed Solutions
  • C, C++, C#, Java, TSQL, PL/SQL, Delphi, ActionScript, Perl, Rexx
  • Microsoft SQL Server, Oracle RDBMS, IBM DB2, PostGreSQL
  • AMQP, Apache qpid, RabbitMQ, Microsoft Message Queuing, IBM WebSphereMQ, Oracle TuxidoMQ
  • Oracle WebLogic, IBM WebSphere
  • Corba, COM, DCE, WCF
  • AspenTech InfoPlus.21(IP21), OsiSoft PI


More information about what I do for a living can be found at: harlinn.com or LinkedIn

You can contact me at espen@harlinn.no

Comments and Discussions