English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

好像每種C++編譯器做出一個window的方法很多也都不一樣
有沒有每一種編譯器都通用的??
請大大貼個範例
感謝~

2006-07-13 08:49:24 · 1 個解答 · 發問者 米老薯條 2 in 電腦與網際網路 程式設計

基本的window就好,有個小按鈕或文字輸入框也沒關係...

2006-07-13 08:50:12 · update #1

霧沙沙XD
有沒有像java的Frame一樣精簡的??

2006-07-13 12:43:58 · update #2

1 個解答

如果new一個project然後選Windows Application,出來的東西看起來就和微軟sdk寫法可說是一樣,因為有字數的限制所以它產生的註解就拿掉了,剩下只在WindowProcedure改一點點,沒有button也沒輸入框,有點太基本了.同樣的程式在Visual C++下也可以run.#include LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);char szClassName[ ] = "WindowsApp";int WINAPI WinMain (HINSTANCE hThisInstance,                    HINSTANCE hPrevInstance,                    LPSTR lpszArgument,                    int nFunsterStil){    HWND hwnd;    MSG messages;    WNDCLASSEX wincl;    wincl.hInstance = hThisInstance;    wincl.lpszClassName = szClassName;    wincl.lpfnWndProc = WindowProcedure;    wincl.style = CS_DBLCLKS;    wincl.cbSize = sizeof (WNDCLASSEX);    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);    wincl.lpszMenuName = NULL;     wincl.cbClsExtra = 0;    wincl.cbWndExtra = 0;    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;    if (!RegisterClassEx (&wincl))        return 0;    hwnd = CreateWindowEx (           0,           szClassName,           "Windows App",           WS_OVERLAPPEDWINDOW,           CW_USEDEFAULT,           CW_USEDEFAULT,           544,           375,           HWND_DESKTOP,           NULL,           hThisInstance,           NULL           );    ShowWindow (hwnd, nFunsterStil);    while (GetMessage (&messages, NULL, 0, 0))    {        TranslateMessage(&messages);        DispatchMessage(&messages);    }    return messages.wParam;}LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){        HDC hdc;        PAINTSTRUCT ps;        RECT rect;    switch (message)    {        case WM_DESTROY:            PostQuitMessage (0);            break;        case WM_PAINT:             hdc=BeginPaint(hwnd,&ps);             GetClientRect(hwnd,&rect);             DrawText(hdc,"Hello World!",-1,&rect,DT_CENTER);             EndPaint(hwnd,&ps);        default:            return DefWindowProc (hwnd, message, wParam, lParam);    }    return 0;}

2006-07-14 10:58:29 補充:
如果你是第一次看到這種windows程式,有點生澀是正常的,新學也需一段時間,但也如你所問的,它在windows下「通用」. Dev-C++本身較陽春,沒你講的那種,你可以改試wxDev-C++. 網址http://wxdsgn.sourceforge.net

2006-07-13 11:46:18 · answer #1 · answered by chan 5 · 0 0

fedest.com, questions and answers