Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Trang 1 của 2 12 CuốiCuối
Kết quả 1 đến 10 của 16
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    chọn project win32 app
    chọn empty project
    chọn trong properties lại là mfc statib lib


    hoặc ở vs2010
    new project win32
    statlic lib
    tắt dòng procombiled header đi


    1. new Item rc
    -> chuột phải -> view code
    Mã nguồn PHP:
    Dialog-name DIALOG [Option] X,Y,Width,HeightFeatures{ Dialog-items}  
    Mã nguồn PHP:
    langman DIAGLOG 18,18,142,92CAPTION L"Cui pap"STYLE DS_MODALFRAME|WS_POPUP|WS_CAPTION|WS_SYSMENU{ DEFPUSHBUTTON "Chuoi tieu",IDD_RED,32,40,30,14, WS_CHILD|WS_VISIBLE|WS_TABSTOP}  
    trong .h tạo ra kèm thêm
    Mã nguồn PHP:
    #define IDD_RED 200  

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    deleted.....................

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi chuong01
    hình như sai rồi anh langman ơi.
    Viết code tạo Dialog là phải có toán tử new mà, viết code trong file cpp đâu phải trong file rc đâu?
    biết thì thưa thớt, ko biết thì dựa cột mà nghe
    tạo teamplate trong rc rồi mới định nghĩa ra 1 đối tượng Diaglog
    sáng ra đang học , ngồi code hộ mà nói thế này khỏi hộ nữa
    cho nốt cái code nè, tự đi mà mày mò

    tạo 1 file cpp với nội dung
    Mã nguồn PHP:
    #include <afxwin.h>#include <Windows.h>#include <afxwinappex.h> // chứa lớp appex#include <afxdialogex.h> // chứa lớp dialog exclass langman:public CWinAppEx{public: BOOL InitInstance() { CDialogEx x(L"langman" ); // sử dụng tên template mẫu, hoặc ID của template mẫu, tùy theo định nghĩa x.DoModal(); return true; }};langman x;  

  5. #5
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    ko tạo được Dialog.
    MFC có cho tạo Dialog bằng code giống Java ko mấy anh?

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi chuong01
    ko tạo được Dialog.
    Có phải MFC ko cho tạo Dialog bằng code giống Java ko mấy anh?
    để tạo ra 1 đối tượng em dùng lớp
    <font color="#0000BB">CDialogEx

    <font color="black">là ok nhất, có thể định nghĩa mẫu cho nó ở trong rc


    sau đó gọi domodal để show dialog ra[IMG]images/smilies/dont_know.gif[/IMG][IMG]images/smilies/dont_know.gif[/IMG][IMG]images/smilies/dont_know.gif[/IMG]

    chi tiết về lớp này :
    http://msdn.microsoft.com/en-us/library/bb983913.aspx
    </font></font>

  7. #7
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi langman
    để tạo ra 1 đối tượng em dùng lớp
    <font color="#0000BB">CDialogEx

    <font color="black">là ok nhất, có thể định nghĩa mẫu cho nó ở trong rc


    sau đó gọi domodal để show dialog ra[IMG]images/smilies/dont_know.gif[/IMG][IMG]images/smilies/dont_know.gif[/IMG][IMG]images/smilies/dont_know.gif[/IMG]

    chi tiết về lớp này :
    http://msdn.microsoft.com/en-us/library/bb983913.aspx
    </font></font>
    Định nghĩa mẫu vẫn là kéo thả phải ko anh?
    Java chỉ cần viết code rồi copy paste thôi, có định nghĩa mẫu gì đâu?

  8. #8
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi chuong01
    Định nghĩa mẫu vẫn là kéo thả phải ko anh?
    Java chỉ cần viết code rồi copy paste thôi, có định nghĩa mẫu gì đâu?
    em có thể dùng các thương thức để định nghĩa lại style của Dialog ko cần mẫu mà

    ai bảo em là mẫu phải kéo thả
    kéo thả chẳng qua chỉ là từ design rồi sinh ra code thôi
    lúc đầu học có ai cho học kéo thả đâu,
    phải tự đi mà viết file rc == code mà

  9. #9
    anh langman cho em cái project mẫu đi.
    Em viết theo code của anh nhưng nó báo lỗi:
    http://www.mediafire.com/?8gu15hn3ymh8a46

  10. #10
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Nói chung thì bạn nên học cái khác đi đã, cái này gọi nguyên hàm APIs mệt lắm.

    Phải đọc MSDN mỏi mắt mới lần được ra.

    Giải thích thì MSDN có giải thích. Tôi lười giải thích & comment lắm. Bạn đọc tạm:

    Trích dẫn Gửi bởi MSDN
    CreateDialogIndirect Function

    --------------------------------------------------------------------------------

    The CreateDialogIndirect macro creates a modeless dialog box from a dialog box template in memory. The CreateDialogIndirect macro uses the CreateDialogIndirectParam function.

    Syntax

    Mã:
    HWND CreateDialogIndirect(          HINSTANCE hInstance,
        LPCDLGTEMPLATE lpTemplate,
        HWND hWndParent,
        DLGPROC lpDialogFunc
    );
    Parameters

    hInstance
    [in] Handle to the module that creates the dialog box.
    lpTemplate
    [in] Pointer to a global memory object containing a template that CreateDialogIndirect uses to create the dialog box. A dialog box template consists of a header that describes the dialog box, followed by one or more additional blocks of data that describe each of the controls in the dialog box. The template can use either the standard format or the extended format.
    In a standard template, the header is a DLGTEMPLATE structure followed by additional variable-length arrays. The data for each control consists of a DLGITEMTEMPLATE structure followed by additional variable-length arrays.

    In an extended dialog box template, the header uses the DLGTEMPLATEEX format and the control definitions use the DLGITEMTEMPLATEEX format.

    After CreateDialogIndirect returns, you can free the template, which is only used to get the dialog box started.

    hWndParent
    [in] Handle to the window that owns the dialog box.
    lpDialogFunc
    [in] Pointer to the dialog box procedure. For more information about the dialog box procedure, see DialogProc.
    Return Value

    If the function succeeds, the return value is the window handle to the dialog box.

    If the function fails, the return value is NULL. To get extended error information, call GetLastError.
    Tôi code tạm 1 cái Dlg bạn cứ như thế mà làm [IMG]images/smilies/smile.png[/IMG]

    Mã:
    #include <windows.h> BOOL CALLBACK DialogProc(HWND, UINT, WPARAM, LPARAM);typedef struct _DlgData{    DLGTEMPLATE mHeader;    WORD menu;    WORD stdClass;     wchar_t title[5];      DLGITEMTEMPLATE mItem;    WORD next;     WORD id;     WORD data; }DlgData;  DlgData dlg = {{WS_OVERLAPPEDWINDOW, 0, 1, 0, 0, 200, 200 },               0,               0x0000,               L"Test",               {WS_CHILD, 0, 0, 0, 200, 200, 1234 },               0xFFFF,               0x0011,               0               };int CALLBACK WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR szCmdLine, int nShowCmd){    MSG message;    HWND hwnd;    int status;     hwnd = CreateDialogIndirect(hInst, &dlg.mHeader, 0, DialogProc);    SetForegroundWindow(hwnd);    ShowWindow(hwnd, nShowCmd);    UpdateWindow(hwnd);    while((status = GetMessage(&message, 0, 0, 0)) != 0)    {        if(status == -1)            return -1;        if(!IsDialogMessage(hwnd, &message))        {            TranslateMessage(&message);            DispatchMessage(&message);        }    }    return (int)message.wParam;} BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){       switch (message)    {    case WM_INITDIALOG:        return TRUE;    case WM_COMMAND:                return TRUE;    case WM_HSCROLL:                return 0;    case WM_DESTROY:        PostQuitMessage(0);        return TRUE;    case WM_CLOSE:                DestroyWindow (hwnd);        return TRUE;    }    return FALSE;}

 

 
Trang 1 của 2 12 CuốiCuối

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •