diff options
author | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2012-09-19 20:51:34 -0700 |
---|---|---|
committer | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2012-09-19 20:51:34 -0700 |
commit | 1123323fda6d128fb98b0427e0ea5f6a2dc9e632 (patch) | |
tree | 3407a3771a069f812554312ce7c36db625139cc2 /fontdump | |
parent | 3cedfae76a2351bc8b1e5bd2ee33bbf8630dbacf (diff) | |
download | xrdp-proprietary-1123323fda6d128fb98b0427e0ea5f6a2dc9e632.tar.gz xrdp-proprietary-1123323fda6d128fb98b0427e0ea5f6a2dc9e632.zip |
o moved from GNU General Public License to Apache License, Version 2.0
o applied new coding standards to all .c files
o moved some files around
Diffstat (limited to 'fontdump')
-rwxr-xr-x | fontdump/fontdump.c | 808 |
1 files changed, 442 insertions, 366 deletions
diff --git a/fontdump/fontdump.c b/fontdump/fontdump.c index 34bdffdc..03609cf0 100755 --- a/fontdump/fontdump.c +++ b/fontdump/fontdump.c @@ -1,3 +1,20 @@ +/** + * xrdp: A Remote Desktop Protocol server. + * + * Copyright (C) Jay Sorg 2004-2012 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include <windows.h> #include <tchar.h> @@ -25,426 +42,485 @@ static int g_running = 0; int check_messages(void) { - MSG msg; - - while (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) - { - GetMessage(&msg, NULL, 0, 0); - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return 0; + MSG msg; + + while (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) + { + GetMessage(&msg, NULL, 0, 0); + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return 0; } /*****************************************************************************/ static int -msg(char* msg1, ...) +msg(char *msg1, ...) { - va_list ap; - char text1[512]; - - va_start(ap, msg1); - vsnprintf(text1, 511, msg1, ap); - SendMessageA(g_lb, LB_ADDSTRING, 0, (LPARAM)text1); - va_end(ap); - return 0; + va_list ap; + char text1[512]; + + va_start(ap, msg1); + vsnprintf(text1, 511, msg1, ap); + SendMessageA(g_lb, LB_ADDSTRING, 0, (LPARAM)text1); + va_end(ap); + return 0; } /*****************************************************************************/ static int show_last_error(void) { - LPVOID lpMsgBuf; - - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&lpMsgBuf, 0, NULL); - msg("GetLastError - %s", lpMsgBuf); - LocalFree(lpMsgBuf); - return 0; + LPVOID lpMsgBuf; + + FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&lpMsgBuf, 0, NULL); + msg("GetLastError - %s", lpMsgBuf); + LocalFree(lpMsgBuf); + return 0; } /*****************************************************************************/ static int font_dump(void) { - HDC dc; - HDC dc1; - RECT rect; - HBRUSH brush; - HGDIOBJ saved; - HBITMAP bitmap; - BITMAPINFO bi; - char* bits; - ABC abc; - SIZE sz; - char filename[256]; - TCHAR text[256]; - char zero1; - char* bmtext; - int bmtextindex; - int fd; - int x1; - int strlen1; - int index1; - int index2; - int len; - int pixel; - int red; - int green; - int blue; - int width; - int height; - int roller; - int outlen; - tui8 b1; - short x2; - - if (g_running) - { - return 0; - } - g_running = 1; - msg("starting"); - g_font_name[0] = 0; - SendMessageA(g_font_list, WM_GETTEXT, 255, (LPARAM)g_font_name); - if (g_strlen(g_font_name) == 0) - { - msg("error font not set"); - g_running = 0; - return 1; - } - dc = GetDC(g_wnd); - height = -MulDiv(g_font_size, GetDeviceCaps(dc, LOGPIXELSY), 72); - g_font = CreateFontA(height, 0, 0, 0, FW_DONTCARE, 0, 0, 0, 0, 0, 0, - 0, 0, g_font_name); - ReleaseDC(g_wnd, dc); - if (g_font == 0) - { - msg("error - Font creation failed"); - } - zero1 = 0; - g_snprintf(filename, 255, "%s-%d.fv1", g_font_name, g_font_size); - msg("creating file %s", filename); - g_file_delete(filename); - fd = g_file_open(filename); - g_file_write(fd, "FNT1", 4); - strlen1 = g_strlen(g_font_name); - g_file_write(fd, g_font_name, strlen1); - x1 = strlen1; - while (x1 < 32) - { - g_file_write(fd, &zero1, 1); - x1++; - } - x2 = g_font_size; /* font size */ - g_file_write(fd, (char*)&x2, 2); - x2 = 1; /* style */ - g_file_write(fd, (char*)&x2, 2); - /* pad */ - index1 = 0; - while (index1 < 8) - { - g_file_write(fd, &zero1, 1); - index1++; - } - for (x1 = 32; x1 < 0x4e00; x1++) - { - check_messages(); - dc = GetWindowDC(g_wnd); - saved = SelectObject(dc, g_font); - if (!GetCharABCWidths(dc, x1, x1, &abc)) + HDC dc; + HDC dc1; + RECT rect; + HBRUSH brush; + HGDIOBJ saved; + HBITMAP bitmap; + BITMAPINFO bi; + char *bits; + ABC abc; + SIZE sz; + char filename[256]; + TCHAR text[256]; + char zero1; + char *bmtext; + int bmtextindex; + int fd; + int x1; + int strlen1; + int index1; + int index2; + int len; + int pixel; + int red; + int green; + int blue; + int width; + int height; + int roller; + int outlen; + tui8 b1; + short x2; + + if (g_running) { - show_last_error(); + return 0; } - text[0] = (TCHAR)x1; - text[1] = 0; - if (!GetTextExtentPoint32(dc, text, 1, &sz)) + + g_running = 1; + msg("starting"); + g_font_name[0] = 0; + SendMessageA(g_font_list, WM_GETTEXT, 255, (LPARAM)g_font_name); + + if (g_strlen(g_font_name) == 0) { - show_last_error(); + msg("error font not set"); + g_running = 0; + return 1; } - SelectObject(dc, saved); + + dc = GetDC(g_wnd); + height = -MulDiv(g_font_size, GetDeviceCaps(dc, LOGPIXELSY), 72); + g_font = CreateFontA(height, 0, 0, 0, FW_DONTCARE, 0, 0, 0, 0, 0, 0, + 0, 0, g_font_name); ReleaseDC(g_wnd, dc); - if ((sz.cx > 0) && (sz.cy > 0)) + + if (g_font == 0) + { + msg("error - Font creation failed"); + } + + zero1 = 0; + g_snprintf(filename, 255, "%s-%d.fv1", g_font_name, g_font_size); + msg("creating file %s", filename); + g_file_delete(filename); + fd = g_file_open(filename); + g_file_write(fd, "FNT1", 4); + strlen1 = g_strlen(g_font_name); + g_file_write(fd, g_font_name, strlen1); + x1 = strlen1; + + while (x1 < 32) + { + g_file_write(fd, &zero1, 1); + x1++; + } + + x2 = g_font_size; /* font size */ + g_file_write(fd, (char *)&x2, 2); + x2 = 1; /* style */ + g_file_write(fd, (char *)&x2, 2); + /* pad */ + index1 = 0; + + while (index1 < 8) { - dc = GetWindowDC(g_wnd); - saved = SelectObject(dc, g_font); - SetBkColor(dc, RGB(255, 255, 255)); - if (!ExtTextOut(dc, 50, 50, ETO_OPAQUE, 0, text, 1, 0)) - { - show_last_error(); - } - SelectObject(dc, saved); - ReleaseDC(g_wnd, dc); - Sleep(10); - /* width */ - x2 = abc.abcB; - g_file_write(fd, (char*)&x2, 2); - /* height */ - x2 = sz.cy; - g_file_write(fd, (char*)&x2, 2); - /* baseline */ - x2 = -sz.cy; - g_file_write(fd, (char*)&x2, 2); - /* offset */ - x2 = abc.abcA; - g_file_write(fd, (char*)&x2, 2); - /* incby */ - x2 = sz.cx; - g_file_write(fd, (char*)&x2, 2); - /* pad */ - index1 = 0; - while (index1 < 6) - { g_file_write(fd, &zero1, 1); index1++; - } - dc = GetWindowDC(g_wnd); - rect.left = 50 + abc.abcA; - rect.top = 50; - rect.right = rect.left + abc.abcB; - rect.bottom = rect.top + sz.cy; - memset(&bi, 0, sizeof(bi)); - width = (abc.abcB + 7) & (~7); - height = sz.cy; - bi.bmiHeader.biSize = sizeof(bi.bmiHeader); - bi.bmiHeader.biWidth = width; - bi.bmiHeader.biHeight = height; - bi.bmiHeader.biPlanes = 1; - bi.bmiHeader.biBitCount = 32; - bitmap = CreateDIBSection(dc, &bi, DIB_RGB_COLORS, (void*)&bits, 0, 0); - if (bitmap == 0) - { - msg("error - CreateDIBSection failed"); - } - else - { - memset(bits, 0, width * height * 4); - dc1 = CreateCompatibleDC(dc); - SelectObject(dc1, bitmap); - if (!BitBlt(dc1, 0, 0, width, height, dc, rect.left, rect.top, SRCCOPY)) + } + + for (x1 = 32; x1 < 0x4e00; x1++) + { + check_messages(); + dc = GetWindowDC(g_wnd); + saved = SelectObject(dc, g_font); + + if (!GetCharABCWidths(dc, x1, x1, &abc)) + { + show_last_error(); + } + + text[0] = (TCHAR)x1; + text[1] = 0; + + if (!GetTextExtentPoint32(dc, text, 1, &sz)) { - show_last_error(); + show_last_error(); } - bmtext = (char*)g_malloc(width * height + 16, 1); - bmtextindex = 0; - for (index1 = (height - 1); index1 >= 0; index1--) + + SelectObject(dc, saved); + ReleaseDC(g_wnd, dc); + + if ((sz.cx > 0) && (sz.cy > 0)) { - for (index2 = 0; index2 < width; index2++) - { - pixel = ((int*)bits)[index1 * width + index2]; - red = (pixel >> 16) & 0xff; - green = (pixel >> 8) & 0xff; - blue = (pixel >> 0) & 0xff; - if (red == 0 && green == 0 && blue == 0) + dc = GetWindowDC(g_wnd); + saved = SelectObject(dc, g_font); + SetBkColor(dc, RGB(255, 255, 255)); + + if (!ExtTextOut(dc, 50, 50, ETO_OPAQUE, 0, text, 1, 0)) + { + show_last_error(); + } + + SelectObject(dc, saved); + ReleaseDC(g_wnd, dc); + Sleep(10); + /* width */ + x2 = abc.abcB; + g_file_write(fd, (char *)&x2, 2); + /* height */ + x2 = sz.cy; + g_file_write(fd, (char *)&x2, 2); + /* baseline */ + x2 = -sz.cy; + g_file_write(fd, (char *)&x2, 2); + /* offset */ + x2 = abc.abcA; + g_file_write(fd, (char *)&x2, 2); + /* incby */ + x2 = sz.cx; + g_file_write(fd, (char *)&x2, 2); + /* pad */ + index1 = 0; + + while (index1 < 6) + { + g_file_write(fd, &zero1, 1); + index1++; + } + + dc = GetWindowDC(g_wnd); + rect.left = 50 + abc.abcA; + rect.top = 50; + rect.right = rect.left + abc.abcB; + rect.bottom = rect.top + sz.cy; + memset(&bi, 0, sizeof(bi)); + width = (abc.abcB + 7) & (~7); + height = sz.cy; + bi.bmiHeader.biSize = sizeof(bi.bmiHeader); + bi.bmiHeader.biWidth = width; + bi.bmiHeader.biHeight = height; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + bitmap = CreateDIBSection(dc, &bi, DIB_RGB_COLORS, (void *)&bits, 0, 0); + + if (bitmap == 0) { - bmtext[bmtextindex] = '1'; - bmtextindex++; + msg("error - CreateDIBSection failed"); } else { - bmtext[bmtextindex] = '0'; - bmtextindex++; + memset(bits, 0, width * height * 4); + dc1 = CreateCompatibleDC(dc); + SelectObject(dc1, bitmap); + + if (!BitBlt(dc1, 0, 0, width, height, dc, rect.left, rect.top, SRCCOPY)) + { + show_last_error(); + } + + bmtext = (char *)g_malloc(width * height + 16, 1); + bmtextindex = 0; + + for (index1 = (height - 1); index1 >= 0; index1--) + { + for (index2 = 0; index2 < width; index2++) + { + pixel = ((int *)bits)[index1 * width + index2]; + red = (pixel >> 16) & 0xff; + green = (pixel >> 8) & 0xff; + blue = (pixel >> 0) & 0xff; + + if (red == 0 && green == 0 && blue == 0) + { + bmtext[bmtextindex] = '1'; + bmtextindex++; + } + else + { + bmtext[bmtextindex] = '0'; + bmtextindex++; + } + } + } + + outlen = 0; + b1 = 0; + roller = 0; + len = g_strlen(bmtext); + + for (index2 = 0; index2 < len; index2++) + { + if (bmtext[index2] == '1') + { + switch (roller) + { + case 0: + b1 = b1 | 0x80; + break; + case 1: + b1 = b1 | 0x40; + break; + case 2: + b1 = b1 | 0x20; + break; + case 3: + b1 = b1 | 0x10; + break; + case 4: + b1 = b1 | 0x08; + break; + case 5: + b1 = b1 | 0x04; + break; + case 6: + b1 = b1 | 0x02; + break; + case 7: + b1 = b1 | 0x01; + break; + } + } + + roller++; + + if (roller == 8) + { + roller = 0; + g_file_write(fd, &b1, 1); + outlen++; + b1 = 0; + } + } + + while ((outlen % 4) != 0) + { + g_file_write(fd, &zero1, 1); + outlen++; + } + + free(bmtext); + DeleteDC(dc1); + DeleteObject(bitmap); } - } - } - outlen = 0; - b1 = 0; - roller = 0; - len = g_strlen(bmtext); - for (index2 = 0; index2 < len; index2++) - { - if (bmtext[index2] == '1') - { - switch (roller) + + if (sz.cx != (long)(abc.abcA + abc.abcB + abc.abcC)) { - case 0: b1 = b1 | 0x80; break; - case 1: b1 = b1 | 0x40; break; - case 2: b1 = b1 | 0x20; break; - case 3: b1 = b1 | 0x10; break; - case 4: b1 = b1 | 0x08; break; - case 5: b1 = b1 | 0x04; break; - case 6: b1 = b1 | 0x02; break; - case 7: b1 = b1 | 0x01; break; + msg("error - width not right 1"); } - } - roller++; - if (roller == 8) - { - roller = 0; - g_file_write(fd, &b1, 1); - outlen++; - b1 = 0; - } + + brush = CreateSolidBrush(RGB(255, 255, 255)); + FillRect(dc, &rect, brush); + DeleteObject(brush); + ReleaseDC(g_wnd, dc); } - while ((outlen % 4) != 0) + else { - g_file_write(fd, &zero1, 1); - outlen++; + /* write out a blank glyph here */ + /* width */ + x2 = 1; + g_file_write(fd, (char *)&x2, 2); + /* height */ + x2 = 1; + g_file_write(fd, (char *)&x2, 2); + /* baseline */ + x2 = 0; + g_file_write(fd, (char *)&x2, 2); + /* offset */ + x2 = 0; + g_file_write(fd, (char *)&x2, 2); + /* incby */ + x2 = 1; + g_file_write(fd, (char *)&x2, 2); + /* pad */ + index1 = 0; + + while (index1 < 6) + { + g_file_write(fd, &zero1, 1); + index1++; + } + + /* blank bitmap */ + index1 = 0; + + while (index1 < 4) + { + g_file_write(fd, &zero1, 1); + index1++; + } } - free(bmtext); - DeleteDC(dc1); - DeleteObject(bitmap); - } - if (sz.cx != (long)(abc.abcA + abc.abcB + abc.abcC)) - { - msg("error - width not right 1"); - } - brush = CreateSolidBrush(RGB(255, 255, 255)); - FillRect(dc, &rect, brush); - DeleteObject(brush); - ReleaseDC(g_wnd, dc); - } - else - { - /* write out a blank glyph here */ - /* width */ - x2 = 1; - g_file_write(fd, (char*)&x2, 2); - /* height */ - x2 = 1; - g_file_write(fd, (char*)&x2, 2); - /* baseline */ - x2 = 0; - g_file_write(fd, (char*)&x2, 2); - /* offset */ - x2 = 0; - g_file_write(fd, (char*)&x2, 2); - /* incby */ - x2 = 1; - g_file_write(fd, (char*)&x2, 2); - /* pad */ - index1 = 0; - while (index1 < 6) - { - g_file_write(fd, &zero1, 1); - index1++; - } - /* blank bitmap */ - index1 = 0; - while (index1 < 4) - { - g_file_write(fd, &zero1, 1); - index1++; - } } - } - g_file_close(fd); - msg("done"); - g_running = 0; - return 0; + + g_file_close(fd); + msg("done"); + g_running = 0; + return 0; } /*****************************************************************************/ static LRESULT CALLBACK wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - PAINTSTRUCT ps; - HBRUSH brush; - RECT rect; - - switch (message) - { - case WM_PAINT: - BeginPaint(hWnd, &ps); - brush = CreateSolidBrush(RGB(255, 255, 255)); - rect = ps.rcPaint; - FillRect(ps.hdc, &rect, brush); - DeleteObject(brush); - EndPaint(hWnd, &ps); - break; - case WM_CLOSE: - DestroyWindow(g_wnd); - g_wnd = 0; - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - case WM_TIMER: - KillTimer(g_wnd, 1); - font_dump(); - break; - case WM_COMMAND: - if ((HWND)lParam == g_exit_button) - { - PostMessage(g_wnd, WM_CLOSE, 0, 0); - } - else if ((HWND)lParam == g_go_button) - { - while (SendMessage(g_lb, LB_GETCOUNT, 0, 0) > 0) - { - SendMessage(g_lb, LB_DELETESTRING, 0, 0); - } - SetTimer(g_wnd, 1, 1000, 0); - } - break; - } - return DefWindowProc(hWnd, message, wParam, lParam); + PAINTSTRUCT ps; + HBRUSH brush; + RECT rect; + + switch (message) + { + case WM_PAINT: + BeginPaint(hWnd, &ps); + brush = CreateSolidBrush(RGB(255, 255, 255)); + rect = ps.rcPaint; + FillRect(ps.hdc, &rect, brush); + DeleteObject(brush); + EndPaint(hWnd, &ps); + break; + case WM_CLOSE: + DestroyWindow(g_wnd); + g_wnd = 0; + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + case WM_TIMER: + KillTimer(g_wnd, 1); + font_dump(); + break; + case WM_COMMAND: + + if ((HWND)lParam == g_exit_button) + { + PostMessage(g_wnd, WM_CLOSE, 0, 0); + } + else if ((HWND)lParam == g_go_button) + { + while (SendMessage(g_lb, LB_GETCOUNT, 0, 0) > 0) + { + SendMessage(g_lb, LB_DELETESTRING, 0, 0); + } + + SetTimer(g_wnd, 1, 1000, 0); + } + + break; + } + + return DefWindowProc(hWnd, message, wParam, lParam); } /*****************************************************************************/ static int create_window(void) { - WNDCLASS wc; - DWORD style; - HDC dc; - int height; - int left; - int top; - - ZeroMemory(&wc, sizeof(wc)); - wc.lpfnWndProc = wnd_proc; /* points to window procedure */ - /* name of window class */ - wc.lpszClassName = _T("fontdump"); - wc.hCursor = LoadCursor(0, IDC_ARROW); - /* Register the window class. */ - if (!RegisterClass(&wc)) - { - return 0; /* Failed to register window class */ - } - style = WS_OVERLAPPED | WS_CAPTION | WS_POPUP | WS_MINIMIZEBOX | - WS_SYSMENU | WS_SIZEBOX | WS_MAXIMIZEBOX; - left = GetSystemMetrics(SM_CXSCREEN) / 2 - 640 / 2; - top = GetSystemMetrics(SM_CYSCREEN) / 2 - 480 / 2; - g_wnd = CreateWindow(wc.lpszClassName, _T("fontdump"), - style, left, top, 640, 480, - (HWND) NULL, (HMENU) NULL, g_instance, - (LPVOID) NULL); - style = WS_CHILD | WS_VISIBLE | WS_BORDER; - g_lb = CreateWindow(_T("LISTBOX"), _T("LISTBOX1"), style, - 200, 10, 400, 400, g_wnd, 0, g_instance, 0); - style = WS_CHILD | WS_VISIBLE; - g_exit_button = CreateWindow(_T("BUTTON"), _T("Exit"), style, - 540, 410, 75, 25, g_wnd, 0, g_instance, 0); - g_go_button = CreateWindow(_T("BUTTON"), _T("Go"), style, - 440, 410, 75, 25, g_wnd, 0, g_instance, 0); - style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN; - g_font_list = CreateWindow(_T("COMBOBOX"), _T("COMBOBOX1"), style, - 50, 250, 125, 125, g_wnd, 0, g_instance, 0); - ShowWindow(g_wnd, SW_SHOWNORMAL); - PostMessage(g_wnd, WM_SETFONT, (WPARAM)g_font, 0); - SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"Tahoma"); - SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"DejaVu Serif"); - SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"DejaVu Sans"); - SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"Arial"); - SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"Comic Sans MS"); - return 0; + WNDCLASS wc; + DWORD style; + HDC dc; + int height; + int left; + int top; + + ZeroMemory(&wc, sizeof(wc)); + wc.lpfnWndProc = wnd_proc; /* points to window procedure */ + /* name of window class */ + wc.lpszClassName = _T("fontdump"); + wc.hCursor = LoadCursor(0, IDC_ARROW); + + /* Register the window class. */ + if (!RegisterClass(&wc)) + { + return 0; /* Failed to register window class */ + } + + style = WS_OVERLAPPED | WS_CAPTION | WS_POPUP | WS_MINIMIZEBOX | + WS_SYSMENU | WS_SIZEBOX | WS_MAXIMIZEBOX; + left = GetSystemMetrics(SM_CXSCREEN) / 2 - 640 / 2; + top = GetSystemMetrics(SM_CYSCREEN) / 2 - 480 / 2; + g_wnd = CreateWindow(wc.lpszClassName, _T("fontdump"), + style, left, top, 640, 480, + (HWND) NULL, (HMENU) NULL, g_instance, + (LPVOID) NULL); + style = WS_CHILD | WS_VISIBLE | WS_BORDER; + g_lb = CreateWindow(_T("LISTBOX"), _T("LISTBOX1"), style, + 200, 10, 400, 400, g_wnd, 0, g_instance, 0); + style = WS_CHILD | WS_VISIBLE; + g_exit_button = CreateWindow(_T("BUTTON"), _T("Exit"), style, + 540, 410, 75, 25, g_wnd, 0, g_instance, 0); + g_go_button = CreateWindow(_T("BUTTON"), _T("Go"), style, + 440, 410, 75, 25, g_wnd, 0, g_instance, 0); + style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN; + g_font_list = CreateWindow(_T("COMBOBOX"), _T("COMBOBOX1"), style, + 50, 250, 125, 125, g_wnd, 0, g_instance, 0); + ShowWindow(g_wnd, SW_SHOWNORMAL); + PostMessage(g_wnd, WM_SETFONT, (WPARAM)g_font, 0); + SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"Tahoma"); + SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"DejaVu Serif"); + SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"DejaVu Sans"); + SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"Arial"); + SendMessageA(g_font_list, CB_ADDSTRING, 0, (LPARAM)"Comic Sans MS"); + return 0; } /*****************************************************************************/ static int main_loop(void) { - MSG msg; - - while (GetMessage(&msg, NULL, 0, 0)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return (int)(msg.wParam); + MSG msg; + + while (GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return (int)(msg.wParam); } /*****************************************************************************/ @@ -452,7 +528,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - g_instance = hInstance; - create_window(); - return main_loop(); + g_instance = hInstance; + create_window(); + return main_loop(); } |