API级Unicode GUI用于Windows/Linux/Mac的C++中的本机应用程序

Fre*_*eif -2 c++ user-interface cross-platform native utf-8

API级Unicode GUI用于Windows/Linux/Mac OS X的C++中的本机应用程序.


我正在寻找一个简单的Unicode,GUI,Native,应用程序,可以在不需要任何非标准库的情况下运行,使用GNU-GCC(g ++)编译的C++编写.

我不是指一个代码源运行任何地方,而是3(Win/Linux/Mac)代码源!run-without-library(本机应用程序).

*原生申请

应用程序可以在不需要任何非标准库的情况下运行,只需要操作系统C++运行时(如Windows上的MSVCRT).

*Unicode应用程序

从右到左的窗口布局(支持从右到左阅读语言),两个按钮[Message]在消息框中显示UTF-8 stings("اهلابالعالم"),[Exit]到... i想退出!:p

===================================

适用于Windows的解决方案(Windows 7)

编译器:MinGW g ++ 4.5.0
命令行:

#include (windows.h)
#include (tchar.h)
#include (string)

typedef std::basic_string<TCHAR> ustring;

LONG StandardExtendedStyle;

TCHAR buffer_1[1024];
TCHAR buffer_2[1024];

static HWND button_1;
static HWND button_2;

inline int ErrMsg(const ustring& s)
{
 return MessageBox(0,s.c_str(),_T("ERROR"),MB_OK|MB_ICONEXCLAMATION);
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
 {
 case WM_CREATE:

 button_1=CreateWindow(L"button",L"UTF-8 Message",WS_CHILD|WS_VISIBLE,10,10,120,25,hwnd,(HMENU)1,NULL,NULL);
 button_2=CreateWindow(L"button",L"Exit",WS_CHILD|WS_VISIBLE,10,50,120,25,hwnd,(HMENU)2,NULL,NULL);

 break;

 case WM_COMMAND:

  switch(LOWORD(wParam))
  {

    case 1:

    _stprintf(buffer_1,L"???? ???????");
    _stprintf(buffer_2,L"Hello World in Arabic !");
    MessageBoxW(hwnd,buffer_1,buffer_2,MB_ICONINFORMATION|MB_OK|MB_RTLREADING|MB_RIGHT);

    break;

    case 2:

    PostQuitMessage(0);

    break;

  }break;

  case WM_CLOSE:

  DestroyWindow(hwnd);

  break;

  case WM_DESTROY:

  PostQuitMessage(0);

  break;

  default:
   return DefWindowProc(hwnd,uMsg,wParam,lParam);
 }
  return 0;
}

int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR pStr,int nCmd)
{

 ustring classname=_T("window");
 WNDCLASSEX window={0};
 window.cbSize        = sizeof(WNDCLASSEX);
 window.lpfnWndProc   = WndProc;
 window.hInstance     = hInst;
 window.hIcon         = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(100), IMAGE_ICON, 16, 16, 0);
 window.hCursor       = reinterpret_cast<HCURSOR>(LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED));
 window.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE+1);
 window.lpszClassName = classname.c_str(); 

 if (!RegisterClassEx(&window))
 {
   ErrMsg(_T("Failed to register wnd class"));return -1;
 }

 int desktopwidth=GetSystemMetrics(SM_CXSCREEN);
 int desktopheight=GetSystemMetrics(SM_CYSCREEN);

 HWND hwnd=CreateWindowEx(0,classname.c_str(),_T("The solution for Windows"),WS_OVERLAPPEDWINDOW,desktopwidth/4,desktopheight/4,270,150,0,0,
hInst,0);

 if (!hwnd)
 {
  ErrMsg(_T("Failed to create wnd"));
  return -1;
 }

 StandardExtendedStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
 SetWindowLong(hwnd,GWL_EXSTYLE,StandardExtendedStyle|WS_EX_LAYOUTRTL);
 ShowWindow(hwnd,nCmd); 
 UpdateWindow(hwnd);
 MSG msg;
 while (GetMessage(&msg,0,0,0)>0)
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
 return static_cast<int>(msg.wParam);
}
Run Code Online (Sandbox Code Playgroud)

#include (windows.h)
#include (tchar.h)
#include (string)

typedef std::basic_string<TCHAR> ustring;

LONG StandardExtendedStyle;

TCHAR buffer_1[1024];
TCHAR buffer_2[1024];

static HWND button_1;
static HWND button_2;

inline int ErrMsg(const ustring& s)
{
 return MessageBox(0,s.c_str(),_T("ERROR"),MB_OK|MB_ICONEXCLAMATION);
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
 {
 case WM_CREATE:

 button_1=CreateWindow(L"button",L"UTF-8 Message",WS_CHILD|WS_VISIBLE,10,10,120,25,hwnd,(HMENU)1,NULL,NULL);
 button_2=CreateWindow(L"button",L"Exit",WS_CHILD|WS_VISIBLE,10,50,120,25,hwnd,(HMENU)2,NULL,NULL);

 break;

 case WM_COMMAND:

  switch(LOWORD(wParam))
  {

    case 1:

    _stprintf(buffer_1,L"???? ???????");
    _stprintf(buffer_2,L"Hello World in Arabic !");
    MessageBoxW(hwnd,buffer_1,buffer_2,MB_ICONINFORMATION|MB_OK|MB_RTLREADING|MB_RIGHT);

    break;

    case 2:

    PostQuitMessage(0);

    break;

  }break;

  case WM_CLOSE:

  DestroyWindow(hwnd);

  break;

  case WM_DESTROY:

  PostQuitMessage(0);

  break;

  default:
   return DefWindowProc(hwnd,uMsg,wParam,lParam);
 }
  return 0;
}

int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR pStr,int nCmd)
{

 ustring classname=_T("window");
 WNDCLASSEX window={0};
 window.cbSize        = sizeof(WNDCLASSEX);
 window.lpfnWndProc   = WndProc;
 window.hInstance     = hInst;
 window.hIcon         = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(100), IMAGE_ICON, 16, 16, 0);
 window.hCursor       = reinterpret_cast<HCURSOR>(LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED));
 window.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE+1);
 window.lpszClassName = classname.c_str(); 

 if (!RegisterClassEx(&window))
 {
   ErrMsg(_T("Failed to register wnd class"));return -1;
 }

 int desktopwidth=GetSystemMetrics(SM_CXSCREEN);
 int desktopheight=GetSystemMetrics(SM_CYSCREEN);

 HWND hwnd=CreateWindowEx(0,classname.c_str(),_T("The solution for Windows"),WS_OVERLAPPEDWINDOW,desktopwidth/4,desktopheight/4,270,150,0,0,
hInst,0);

 if (!hwnd)
 {
  ErrMsg(_T("Failed to create wnd"));
  return -1;
 }

 StandardExtendedStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
 SetWindowLong(hwnd,GWL_EXSTYLE,StandardExtendedStyle|WS_EX_LAYOUTRTL);
 ShowWindow(hwnd,nCmd); 
 UpdateWindow(hwnd);
 MSG msg;
 while (GetMessage(&msg,0,0,0)>0)
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
 return static_cast<int>(msg.wParam);
}
Run Code Online (Sandbox Code Playgroud)


http://download.seifsoftware.com/the_solution_for_%20windows_in_c++.png
NOT:此应用程序仅附加MSVCRT.DLL,即本机Windows C++应用程序.

===================================

适用于Linux的解决方案


请帮忙!


如何在Linux上运行应用程序而不告诉用户安装这个和本机Linux应用程序!

  • 文件格式最多的是什么?ELF,宾..?
  • X11是原生Linux GUI库吗?或WxWidgets,QT,GTK +,gtkmm .. ??? !!!
  • 可以在Gnome和KDE上运行吗?或需要不同的代码源?

谁知道Linux的解决方案?

===================================



适用于Mac OS X的解决方案

请帮忙!


我认为Mac OS X的解决方案是使用G ++的C++中的Cocoa!但我必须确定!

  • G ++可以用Cocoa构建一个原生的Mac OS应用程序吗?

Mar*_*ett 6

或者Qt.不是'原生',但MFC,WPF,Silverlight ......

  • +1 Qt比wxWidgets好多了,恕我直言 (2认同)