Menu

Working With Dailog Boxes

2007-12-02
2012-09-26
  • Martian Man

    Martian Man - 2007-12-02

    Hello Everyone,
    Umm... I'm just starting out with dialog boxes and I need some help.
    Here's the code I have so far:

    .CPP file (In different parts of the file):

    (Part 1):
    INT_PTR CALLBACK AddDlgProc (HWND, UINT, WPARAM, LPARAM);

    (Part 2):
    INT_PTR CALLBACK AddDlgProc(HWND hwndAddDlg, UINT AddMsg, WPARAM AddwParam, LPARAM AddlParam)
    {
    /There is nothing here. I didn't know what to put here exactly, though I have somewhat of an idea; so I left it blank. Could someone tell me what to put here./
    }

    (Part 3):
    case IDM_ADD:
    DialogBox(hThisInstance, MAKEINTRESOURCE(IDD_ADD), hwnd, AddDlgProc);
    return 0;

    *Note: hThisInstance is defined as an HINSTANCE right between the switch(message) and the LRESULT CALLBACK WindowProcedure stuff.

    .H File:

    define IDM_ADD 0x022AB

    define IDD_ADD 003

    define IDDT_STATIC 0x001D1

    define DATE_PIX 0x002D1

    define IDDC_DATE 0x003D1

    define IDDC_TEXT 0x004D1

    define IDDC_TEXT1 0x005D1

    define IDDC_USEAGE 0x006D1

    define IDDC_STATIC 0x015D1

    define IDDC_ADDTEXT 0x007D1

    define IDDC_PARTSCB 0x008D1

    define IDDC_PARTSTYPES 0x009D1

    define IDDC_PARTSQUAN 0x010D1

    define IDDC_STATIC1 0x011D1

    define IDDC_ADDTYPE 0x012D1

    define IDDC_ADDOK 0x013D1

    define IDDC_ADDCANCEL 0x014D1

    define IDDI_DATA 0x002C

    .RC File:

    IDD_ADD DIALOGEX 50, 10, 200, 250
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION "Add"
    FONT 10,"MS Sans Serif"
    BEGIN
    LTEXT "Date:", IDDT_STATIC, 10, 30, 50, 20
    CONTROL "", DATE_PIX, "static", WS_CHILD | IDDI_DATA, 30, 30, 93, 32
    CONTROL "", IDDC_DATE, "edit", WS_CHILD | WS_BORDER | WS_TABSTOP | ES_LEFT, 10, 53, 50, 12
    CONTROL "", IDDC_TEXT, "static", WS_CHILD, 100, 23, 100, 10
    CONTROL "", IDDC_TEXT1, "static", WS_CHILD, 100, 33, 100, 18
    CONTROL "", IDDC_USEAGE, "edit", WS_CHILD | WS_BORDER | WS_TABSTOP | ES_LEFT, 100, 53, 50, 12
    LTEXT "Enter Service Performed", IDDC_STATIC, 5, 75, 100, 10
    CONTROL "",IDDC_ADDTEXT,"edit",WS_CHILD|WS_BORDER|WS_TABSTOP|ES_MULTILINE|ES_WANTRETURN,5,95,180,30
    CONTROL "", IDDC_PARTSCB, "combobox", WS_CHILD | WS_BORDER | CBS_DROPDOWNLIST, 5, 135, 60, 150
    CONTROL "", IDDC_PARTSTYPES, "combobox", WS_CHILD | WS_BORDER | CBS_DROPDOWNLIST, 70, 135, 60, 150
    CONTROL "", IDDC_PARTSQUAN, "edit", WS_CHILD | WS_BORDER, 140, 135, 10, 10
    LTEXT "Type", IDDC_STATIC1, 150, 210, 20, 10
    CONTROL "", IDDC_ADDTYPE, "edit", WS_CHILD | WS_BORDER, 150, 220, 7, 10
    PUSHBUTTON "OK", IDDC_ADDOK, 5, 220, 30, 20
    PUSHBUTTON "CANCEL", IDDC_ADDCANCEL, 50, 220, 50, 20
    END

    My whole program compiles correctly except for 2 resource warnings:
    0: 1033: Duplicate Value
    1: 1033: Duplicate Value

    And yes, my program runs correctly except for the dialog box.

    Here's my compile log:

    Compiler: Default compiler
    Building Makefile: "X:\Programs\Software\Media\Makefile.win"
    Executing make...
    make.exe -f "X:\Programs\Software\Media\Makefile.win" all
    g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"H:/Programs/KWWR Software/include"

    windres.exe -i RC_private.rc --input-format=rc -o RC_private.res -O coff

    windres.exe: warning: 14: 0: 1033: duplicate value
    windres.exe: warning: 16: 1: 1033: duplicate value

    g++.exe main.o RC_private.res -o "PartyMedia.exe" -L"C:/Dev-Cpp/lib" -L"C:/Documents and Settings/Martian/Desktop/My Software/libraries" -mwindows libwinmm.a

    Execution terminated
    Compilation successful

    The real reason I'm posting this though is that when I click on my menuitem "Add" (which is attached to the IDM_ADD case) it doesn't do anything. Of course, there is more to my program than this, this is just what you need to help me.

    Could someone please post the code here for what else I need and what I might be doing wrong. If someone could please give me links to websites that you think would be helpful to me in the future AFTER you've helped me here.

    By the way, I'm pretty sure that those duplicate values have to do with my dialog box, not my other stuff in my program. (They showed up when I was doing stuff with my dialog box.) If anybody can find a way to make those go away that would be helpful. And if you could explain what a duplicate value is, why it comes up all the time, and exactly why the number 1033 is used I would really appreciate it.

    Also, although I'd rather use my RC and my CPP file to make dialog boxes, if someone wants to tell me how to use the CreateDialog and other funcions to create the same dialog box I have posted above using my CPP file only that would be nice.

    Thank you very much! :)

     
    • BiT

      BiT - 2007-12-03
       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.