NO

Author Topic: Unicode symbol  (Read 2980 times)

czerny

  • Guest
Unicode symbol
« on: December 18, 2011, 07:29:15 PM »
Hallo,

I would like to use a symbol that looks like a little sun (unicode 9788) as button text.

I tried:

Code: [Select]
hFont = CreateFont(0, 0, 0, 0, 0, 0, 0, 0, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DECORATIVE, "Arial");
SendDlgItemMessage(hwndDlg,ID_BUT,WM_SETFONT,(WPARAM)hFont,MAKELPARAM(TRUE, 0));
unsigned long c = 0x263CU; // high bytes terminate string!
SendDlgItemMessage(hwndDlg,ID_BUT,WM_SETTEXT,0,(LPARAM)(&c));

But what I get is a frame (a little bit different from the 'not def' sign).

I have UNICODE and _UNICODE defined.

What I am doing wrong?

czerny



laurro

  • Guest
Re: Unicode symbol
« Reply #1 on: December 18, 2011, 11:23:18 PM »
Make your dialog UNICODE , here is how :

#define UNICODE
#define _UNICODE
#include <windows.h>
#include <tchar.h>
#include "main.h"

static INT_PTR CALLBACK MainDlgProc(HWND, UINT, WPARAM, LPARAM);
static HANDLE ghInstance;

int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
    WNDCLASSEX wcx;
    ghInstance = hInstance;
    wcx.cbSize = sizeof(wcx);
    if (!GetClassInfoEx(NULL, MAKEINTRESOURCE(32770), &wcx))        return 0;
    wcx.hInstance = hInstance;
    wcx.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(8001));
    wcx.lpszClassName =L"buttonClass";
    if (!RegisterClassEx(&wcx))        return 0;

    return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)MainDlgProc);
}

static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
        case WM_INITDIALOG:
{
HFONT hFont = CreateFont(0, 0, 0, 0, FW_MEDIUM, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Arial"));
SendDlgItemMessage(hwndDlg,IDOK,WM_SETFONT,(WPARAM)hFont,MAKELPARAM(1, 0));
wchar_t *c = L"\x263C";
SendDlgItemMessage(hwndDlg,IDOK,WM_SETTEXT,0,(LPARAM) c);
}         
            return TRUE;

         case WM_COMMAND:
            switch (LOWORD(wParam))
            {
               case IDOK:
                    EndDialog(hwndDlg, TRUE);
                    return TRUE;
            }
            break;

        case WM_CLOSE:
            EndDialog(hwndDlg, 0);
            return TRUE;
    }
    return FALSE;
}


    Laur