资源文件中的对话框

时间:2017-07-23 21:10:26

标签: c dialog resources rc

我正在尝试创建一个对话框,它在资源文件中返回一个错误。我一直在尝试执行不同类型的代码,并且发现了问题。它表示未知类型IDD_TOOL。这有什么不对吗?

我得到的错误是:

[Error] unknown type name 'IDD_TOOLBAR'
[Error] expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant (line 2 column 22 for resource code.)

这是资源代码。

IDD_ABOUT DIALOG DISCARDABLE  0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My About Box"
FONT 8, "MS Sans Serif"
BEGIN
    DEFPUSHBUTTON   "&OK",IDOK,174,18,50,14
    PUSHBUTTON      "&Cancel",IDCANCEL,174,35,50,14
    GROUPBOX        "About this program...",IDC_STATIC,7,7,225,52
    CTEXT           "An example program showing how to use Dialog Boxes\r\n\r\nby theForger",
                    IDC_STATIC,16,18,144,33
END

这是主要代码。

#include<windows.h>
#include "new.rc"
#include "main.h"
#define THEICON "windowIco.ico"

HWND g_hToolbar;


LRESULT CALLBACK newStartCallback(HWND newWindow, UINT msg, WPARAM wparam, LPARAM lparam){

    HMENU hmenu, hsubmenu;

    switch(msg){
        case WM_CREATE:
            hmenu= CreateMenu();
            hsubmenu = CreatePopupMenu();
            AppendMenu(hsubmenu, MF_STRING|MF_POPUP, 10001 , "&New");
            AppendMenu(hsubmenu, MF_STRING|MF_POPUP, 10002, "&Save File");
            AppendMenu(hmenu, MF_STRING|MF_POPUP,  (UINT)hsubmenu, "&File");
            hsubmenu = CreatePopupMenu();
            AppendMenu(hsubmenu, MF_STRING|MF_POPUP, 10003, "&Start");
            AppendMenu(hsubmenu, MF_STRING|MF_POPUP, 10004, "&dialogbox...");
            AppendMenu(hmenu, MF_STRING|MF_POPUP, (UINT)hsubmenu, "&uyu");
            SetMenu(newWindow, hmenu); //Forgot to add Set Menu function here
            break;
        case WM_COMMAND:
            switch(LOWORD(wparam)){  //gets low order of wparam.... LOWORD FUNCTION ONE PARAMETER INSIDE GETS ITS LOW ORDER VALUE
                case 10003:
                printf(" asdaksda");
                break;
                case 1004:
               // int dialogBoxint = DialogBox(GetModuleHandle(NULL), , newWindow, );
                break;
                default:
                printf(" asda");
                break;
            }
            break;
        default:
            return DefWindowProc(newWindow, msg, wparam, lparam);
    }

}

char classNameofTheNewWnd[] = "StartNewClass";

int WINAPI WinMain(HINSTANCE newWindowIns, HINSTANCE newPREVwindowIns, LPSTR dontknowthis, int nCommandShow){
    HWND newWindow;
    WNDCLASSEX windowclass;

    windowclass.cbSize = sizeof(WNDCLASSEX);
    windowclass.style = 0;
    windowclass.lpfnWndProc = newStartCallback;
    windowclass.hIcon = LoadImage(GetModuleHandle(NULL), THEICON, IMAGE_ICON, LR_DEFAULTSIZE, LR_DEFAULTSIZE, LR_LOADFROMFILE);  //
    windowclass.hIconSm = LoadIcon(GetModuleHandle(NULL), THEICON);          //turned to GetModuleHandle(NULL) from plain NULL                                                                     // THESE ARE THE ICONS LETS SEE WHICH ONE WORKS NOW :))))
    windowclass.lpszMenuName = NULL;
    windowclass.lpszClassName = classNameofTheNewWnd;
    windowclass.hbrBackground = (HBRUSH)(COLOR_WINDOW-2);
    windowclass.cbWndExtra = 0;
    windowclass.cbClsExtra = 0;
    windowclass.hInstance = newWindowIns;
    windowclass.hCursor = LoadCursor(NULL, IDC_CROSS);

    if(!RegisterClassEx(&windowclass)){
        printf("no");
    }
    newWindow = CreateWindowEx(WS_EX_CLIENTEDGE, classNameofTheNewWnd, "Start Something New", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1200, 550, NULL, NULL, newWindowIns, NULL);
    ShowWindow(newWindow, nCommandShow);

    MSG message;

    while(GetMessage(&message, NULL, 0, 0) > 0){ //don't forget to compare here..... if it is more than 0 then it means there is a new message!!!! :D
        TranslateMessage(&message);
        DispatchMessage(&message);
    }
    printf("message.wParam");
    return message.wParam;
}

0 个答案:

没有答案