Dialog Problem! not working,

This is a discussion on Dialog Problem! not working, within the Windows Programming forums, part of the Platform Specific Boards category; i get a bunch of errors the worst is in Lresult Callback at the bottom says LOWARD isnt defined main.cpp ...

  1. #1
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178

    Dialog Problem! not working,

    i get a bunch of errors the worst is in
    Lresult Callback at the bottom says LOWARD isnt defined

    main.cpp
    Code:
    #include <windows.h>
    #include "Resource.h"
    #include "Dialoghead.h"
    
    /*  Declare Windows procedure  */
    LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
    
    /*  Make the class name into a global variable  */
    char szClassName[ ] = "WindowsApp";
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    
    {
        HWND hwnd;               /* This is the handle for our window */
        MSG messages;            /* Here messages to the application are saved */
        WNDCLASSEX wincl;        /* Data structure for the windowclass */
    
        /* The Window structure */
        wincl.hInstance = hThisInstance;
        wincl.lpszClassName = szClassName;
        wincl.lpfnWndProc = WndProc;      /* This function is called by windows */
        wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
        wincl.cbSize = sizeof (WNDCLASSEX);
    
        /* Use default icon and mouse-pointer */
        wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hIconSm = LoadIcon (NULL, IDI_WARNING);
        wincl.hCursor = LoadCursor (NULL, IDC_SIZEALL);
        wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU);                 /* No menu */
        wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
        wincl.cbWndExtra = 0;                      /* structure or the window instance */
        /* Use Windows's default color as the background of the window */
        wincl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
    
        /* Register the window class, and if it fails quit the program */
        if (!RegisterClassEx (&wincl))
            return 0;
    
        /* The class is registered, let's create the program*/
        hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Windows App",       /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               CW_USEDEFAULT,       /* Windows decides the position */
               CW_USEDEFAULT,       /* where the window ends up on the screen */
               544,                 /* The programs width */
               375,                 /* and height in pixels */
               HWND_DESKTOP,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               hThisInstance,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
               );
    
        /* Make the window visible on the screen */
        ShowWindow (hwnd, nFunsterStil);
    
        /* Run the message loop. It will run until GetMessage() returns 0 */
        while (GetMessage (&messages, NULL, 0, 0))
        {
            /* Translate virtual-key messages into character messages */
            TranslateMessage(&messages);
            /* Send message to WindowProcedure */
            DispatchMessage(&messages);
        }
    
        /* The program return-value is 0 - The value that PostQuitMessage() gave */
        return messages.wParam;
    }
    
    
    /*  This function is called by the Windows function DispatchMessage()  */
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
        switch(Message)
        {
            case WM_COMMAND:
                 switch(LOWARD(wParam))
                 {
                      case ID_DIALOG_RUN:
                           int ret = DialogBox(GetModuleHandle(NULL), 
                           MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
                           
                           if(ret == IDOK){
                           MessageBox(hwnd, "Dialog exited with IDOK.", "Notice",
                           MB_OK | MB_ICONINFORMATION);
                           }
                           
                           else if(ret == IDCANCEL){
                           MessageBox(hwnd, "Dialog exited with IDCANCEL.", "Notice",
                           MB_OK | MB_ICONINFORMATION);
                           }
                
                           else if(ret == -1){
                           MessageBox(hwnd, "Dialog failed!", "Error",
                           MB_OK | MB_ICONERROR);
                           }
                      break;
                      case ID_FILE_EXIT:
                           DestroyWindow(hwnd);
                      break;
                }
            break;
            case WM_CLOSE:
                DestroyWindow(hwnd);
            break;
            case WM_DESTROY:
                PostQuitMessage(WM_QUIT);
            break;
            default:
                return DefWindowProc(hwnd, Message, wParam, lParam);
        }
        return 0;
    }
    Dialoghead.h
    Code:
    #ifndef _DIALOGHEAD_H_
    #define _DIALOGHEAD_H_
    bool CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
        switch(Message)
        {
            case WM_INITDIALOG:
    
            return TRUE;
            case WM_COMMAND:
                switch(LOWORD(wParam))
                {
                    case IDOK:
                        EndDialog(hwnd, IDOK);
                    break;
                    case IDCANCEL:
                        EndDialog(hwnd, IDCANCEL);
                    break;
                }
            break;
            default:
                return FALSE;
        }
        return TRUE;
    }
    #endif
    Resource.rc
    Code:
    #include "Resource.h"
    
    
    IDR_MYMENU MENU
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "&Open", 0, GRAYED
            MENUITEM "E&xit", ID_FILE_EXIT   
        END
    
        POPUP "&Stuff"
        BEGIN
            MENUITEM "&Dialog << Test", ID_DIALOG_RUN
        END
    END
    
    
    IDD_ABOUT DIALOG DISCARDABLE  0, 0, 239, 66
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION "My Dialog Box"
    FONT 8, "MS Sans Serif"
    BEGIN
        CTEXT           "An example program showing how to use Dialog Boxes\r\n\r\nby theForger",ID_TEXT,16,18,144,33
        GROUPBOX        "About this program...",ID_BOUT,174,18,50,14
        DEFPUSHBUTTON   "&OK",IDOK,174,18,50,14
        PUSHBUTTON      "&Cancel",IDCANCEL,174,35,50,14    
    END
    and finally Resource.h
    Code:
    #ifndef _RESOURCE_H_
    #define _RESOURCE_H_
    
    
    #define IDR_MYMENU 1001
    #define ID_FILE_EXIT 1002
    #define ID_DIALOG_RUN 1004
    
    #define IDD_ABOUT 1005
    #define ID_BOUT 1003
    #define ID_TEXT 1006
    
    #endif
    Please Help!
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,261
    That's because it isn't. You meant LOWORD.

  3. #3
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    mbad
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  4. #4
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    ok thats done now just this

    85 C:\Documents and Settings\Richard\Desktop\win api\Dialog\main.cpp initializing argument 4 of `int DialogBoxParamA(HINSTANCE__*, const CHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM), LPARAM)'

    on
    Code:
    nt ret = DialogBox(GetModuleHandle(NULL), 
                           MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
    and i still got sum errors

    103 C:\Documents and Settings\Richard\Desktop\win api\Dialog\main.cpp jump to case label

    85 C:\Documents and Settings\Richard\Desktop\win api\Dialog\main.cpp crosses initialization of `int ret'
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  5. #5
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    I can help you with this:
    Code:
    int ret = DialogBox(GetModuleHandle(NULL), 
                           MAKEINTRESOURCE(IDD_ABOUT), hwnd,(LONG) AboutDlgProc);

  6. #6
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Problems solved over MSN. There were three.....

    AboutDlgProc() was defined with the return type bool CALLBACK, rather than BOOL CALLBACK. Thus, DialogBox() wasn't accepting it. And you cannot cast AboutDlgProc as a LONG in DialogBox(). The fourth argument must be a function pointer, not a LONG.

    Second, the case statements in WndProc() needed to be encased in brackets. You should always encase your cases in brackets, unless they only contain one statement.

    Third, the program would not close. PostQuitMessage() should take 0 as its argument in order to close the entire program.
    Code:
    void function(void)
     {
      function();
     }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Chemistry Problem In C++ Script Not WORKING
    By Thinker in forum C++ Programming
    Replies: 4
    Last Post: 03-09-2008, 09:02 AM
  2. problem : input and calculation working together
    By itay390 in forum C Programming
    Replies: 13
    Last Post: 07-30-2005, 12:32 PM
  3. MFC Multi-threading is working ... Now another problem :(
    By SyntaxBubble in forum Windows Programming
    Replies: 3
    Last Post: 11-13-2003, 07:39 PM
  4. Problem with Dialog not showing
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 12-29-2002, 08:14 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21