Welcome to Nana C++ Library FAQ

This FAQ is to give simple examples to demonstrate what Nana has to offer.

Questions

Still questions? Ask me: cnjinhao at hotmail com

How to disable console window?

There are examples in documentation use main() function as the entry function. In Windows system, the main() function is the entry for console application, therefore, you can see a console window when run these examples. To disable the console, choose Win32 Application project and WinMain() function for the entry.


How to intercept window messages send by Windows controls?

Nana library does not provide functions to accss the system message loop, because this feature is platform-depended. Nevertheless, by using some library features, it is possible to use Windows subclassing to access native window handles and messages. The window subclassing is to use SetWindowLong() function with GWL_WNDPROC to specify a new window procedure for the specified window. There is a sample class toolkit for implementing the window subclassing written in C++11, click here for the sample.


Does Nana have support for layout management?

Yes, Nana does. Nana provides a powerful class place for layout management, it can makes code much clearer and shorter. Class place supports the splitter bar, you can split windows without writting code. By using class place, the program can change its layout dynamicaly without rebuilding it. Please refer to the doc for the details of class place.


What is nana::string?

nana::string is a typedef name of std::string or std::wstring. If NANA_UNICODE is defined, nana::string is a typedef name of std::wstring, otherwise std::string.


How to convert a UTF8 string to local charset?

Nana provides a class charset.

std::string utf8_str; //A UTF8 string
std::string lc_str = nana::charset(utf8_str, nana::unicode::utf8); //UTF8 to local charset in Windows.
std::wstring utfx_str = nana::charset(utf8_str, nana::unicode::utf8); //UTF8 to UTF16/UTF32

Refer the doc for more details.


Does Nana have support the display of Arabic?

Yes, Nana has support for BiDi languages.


How can I use GDI+ in Nana?

When you want to draw something, you need a graphics object. For example, draw a rectangle on a form by using GDI+.

int main()
{
    //Initilize GDI+ ...
    using namespace nana::gui;

    form fm;

    //Class drawing is to set a draw function for a specified widget, when
    //library redraws the widget, the draw function will be called.
    drawing(fm).draw([](nana::paint::graphics& graph)
    {
        Gdiplus::Graphics gdip((HDC)graph.context());   //Platform-specific
        Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0), 2.0);
        gdip.DrawRectangle(&pen, 0, 0, 100, 100);
    });

    fm.show();
    exec();
}

Refer the doc for the class drawing.