Note that there are some explanatory texts on larger screens.

plurals
  1. POAPI-level Unicode GUI Native apps in C++ for Windows/Linux/Mac
    text
    copied!<p><h1>API-level Unicode GUI Native apps in C++ for Windows / Linux / Mac OS X.</h1><br/></p> <p>I am looking for writing a simple <strong>Unicode</strong>, <strong>GUI</strong>, <strong>Native</strong>, application, that can be run without need any non-standard library, written in C++ compiled with GNU-GCC (g++).</p> <h2>NOT</h2> <p>I don't mean one-code-source run-anywhere, but 3 (Win/Linux/Mac) code source! run-without-library (native application).</p> <h2>* Native application</h2> <p>Application can run without need any non-standard library, only the operating system C++ runtime (like MSVCRT on Windows).</p> <h2>* Unicode application</h2> <p>Right-to-left Window Layout (to support Right to left reading languages), with two buttons [Message] to show UTF-8 stings ("اهلا بالعالم") in a message-box, and [Exit] to... i think exit! :p</p> <p>===================================</p> <h2>The solution for Windows (Windows 7)</h2> <p>Compiler: MinGW g++ 4.5.0<br/> Command line:<br/><pre>g++ -Wl,--enable-auto-import -O2 -fno-strict-aliasing -DWIN32_LEAN_AND_MEAN -D_UNICODE -DUNICODE -mwindows -Wall test.cpp -o test.exe</pre></p> <pre>#include (windows.h) #include (tchar.h) #include (string) typedef std::basic_string 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(LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED)); window.hbrBackground = reinterpret_cast(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(msg.wParam); }</pre> <p><br/> <a href="http://download.seifsoftware.com/the_solution_for_%20windows_in_c++.png" rel="nofollow noreferrer">http://download.seifsoftware.com/the_solution_for_%20windows_in_c++.png</a> <br/> NOT: This application is attached only with MSVCRT.DLL, that mean is a native windows C++ application.</p> <p>===================================</p> <p><h2>The solution for Linux</h2><br/></p> <p><h2>Please HELP!</h2><br/></p> <p>how run the application on Linux without tell to user to install this and this.. a native Linux application!<br/></p> <ul> <li>What is the file format most be ? ELF, Bin.. ?<br/></li> <li>X11 is the native Linux GUI library ? or WxWidgets, QT, GTK+, gtkmm.. ???!!!<br/></li> <li>Can be run on Gnome and KDE ? or need a different code source ?<br/></li> </ul> <p>Any one know the solution for Linux ?<br/><br/></p> <p>===================================</p> <p><br/><br/><h2>The solution for Mac OS X</h2></p> <p><h2>Please HELP!</h2><br/></p> <p>I think the solution for Mac OS X is Cocoa in C++ with G++ ! but i'm note sure !</p> <ul> <li>Can G++ build a native Mac OS application with Cocoa ??</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload